add db
This commit is contained in:
1 parent
799dc4f7cb
commit
43ca775fb0
8 files changed
+65
-44
No files matched your search
+18
-3
@@ -27,10 +27,9 @@ CATEGORY = 1356240812861821048
|
||||
ARCHIVE_CATEGORY = 1367458846708334703
|
||||
OFFENSIVE_LOG_CHANNEL = 1353940560771027034
|
||||
DEFENSIVE_LOG_CHANNEL = 1353940670246686843
|
||||
MONITORED_ALLIANCES = [10177, 10198]
|
||||
MONITORED_ALLIANCES = [10177, 10198, 11965]
|
||||
ALLIANCE_ATK_CH = 1367461291685318686
|
||||
|
||||
REFILL_LIST = json.load(open("refill.json"))
|
||||
|
||||
logger = logging.getLogger("discord")
|
||||
# decorator to log errors for a function manually
|
||||
@@ -73,6 +72,7 @@ class WarMonitor(commands.Cog):
|
||||
self.war_update_task = None
|
||||
self.war_attacks_task = None
|
||||
self.monitored_wars = []
|
||||
self.allied_nations = []
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_ready(self):
|
||||
@@ -80,6 +80,21 @@ class WarMonitor(commands.Cog):
|
||||
war_ids = [ch.name.split("-")[-1] for ch in category.text_channels]
|
||||
war_ids = [int(x) for x in war_ids if x.isdigit()]
|
||||
self.monitored_wars.extend(war_ids)
|
||||
await self.set_allied_nations()
|
||||
|
||||
async def set_allied_nations(self):
|
||||
"""Fetch allied nations."""
|
||||
result = await self.kit.query(
|
||||
"nation",
|
||||
{"alliance_id": [10177, 10198, 11965]},
|
||||
"id"
|
||||
)
|
||||
if not result:
|
||||
logger.warning("Failed to fetch allied nations")
|
||||
self.allied_nations.extend(
|
||||
[nation.id for nation in result.nations]
|
||||
)
|
||||
|
||||
|
||||
async def cog_load(self):
|
||||
self.war_create_task = self.bot.loop.create_task(self.war_create_subscription())
|
||||
@@ -416,7 +431,7 @@ class WarMonitor(commands.Cog):
|
||||
await channel.send(msg)
|
||||
|
||||
async def log_ally_attacks(self, warattack: pnwkit.WarAttack):
|
||||
if not warattack.att_id in REFILL_LIST:
|
||||
if not warattack.att_id in self.allied_nations:
|
||||
return
|
||||
channel = await self.bot.fetch_channel(ALLIANCE_ATK_CH)
|
||||
attacker, defender = await get_nation(self.kit, [warattack.att_id, warattack.def_id])
|
||||
|
||||
Reference in new issue
Block a user