Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0db9e19162 | ||
|
|
f68566d4e6 | ||
|
|
f7e65b0a17 | ||
|
|
dbec4ee962 | ||
|
|
3e1ff8c71e | ||
|
|
cc52ed006f | ||
|
|
2efd6161ad | ||
|
|
708bffde8f | ||
|
|
843e32067a | ||
|
|
2fd8d32335 | ||
|
|
4453d6a551 | ||
|
|
4296738220 | ||
|
|
88c24a93fa | ||
|
|
2e2a749e1a | ||
|
|
e4148743d1 | ||
|
|
f29a3c08f4 | ||
|
|
cb6e88758d | ||
|
|
a6ac1caff4 | ||
|
|
60154ed1bf | ||
|
|
157158fee3 | ||
|
|
ca77a071ae | ||
|
|
caf8c94666 | ||
|
|
10809e1c76 | ||
|
|
c3e61792cc | ||
|
|
239d8f3129 | ||
|
|
d971a6b9ff | ||
|
|
dc96447bd4 | ||
|
|
840f6cead8 | ||
|
|
70e66852d3 | ||
|
|
b30bade32e | ||
|
|
60b7e46b34 | ||
|
|
58fcd42961 | ||
|
|
3da237aceb | ||
|
|
b7f4abc454 | ||
|
|
073dec2be0 | ||
|
|
675873b3e2 | ||
|
|
07b61045f3 | ||
|
|
b18d2f7b45 | ||
|
|
761f87de8b | ||
|
|
5060f9eec1 | ||
|
|
db733b6bbd | ||
|
|
727f301ea7 | ||
|
|
974d60b609 | ||
|
|
a68f853d78 | ||
|
|
32176514e3 | ||
|
|
232c4178aa | ||
|
|
00b2ce7d49 | ||
|
|
e73b136d57 | ||
|
|
64bf2137c4 | ||
|
|
369485f0da | ||
|
|
e355764fba | ||
|
|
f4f813e4bc | ||
|
|
e511f9282a | ||
|
|
c0505192ee | ||
|
|
f4ef3e9cd8 | ||
|
|
c82bb3bd3c | ||
|
|
ae5cdd5bed | ||
|
|
f011ae73c5 | ||
|
|
39e1e7b395 | ||
|
|
e0e65ee8fc | ||
|
|
1ce75a2f3e | ||
|
|
7e3ad49a0d | ||
|
|
cdb764e586 | ||
|
|
c28f012f0c | ||
|
|
29ab3110e5 | ||
|
|
ca40b33099 |
No files matched your search
@@ -6,3 +6,4 @@ store
|
|||||||
*.pyo
|
*.pyo
|
||||||
*.pyd
|
*.pyd
|
||||||
.venv
|
.venv
|
||||||
|
krampus_calc.java
|
||||||
+2
-2
@@ -45,9 +45,9 @@ class CustomCtx(Context):
|
|||||||
else:
|
else:
|
||||||
pages.append(codeblock.format(string))
|
pages.append(codeblock.format(string))
|
||||||
string = ""
|
string = ""
|
||||||
string += p
|
string += p + '\n'
|
||||||
if string:
|
if string:
|
||||||
pages.append(string)
|
pages.append(codeblock.format(string))
|
||||||
await self.paginate(pages=pages, pagetype="text")
|
await self.paginate(pages=pages, pagetype="text")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+15
-2
@@ -199,8 +199,21 @@ class Main(commands.Cog):
|
|||||||
async def shell(self, ctx: commands.Context, *, cmd: codeblock_converter = None):
|
async def shell(self, ctx: commands.Context, *, cmd: codeblock_converter = None):
|
||||||
if cmd is None:
|
if cmd is None:
|
||||||
return
|
return
|
||||||
jskgit = bot.get_command("jsk sh")
|
jsksh = bot.get_command("jsk sh")
|
||||||
await ctx.invoke(jskgit, argument=cmd)
|
await ctx.invoke(jsksh, argument=cmd)
|
||||||
|
|
||||||
|
|
||||||
|
@commands.is_owner()
|
||||||
|
@commands.command(name="pullr")
|
||||||
|
async def pullr(self, ctx: CustomCtx):
|
||||||
|
"""
|
||||||
|
git pull and restart the bot.
|
||||||
|
"""
|
||||||
|
git = bot.get_command("jsk git")
|
||||||
|
await ctx.invoke(git, argument=codeblock_converter("pull"))
|
||||||
|
restart = bot.get_command("restart")
|
||||||
|
await ctx.invoke(restart)
|
||||||
|
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
|
|||||||
+814
-98
File diff suppressed because it is too large.
Load diff
+60
-2
@@ -1,17 +1,19 @@
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
|
import asyncio
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
from typing import List, Literal, Optional
|
from typing import List, Literal, Optional
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands, tasks
|
||||||
import pnwkit
|
import pnwkit
|
||||||
|
import pytz
|
||||||
from pnwkit import Order, OrderBy
|
from pnwkit import Order, OrderBy
|
||||||
|
from discord.utils import format_dt
|
||||||
|
|
||||||
from botclass import Brahmos, CustomCtx
|
from botclass import Brahmos, CustomCtx
|
||||||
|
|
||||||
|
|
||||||
class Misc(commands.Cog):
|
class Misc(commands.Cog):
|
||||||
def __init__(self, bot: Brahmos):
|
def __init__(self, bot: Brahmos):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
@@ -27,6 +29,10 @@ class Misc(commands.Cog):
|
|||||||
bot_key_api_key=os.getenv("pnwACCKEY"),
|
bot_key_api_key=os.getenv("pnwACCKEY"),
|
||||||
aiohttp_session=aiohttp.ClientSession(loop=self.bot.loop),
|
aiohttp_session=aiohttp.ClientSession(loop=self.bot.loop),
|
||||||
)
|
)
|
||||||
|
self.send_daily_message.start()
|
||||||
|
|
||||||
|
def cog_unload(self):
|
||||||
|
self.send_daily_message.cancel()
|
||||||
|
|
||||||
@commands.command(name="sex")
|
@commands.command(name="sex")
|
||||||
async def sex(self, ctx: CustomCtx):
|
async def sex(self, ctx: CustomCtx):
|
||||||
@@ -91,7 +97,59 @@ class Misc(commands.Cog):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return await ctx.cbsend(e)
|
return await ctx.cbsend(e)
|
||||||
|
|
||||||
|
@commands.command(name="color")
|
||||||
|
async def color(self, ctx):
|
||||||
|
"""
|
||||||
|
return members not olive colored in the alliance
|
||||||
|
"""
|
||||||
|
res = await self.kit.query(
|
||||||
|
"nations",
|
||||||
|
{"alliance_id": [10177, 10198]},
|
||||||
|
"id, leader_name, nation_name, color, vacation_mode_turns"
|
||||||
|
)
|
||||||
|
nations = [n for n in res.nations if n.color != "olive" and n.vacation_mode_turns == 0]
|
||||||
|
await ctx.send(
|
||||||
|
"> nations not olive:\n" + "\n".join([f"[{n.nation_name}](<https://politicsandwar.com/nation/id={n.id}>) [{n.leader_name}]" for n in nations])
|
||||||
|
)
|
||||||
|
|
||||||
|
def seconds_until_target(self, hour: int, minute: int = 0):
|
||||||
|
now = datetime.datetime.utcnow()
|
||||||
|
target = now.replace(hour=hour, minute=minute, second=0, microsecond=0)
|
||||||
|
if target < now:
|
||||||
|
target += datetime.timedelta(days=1)
|
||||||
|
return (target - now).total_seconds()
|
||||||
|
|
||||||
|
@tasks.loop(hours=24)
|
||||||
|
async def send_daily_message(self):
|
||||||
|
channel = self.bot.get_channel(1356234853217075200)
|
||||||
|
res = await self.kit.query(
|
||||||
|
"nations",
|
||||||
|
{"alliance_id": [10177, 10198], "alliance_position": [2,3,4,5]},
|
||||||
|
"id, leader_name, nation_name, color, vacation_mode_turns, last_active"
|
||||||
|
)
|
||||||
|
nations = [n for n in res.nations if n.color != "olive" and n.vacation_mode_turns == 0]
|
||||||
|
await channel.send(
|
||||||
|
"> nations not olive:\n" + "\n".join([f"[{n.nation_name}](<https://politicsandwar.com/nation/id={n.id}>) [{n.leader_name}]" for n in nations])
|
||||||
|
)
|
||||||
|
inactives = []
|
||||||
|
for nation in res.nations:
|
||||||
|
if nation.vacation_mode_turns != 0:
|
||||||
|
continue
|
||||||
|
utcnow = datetime.datetime.utcnow().replace(tzinfo=pytz.utc)
|
||||||
|
delta = utcnow - nation.last_active
|
||||||
|
if delta > datetime.timedelta(days=2, hours=16):
|
||||||
|
inactives.append(nation)
|
||||||
|
if inactives:
|
||||||
|
await channel.send(
|
||||||
|
"> Inactive nations:\n" + "\n".join([f"[{n.nation_name}](<https://politicsandwar.com/nation/id={n.id}>) [{n.leader_name}] {format_dt(n.last_active)}" for n in inactives])
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@send_daily_message.before_loop
|
||||||
|
async def before_send_daily_message(self):
|
||||||
|
await self.bot.wait_until_ready()
|
||||||
|
seconds = self.seconds_until_target(2, 5)
|
||||||
|
await asyncio.sleep(seconds)
|
||||||
|
|
||||||
|
|
||||||
async def setup(bot: commands.Bot):
|
async def setup(bot: commands.Bot):
|
||||||
|
|||||||
+18
-1
@@ -303,6 +303,8 @@ class WarMonitor(commands.Cog):
|
|||||||
self.monitored_wars.append(war.id)
|
self.monitored_wars.append(war.id)
|
||||||
category = await self.bot.fetch_channel(CATEGORY)
|
category = await self.bot.fetch_channel(CATEGORY)
|
||||||
attacker, defender = await get_nation(self.kit, [war.att_id, war.def_id])
|
attacker, defender = await get_nation(self.kit, [war.att_id, war.def_id])
|
||||||
|
if defender.alliance_position.name == "APPLICANT":
|
||||||
|
return
|
||||||
channel = await category.create_text_channel(
|
channel = await category.create_text_channel(
|
||||||
name=f"{attacker.nation_name.lower()}-{war.id}"
|
name=f"{attacker.nation_name.lower()}-{war.id}"
|
||||||
)
|
)
|
||||||
@@ -478,7 +480,7 @@ class WarMonitor(commands.Cog):
|
|||||||
await ctx.send(f"this command only works inside {category.name}")
|
await ctx.send(f"this command only works inside {category.name}")
|
||||||
return
|
return
|
||||||
await ctx.channel.edit(category=(await self.bot.fetch_channel(ARCHIVE_CATEGORY)))
|
await ctx.channel.edit(category=(await self.bot.fetch_channel(ARCHIVE_CATEGORY)))
|
||||||
await ctx.channel.send("channel moved to archived category")
|
await ctx.channel.send("> channel moved to archive, you can also do fr delete to delete the channel or fr delall to delete all channels in archive.")
|
||||||
# sync perms to archive category
|
# sync perms to archive category
|
||||||
await ctx.channel.edit(sync_permissions=True)
|
await ctx.channel.edit(sync_permissions=True)
|
||||||
|
|
||||||
@@ -503,6 +505,21 @@ class WarMonitor(commands.Cog):
|
|||||||
return
|
return
|
||||||
await ctx.channel.delete()
|
await ctx.channel.delete()
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
@commands.has_permissions(administrator=True)
|
||||||
|
@commands.has_role("The Croak Council")
|
||||||
|
async def delall(self, ctx: CustomCtx):
|
||||||
|
category = await self.bot.fetch_channel(ARCHIVE_CATEGORY)
|
||||||
|
if ctx.channel not in category.text_channels:
|
||||||
|
await ctx.send(f"this command only works inside {category.name}")
|
||||||
|
return
|
||||||
|
for channel in category.text_channels:
|
||||||
|
try:
|
||||||
|
await channel.delete()
|
||||||
|
except Exception as e:
|
||||||
|
await ctx.send(f"failed to delete channel: {e}")
|
||||||
|
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def monitored(self, ctx: CustomCtx):
|
async def monitored(self, ctx: CustomCtx):
|
||||||
await ctx.send(self.monitored_wars)
|
await ctx.send(self.monitored_wars)
|
||||||
|
|||||||
+1
-1
@@ -50,7 +50,7 @@ async def get_nation(kit: pnwkit.QueryKit, id: Union[List[int], int]) -> Union[p
|
|||||||
nation = await kit.query(
|
nation = await kit.query(
|
||||||
"nations",
|
"nations",
|
||||||
{"id": id},
|
{"id": id},
|
||||||
"nation_name, flag, num_cities, soldiers, tanks, aircraft, ships, missiles, score, nukes, id, alliance {name, id, flag}, discord, vacation_mode_turns",
|
"nation_name, flag, num_cities, soldiers, tanks, aircraft, ships, missiles, score, nukes, id, alliance {name, id, flag}, discord, vacation_mode_turns, color, alliance_position",
|
||||||
)
|
)
|
||||||
if isinstance(id, list):
|
if isinstance(id, list):
|
||||||
result = []
|
result = []
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
import pnwkit
|
|
||||||
|
|
||||||
|
|
||||||
class Bank:
|
|
||||||
def __init__(self, kit: pnwkit.QueryKit):
|
|
||||||
self.kit = kit
|
|
||||||
|
|
||||||
async def balance(self, id: int):
|
|
||||||
"""
|
|
||||||
receiver_type:
|
|
||||||
()
|
|
||||||
"""
|
|
||||||
resources = await self.kit.query(
|
|
||||||
"alliances",
|
|
||||||
{"id": 10177, "first": 1},
|
|
||||||
"money, food, uranium, coal, iron, oil, bauxite, iron, lead, munitions, gasoline, aluminum, steel",
|
|
||||||
)
|
|
||||||
Reference in new issue
Block a user