Save faction ID in factions table.
authorCMDR furrycat <elite@furrycat.net>
Sat, 15 Apr 2017 20:57:10 +0000 (21:57 +0100)
committerCMDR furrycat <elite@furrycat.net>
Sat, 15 Apr 2017 20:57:10 +0000 (21:57 +0100)
plugin/faction/faction.py

index 128fbae..0c31be7 100644 (file)
@@ -47,7 +47,7 @@ class Faction(DBConnection):
 
   def create_tables(self):
     self.open_db()
-    cursor = self.query('create table if not exists factions (id char(36) not null, bot_id varchar(32) not null, member_id varchar(32) not null, server_id varchar(32) not null, channel_id varchar(32) not null, newsflash_channel_id varchar(32), name varchar(128) not null, state_id int not null, interval int not null default 86400, updated datetime)')
+    cursor = self.query('create table if not exists factions (id char(36) not null, bot_id varchar(32) not null, member_id varchar(32) not null, server_id varchar(32) not null, channel_id varchar(32) not null, newsflash_channel_id varchar(32), faction_id int not null, name varchar(128) not null, state_id int not null, interval int not null default 86400, updated datetime)')
     cursor = self.query('create unique index if not exists factions_id on factions (id)')
     cursor = self.query('create index if not exists factions_bot_id on factions (bot_id)')
     cursor = self.query('create table if not exists faction_names (faction_id int not null, name varchar(128) not null)')
@@ -310,7 +310,7 @@ class Faction(DBConnection):
     if len(lines):
       await bot.say_many(message.channel, lines)
     for tracked in self.tracked_factions:
-      await self.report_stale_influence(message.channel, name = tracked.name)
+      await self.report_stale_influence(message.channel, id = tracked.faction_id)
 
   async def list_tracked_factions(self, message):
     results = []
@@ -471,8 +471,8 @@ class Faction(DBConnection):
       log.warning("Can't get channel for faction {}".format(tracked.id))
 
     self.update_tracked_faction(tracked.id, **update)
-    await self.report_faction_influence(channel, name = tracked.name, yelp_if_no_data = False)
-    await self.report_stale_influence(channel, name = tracked.name)
+    await self.report_faction_influence(channel, id = tracked.faction_id, yelp_if_no_data = False)
+    await self.report_stale_influence(channel, id = tracked.faction_id)
 
   async def get_faction(self, destination, name):
     factions = eddb.find_faction(name)