Allow everyone to issue track moderator commands
By default, allow anyone in channel to issue track moderation commands (as that greatly simplifies administration). Add two admin commands to allow toggling that behavior on and off. Change-Id: I5dc95a1ea14b49c1882bd715b8fbdc3344867b64
This commit is contained in:
parent
492c8bd8b7
commit
23c688f041
11
README.rst
11
README.rst
|
@ -16,7 +16,10 @@ with several sections of information:
|
||||||
Track moderators commands
|
Track moderators commands
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
You have to have voice in the channel (+v) to send commands to the ptgbot.
|
By default the bot allows anyone in the channel to issue track moderation
|
||||||
|
commands. However note that it is possible for admins to restrict access
|
||||||
|
to people who have voice in the channel (+v).
|
||||||
|
|
||||||
Commands follow the following format::
|
Commands follow the following format::
|
||||||
|
|
||||||
#TRACKNAME COMMAND [PARAMETERS]
|
#TRACKNAME COMMAND [PARAMETERS]
|
||||||
|
@ -133,6 +136,12 @@ You have to be a channel operator (+o) to use admin commands.
|
||||||
~reload
|
~reload
|
||||||
Resets the database entirely (reloads from configuration)
|
Resets the database entirely (reloads from configuration)
|
||||||
|
|
||||||
|
~requirevoice
|
||||||
|
Requires that users are voiced (+v) to issue track moderation commands
|
||||||
|
|
||||||
|
~alloweveryone
|
||||||
|
Allows everyone in the channel to issue track moderation commands
|
||||||
|
|
||||||
|
|
||||||
Local testing
|
Local testing
|
||||||
=============
|
=============
|
||||||
|
|
|
@ -110,8 +110,9 @@ class PTGBot(irc.bot.SingleServerIRCBot):
|
||||||
chan = e.target
|
chan = e.target
|
||||||
|
|
||||||
if msg.startswith('#'):
|
if msg.startswith('#'):
|
||||||
if not (self.channels[chan].is_voiced(nick) or
|
if (self.data.is_voice_required() and not
|
||||||
self.channels[chan].is_oper(nick)):
|
(self.channels[chan].is_voiced(nick) or
|
||||||
|
self.channels[chan].is_oper(nick))):
|
||||||
self.send(chan, "%s: Need voice to issue commands" % (nick,))
|
self.send(chan, "%s: Need voice to issue commands" % (nick,))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -171,6 +172,10 @@ class PTGBot(irc.bot.SingleServerIRCBot):
|
||||||
self.data.unbook(room, timeslot)
|
self.data.unbook(room, timeslot)
|
||||||
elif command == 'newday':
|
elif command == 'newday':
|
||||||
self.data.new_day_cleanup()
|
self.data.new_day_cleanup()
|
||||||
|
elif command == 'requirevoice':
|
||||||
|
self.data.require_voice()
|
||||||
|
elif command == 'alloweveryone':
|
||||||
|
self.data.allow_everyone()
|
||||||
elif command == 'list':
|
elif command == 'list':
|
||||||
self.send_track_list(chan)
|
self.send_track_list(chan)
|
||||||
elif command in ('clean', 'add', 'del'):
|
elif command in ('clean', 'add', 'del'):
|
||||||
|
|
13
ptgbot/db.py
13
ptgbot/db.py
|
@ -26,7 +26,7 @@ import random
|
||||||
class PTGDataBase():
|
class PTGDataBase():
|
||||||
|
|
||||||
BASE = {'tracks': [], 'slots': {}, 'now': {}, 'next': {}, 'colors': {},
|
BASE = {'tracks': [], 'slots': {}, 'now': {}, 'next': {}, 'colors': {},
|
||||||
'location': {}, 'scheduled': {}, 'additional': {}}
|
'location': {}, 'scheduled': {}, 'additional': {}, 'voice': 0}
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.filename = config['db_filename']
|
self.filename = config['db_filename']
|
||||||
|
@ -167,6 +167,17 @@ class PTGDataBase():
|
||||||
self.data['additional'][room][timeslot] = ""
|
self.data['additional'][room][timeslot] = ""
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
def is_voice_required(self):
|
||||||
|
return self.data['voice'] == 1
|
||||||
|
|
||||||
|
def require_voice(self):
|
||||||
|
self.data['voice'] = 1
|
||||||
|
self.save()
|
||||||
|
|
||||||
|
def allow_everyone(self):
|
||||||
|
self.data['voice'] = 0
|
||||||
|
self.save()
|
||||||
|
|
||||||
def new_day_cleanup(self):
|
def new_day_cleanup(self):
|
||||||
self.data['now'] = {}
|
self.data['now'] = {}
|
||||||
self.data['next'] = {}
|
self.data['next'] = {}
|
||||||
|
|
Loading…
Reference in New Issue