Feeds can be temporarily disabled.
authorCMDR furrycat <elite@furrycat.net>
Sun, 23 Oct 2016 11:38:08 +0000 (12:38 +0100)
committerCMDR furrycat <elite@furrycat.net>
Sun, 23 Oct 2016 11:38:08 +0000 (12:38 +0100)
bot.py
db.py

diff --git a/bot.py b/bot.py
index 41dcbf7..75084d1 100755 (executable)
--- a/bot.py
+++ b/bot.py
@@ -955,6 +955,8 @@ def do_feeds():
   while True:
     feeds = {}
     for feed in list(db.get_feeds(client)):
+      if not parse_boolean(feed['enabled']):
+        continue
       feeds.setdefault(feed['channel_id'], [])
       feeds[feed['channel_id']].append(feed)
     for channel_id in feeds.keys():
diff --git a/db.py b/db.py
index 254f9bf..7c07d7a 100644 (file)
--- a/db.py
+++ b/db.py
@@ -36,7 +36,7 @@ class DBConnection(object):
     cursor = self.query('create table if not exists announcements (id char(36) not null, bot_id varchar(32) not null, server_id varchar(32) not null, member_id varchar(32) not null, channel_id varchar(32) not null, voice_id varchar(32), sound varchar(128), mention varchar(32), start_date datetime, end_date datetime, interval int, probability float not null default 1.0, last_spoke datetime, asap boolean not null default false, message text, digest char(56))')
     cursor = self.query('create unique index if not exists announcements_id on announcements (id)')
     cursor = self.query('create index if not exists announcements_bot_id on announcements (bot_id)')
-    cursor = self.query('create table if not exists feeds (id char(36) not null, bot_id varchar(32) not null, server_id varchar(32) not null, channel_id varchar(32) not null, description varchar(64), url varchar(128) not null, date boolean not null default true, summary boolean not null default false, link_json varchar(256))')
+    cursor = self.query('create table if not exists feeds (id char(36) not null, bot_id varchar(32) not null, server_id varchar(32) not null, channel_id varchar(32) not null, description varchar(64), url varchar(128) not null, date boolean not null default true, summary boolean not null default false, link_json varchar(256), enabled boolean not null default true)')
     cursor = self.query('create unique index if not exists feed_id on feeds (id)')
     cursor = self.query('create index if not exists feed_bot_id on feeds (bot_id)')
     self.dbh.commit()
@@ -178,7 +178,7 @@ class DBConnection(object):
 
   def get_feeds(self, client):
     now = self.now()
-    cursor = self.query("select id, server_id, channel_id, url, date, summary, link_json from feeds where bot_id=?", [client.user.id])
+    cursor = self.query("select id, server_id, channel_id, url, date, summary, link_json, enabled from feeds where bot_id=?", [client.user.id])
     for row in cursor.fetchall():
       yield dict(row)
     self.close_db()