Compare commits

...
66 Commits
Author SHA1 Message Date
un1xx 0db9e19162 Merge branch 'main' into rev-calc 2025-06-06 22:22:24 +05:30
un1xx f68566d4e6 update refill cmd 2025-06-06 22:17:52 +05:30
un1xx f7e65b0a17 update refill cmd 2025-06-06 21:31:08 +05:30
un1xx dbec4ee962 update refill cmd 2025-06-06 21:24:28 +05:30
un1xx 3e1ff8c71e update refill cmd 2025-06-06 21:18:14 +05:30
un1xx cc52ed006f update refill cmd 2025-06-06 21:17:15 +05:30
un1xx 2efd6161ad update refill cmd 2025-06-06 21:15:42 +05:30
un1xx 708bffde8f update refill cmd 2025-06-06 21:12:16 +05:30
un1xx 843e32067a update refill cmd 2025-06-06 21:09:42 +05:30
un1xx 2fd8d32335 update raws cmd 2025-06-06 19:30:54 +05:30
un1xx 4453d6a551 update raws cmd 2025-06-06 19:17:38 +05:30
un1xx 4296738220 update raws cmd 2025-06-06 19:15:04 +05:30
un1xx 88c24a93fa update raws cmd 2025-06-06 19:09:43 +05:30
un1xx 2e2a749e1a update raws cmd 2025-06-06 19:07:15 +05:30
un1xx e4148743d1 update raws cmd 2025-06-06 19:04:21 +05:30
karan f29a3c08f4 expose nation rss in embed 2025-06-01 19:16:15 +05:30
karan cb6e88758d changes 2025-06-01 19:12:47 +05:30
karan a6ac1caff4 changes 2025-06-01 19:10:58 +05:30
karan 60154ed1bf updated calculations 2025-06-01 19:03:34 +05:30
karan 157158fee3 removed all monetary/manufacturing calculation 2025-06-01 18:37:00 +05:30
un1xx ca77a071ae update 2025-05-25 23:10:36 +05:30
un1xx caf8c94666 update 2025-05-25 23:09:20 +05:30
un1xx 10809e1c76 update 2025-05-25 23:07:34 +05:30
un1xx c3e61792cc update 2025-05-25 23:06:26 +05:30
un1xx 239d8f3129 update 2025-05-25 23:05:18 +05:30
un1xx d971a6b9ff update 2025-05-25 22:53:50 +05:30
un1xx dc96447bd4 update 2025-05-25 22:52:43 +05:30
un1xx 840f6cead8 update 2025-05-25 22:51:35 +05:30
un1xx 70e66852d3 update 2025-05-25 22:47:57 +05:30
un1xx b30bade32e update 2025-05-25 22:40:14 +05:30
un1xx 60b7e46b34 tf cmd 2025-05-25 22:30:39 +05:30
karan 58fcd42961 raise errors 2025-05-25 22:13:03 +05:30
karan 3da237aceb strptime is updated but code is not 2025-05-25 22:04:18 +05:30
karan b7f4abc454 changes 2025-05-25 22:02:04 +05:30
karan 073dec2be0 nation['cities'] to nation.cities 2025-05-25 21:52:45 +05:30
karan 675873b3e2 changes 2025-05-25 21:38:15 +05:30
karan 07b61045f3 fix 2025-05-25 21:33:09 +05:30
karan b18d2f7b45 another spelling 2025-05-25 21:31:29 +05:30
karan 761f87de8b spelling, also only 10198 for testing 2025-05-25 21:29:49 +05:30
karan 5060f9eec1 misspelling 2025-05-25 21:26:24 +05:30
karan db733b6bbd changes 2025-05-25 21:24:47 +05:30
karan 727f301ea7 changes 2025-05-25 21:23:17 +05:30
karan 974d60b609 facepalm 2025-05-25 21:13:21 +05:30
karan a68f853d78 changes 2025-05-25 21:09:25 +05:30
karan 32176514e3 alias and function definition cannot be the same 2025-05-25 21:06:44 +05:30
karan 232c4178aa changes 2025-05-25 20:58:29 +05:30
karan 00b2ce7d49 initial_resource_calculation 2025-05-25 20:49:22 +05:30
un1xx e73b136d57 Update banking.py 2025-05-15 20:42:15 +05:30
un1xx 64bf2137c4 Update banking.py 2025-05-15 20:40:44 +05:30
un1xx 369485f0da Update banking.py 2025-05-15 20:38:31 +05:30
un1xx e355764fba Update banking.py 2025-05-15 20:21:36 +05:30
un1xx f4f813e4bc Update misc.py 2025-05-15 20:19:56 +05:30
un1xx e511f9282a update 2025-05-13 10:17:08 +05:30
un1xx c0505192ee add delall cmd 2025-05-12 21:32:38 +05:30
un1xx f4ef3e9cd8 add delall cmd 2025-05-12 21:31:23 +05:30
un1xx c82bb3bd3c update war logger 2025-05-12 21:19:48 +05:30
un1xx ae5cdd5bed Update misc.py 2025-05-11 22:37:12 +05:30
un1xx f011ae73c5 Update misc.py 2025-05-11 22:34:29 +05:30
un1xx 39e1e7b395 add color cmd 2025-05-11 22:12:47 +05:30
un1xx e0e65ee8fc modify pullr 2025-05-11 18:01:08 +05:30
un1xx 1ce75a2f3e modify pullr 2025-05-11 17:47:01 +05:30
un1xx 7e3ad49a0d modify wc 2025-05-11 17:41:57 +05:30
un1xx cdb764e586 fix error in pullr 2025-05-11 17:17:31 +05:30
un1xx c28f012f0c fix error in wc 2025-05-11 17:16:01 +05:30
un1xx 29ab3110e5 update owner cmds 2025-05-11 17:07:18 +05:30
un1xx ca40b33099 fix error in cbsend 2025-05-09 22:59:38 +05:30
8 changed files with 913 additions and 125 deletions

No files matched your search

+1
View File
@@ -6,3 +6,4 @@ store
*.pyo *.pyo
*.pyd *.pyd
.venv .venv
krampus_calc.java
+2 -2
View File
@@ -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
View File
@@ -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()
+816 -100
View File
File diff suppressed because it is too large. Load diff
+60 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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 = []
-17
View File
@@ -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",
)