def create_tables(self):
self.open_db()
- 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 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), permissions boolean not null default true, 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()
def get_feeds(self, client):
now = self.now()
- cursor = self.query("select id, server_id, channel_id, url, date, summary, link_json, enabled from feeds where bot_id=?", [client.user.id])
+ cursor = self.query("select id, server_id, channel_id, url, date, summary, link_json, permissions, enabled from feeds where bot_id=?", [client.user.id])
for row in cursor.fetchall():
yield dict(row)
self.close_db()
feeds.setdefault(feed['channel_id'], [])
feeds[feed['channel_id']].append(feed)
for channel_id in feeds.keys():
- yield from self.set_rss_permissions(channel_id)
+ if any([bot.parse_boolean(feed['permissions']) for feed in feeds[channel_id]]):
+ yield from self.set_rss_permissions(channel_id)
yield from self.do_rss(feeds[channel_id])
yield from asyncio.sleep(rsstime.value)
text += ' in <#{}>'.format(feed['channel_id'])
text += ' date {}'.format(feed['date'])
text += ' summary {}'.format(feed['summary'])
+ text += ' permissions {}'.format(feed['permissions'])
if feed['link_json']:
text += "--link_json '{}'".format(feed['link_json'])
lines.append(text)
elif arg == 'in':
k = 'channel_id'
if param:
- channel = bot.parse_channel(param, voice_ok = False)
+ if param == 'here':
+ channel = message.channel
+ if channel.is_private:
+ log.warning('Requested feed to private channel!')
+ break
+ else:
+ channel = bot.parse_channel(param, voice_ok = False)
if channel is not None:
parsed[k] = channel.id
ok = True
ok = True
else:
break
- elif arg in ['date', 'summary']:
+ elif arg in ['date', 'permissions', 'summary']:
k = arg
if param in ['true', 'false']:
parsed[k] = param
yield from bot.say(message.channel, '{}?'.format(arg))
return None
+ if 'permissions' not in parsed:
+ parsed['permissions'] = True
+
if 'channel_id' in parsed:
channel = client.get_channel(parsed['channel_id'])
if not channel:
'```summary true```',
'Include part of the text from the feed in the post.',
'',
+ '```permissions false```',
+ "Don't override the `CHANNEL` permissions to prevent others from posting there.",
+ '',
]
elif command == 'delete':
lines = [