Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@module.require_admin('You must be a bot admin to use this command')
def say_admin_list(bot, trigger):
"""Sends privmsg of all current admins.
Will only respond to bot admins."""
bot.say('Check your PM')
bot.say('Current bot owner: ' + bot.config.core.owner, trigger.nick)
admins = bot.config.core.admins
if len(admins) > 0:
bot.say('Current bot admins:', trigger.nick)
for admin in admins.split(','):
bot.say('\t' + admin, trigger.nick)
else:
bot.say('No configured admins', trigger.nick)
bot.say('New admins can be added by creating a PR against '
'https://github.com/openshift/openshift-ansible-ops/tree/prod/playbooks/adhoc/ircbot', trigger.nick)
@module.require_admin('You must be a bot admin to use this command')
def unmark_channel_track_oncall(bot, trigger):
"""Stops tracking on-call and shift lead rotations for channel."""
if bot.db.get_channel_value(trigger.sender, 'monitoring'):
bot.db.set_channel_value(trigger.sender, 'monitoring', None)
bot.db.set_channel_value(trigger.sender, 'announce', None)
bot.say(trigger.sender + ' is no longer tracking SRE on-call rotations.')
else:
bot.say(trigger.sender + ' is not currently tracking SRE on-call rotations.')
@module.require_admin('You must be a bot admin to use this command')
def unmark_channel_announcements(bot, trigger):
"""Stops shift change announcements in channel, while still allowing the other benefits of tracking
the shift change schedule."""
if bot.db.get_channel_value(trigger.sender, 'monitoring'):
if bot.db.get_channel_value(trigger.sender, 'announce'):
bot.db.set_channel_value(trigger.sender, 'announce', None)
bot.say('I will no longer announce shift changes in this channel.')
bot.say('Topic updates will still occur if I have the proper permissions.')
else:
bot.say('I\'m already not announcing in this channel.')
else:
bot.say('I\'m not currently tracking this channel. Check out .help track')
@sopel.module.require_admin(message='Nope')
@sopel.module.commands('qw')
def qw(bot, tr):
with open('quotes.txt') as file:
quotes = [i for i in file]
for q in quotes:
jarvis.notes.quote(q, bot.config.scp.sssc)
bot.send('FINISHED ADDING {}'.format(len(quotes)))
@module.require_admin('You must be a bot admin to use this command')
def delete_user_from_msg(bot, trigger):
"""Will delete a user from receiving .msg messages.
Will only respond to bot admins."""
if trigger.group(2):
msg_list = get_msg_list(bot, trigger.sender)
if len(msg_list) > 0 and trigger.group(2) in msg_list:
msg_list.remove(trigger.group(2))
bot.db.set_channel_value(trigger.sender, 'msg_list', msg_list)
bot.say(trigger.group(2) + ' has been removed from the .msg list.')
else:
bot.say('That nick (' + trigger.group(2) + ') does not exist in the .msg list.')
else:
bot.say('Don\'t forget to give me the nick to remove from the .msg list.')
@module.require_admin('You must be a bot admin to use this command')
def mark_channel_announcements(bot, trigger):
"""Starts shift change announcements in channel if previously stopped."""
if bot.db.get_channel_value(trigger.sender, 'monitoring'):
if bot.db.get_channel_value(trigger.sender, 'announce'):
bot.say('I\'m already announcing in this channel.')
else:
bot.db.set_channel_value(trigger.sender, 'announce', True)
bot.say('I will resume announcements in this channel.')
else:
bot.say('I\'m not currently tracking this channel. Check out .help track')
@module.require_admin('You must be a bot admin to use this command')
def add_user_to_msg(bot, trigger):
"""Will add a user as a managed user for receiving .msg messages.
Will only respond to bot admins."""
if trigger.group(2):
msg_list = get_msg_list(bot, trigger.sender)
msg_list.append(trigger.group(2))
bot.db.set_channel_value(trigger.sender, 'msg_list', msg_list)
if len(msg_list) > 0:
bot.say(trigger.group(2) + ' has been added to the .msg list.')
else:
bot.say('The .msg list has been initialized, and ' + trigger.group(2) + ' has been added.')
else:
bot.say('Don\'t forget to give me the nick to add to the .msg list.')
@module.require_admin('You must be a bot admin to use this command')
def delete_all_users_from_msg(bot, trigger):
"""Deletes all users from receiving .msg messages.
Will only respond to bot admins."""
if trigger.group(2) == 'confirm':
bot.db.set_channel_value(trigger.sender, 'msg_list', None)
bot.say('I\'ve removed all users from the .msg list.')
else:
msg_list = get_msg_list(bot, trigger.sender)
if len(msg_list) > 0:
bot.say('This is a destructive command that will remove ' + str(len(msg_list)) +
' users from the .msg list.')
bot.reply('If you still want to do this, please run: .msg-deleteall confirm')
else:
bot.db.set_channel_value(trigger.sender, 'msg_list', None)
bot.say('There are no users to delete.')
@module.require_admin('You must be a bot admin to use this command')
def say_monitored_channels_list(bot, trigger):
"""Sends PRIVMSG of all channels currently monitored for on-call and shift lead rotations.
Will only respond to bot admins."""
channels = 0
for channel in bot.channels:
if bot.db.get_channel_value(channel, 'monitoring'):
bot.say(channel, trigger.nick)
channels += 1
if channels == 0:
bot.say('No monitored channels.', trigger.nick)
bot.say('I\'ve sent you a privmsg.')