mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
Updates for multiple modules, add messaging commands and priv checking
This commit is contained in:
parent
14b01e9796
commit
560f209b0f
@ -126,7 +126,8 @@ def watch_chanlist_complete(bot, trigger):
|
||||
|
||||
@sopel.module.nickname_commands('channels', 'channel')
|
||||
def nickname_comand_chanstats(bot, trigger):
|
||||
triggerargs = sopel_triggerargs(bot, trigger, 'nickname_command')
|
||||
|
||||
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command')
|
||||
|
||||
if not len(triggerargs):
|
||||
commandused = 'list'
|
||||
|
||||
@ -19,7 +19,7 @@ def gif_trigger(bot, trigger):
|
||||
while "SpiceBot_GifSearch" not in bot.memory:
|
||||
pass
|
||||
|
||||
triggerargs = sopel_triggerargs(bot, trigger)
|
||||
triggerargs, triggercommand = sopel_triggerargs(bot, trigger)
|
||||
if triggerargs == []:
|
||||
return bot.osd("Please present a query to search.")
|
||||
|
||||
|
||||
@ -19,16 +19,16 @@ def gifapi_triggers(bot, trigger):
|
||||
while "SpiceBot_GifSearch" not in bot.memory:
|
||||
pass
|
||||
|
||||
triggerargs, prefixcommand = sopel_triggerargs(bot, trigger, 'prefix_command')
|
||||
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'prefix_command')
|
||||
|
||||
if prefixcommand not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys():
|
||||
if triggercommand not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys():
|
||||
return
|
||||
|
||||
if triggerargs == []:
|
||||
return bot.osd("Please present a query to search.")
|
||||
|
||||
query = spicemanip.main(triggerargs, 0)
|
||||
searchdict = {"query": query, "gifsearch": prefixcommand}
|
||||
searchdict = {"query": query, "gifsearch": triggercommand}
|
||||
|
||||
gifdict = getGif(bot, searchdict)
|
||||
|
||||
|
||||
@ -101,7 +101,7 @@ def setup_thread(bot):
|
||||
|
||||
@sopel.module.commands('gif')
|
||||
def gif_trigger(bot, trigger):
|
||||
triggerargs = sopel_triggerargs(bot, trigger)
|
||||
triggerargs, triggercommand = sopel_triggerargs(bot, trigger)
|
||||
if triggerargs == []:
|
||||
return bot.osd("Please present a query to search.")
|
||||
|
||||
|
||||
52
sopel_modules/SpiceBot_Messaging/Messaging.py
Normal file
52
sopel_modules/SpiceBot_Messaging/Messaging.py
Normal file
@ -0,0 +1,52 @@
|
||||
# coding=utf-8
|
||||
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
|
||||
import sopel.module
|
||||
from sopel.tools import stderr
|
||||
|
||||
import sopel_modules.osd
|
||||
import spicemanip
|
||||
|
||||
from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, command_permissions_check, inlist
|
||||
|
||||
|
||||
def configure(config):
|
||||
pass
|
||||
|
||||
|
||||
def setup(bot):
|
||||
pass
|
||||
|
||||
|
||||
@sopel.module.nickname_commands('action', 'notice', 'privmsg')
|
||||
def bot_command_hub(bot, trigger):
|
||||
|
||||
if not command_permissions_check(bot, trigger, ['admins', 'owner']):
|
||||
bot.say("I was unable to process this Bot Nick command due to privilege issues.")
|
||||
return
|
||||
|
||||
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command')
|
||||
|
||||
if not len(triggerargs):
|
||||
bot.say("You must specify a channel.")
|
||||
return
|
||||
|
||||
channel = spicemanip.main(triggerargs, 1)
|
||||
if not inlist(bot, channel.lower(), bot.memory['SpiceBot_Channels']['channels'].keys()) and channel != 'all':
|
||||
bot.osd("Channel name {} not valid.".format(channel))
|
||||
return
|
||||
|
||||
triggerargs = spicemanip.main(triggerargs, '2+')
|
||||
|
||||
if channel == 'all':
|
||||
channelsendlist = bot.channels.keys()
|
||||
else:
|
||||
channelsendlist = [channel]
|
||||
|
||||
botmessage = spicemanip.main(triggerargs, 0)
|
||||
if not botmessage:
|
||||
bot.say("You must specify a message to send.")
|
||||
return
|
||||
|
||||
bot.osd(botmessage, channelsendlist, triggercommand.upper())
|
||||
8
sopel_modules/SpiceBot_Messaging/__init__.py
Normal file
8
sopel_modules/SpiceBot_Messaging/__init__.py
Normal file
@ -0,0 +1,8 @@
|
||||
# coding=utf8
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
|
||||
from .Messaging import *
|
||||
|
||||
__author__ = 'Sam Zick'
|
||||
__email__ = 'sam@deathbybandaid.net'
|
||||
__version__ = '0.1.0'
|
||||
@ -27,15 +27,48 @@ def sopel_triggerargs(bot, trigger, command_type='module_command'):
|
||||
triggerargs = spicemanip.main(triggerargs, 'create')
|
||||
|
||||
if command_type in ['module_command']:
|
||||
command = spicemanip.main(triggerargs, 1).lower()
|
||||
triggerargs = spicemanip.main(triggerargs, '2+', 'list')
|
||||
elif command_type in ['nickname_command']:
|
||||
command = spicemanip.main(triggerargs, 1).lower()[1:]
|
||||
triggerargs = spicemanip.main(triggerargs, '3+', 'list')
|
||||
elif command_type in ['prefix_command']:
|
||||
prefixcommand = spicemanip.main(triggerargs, 1).lower()[1:]
|
||||
command = spicemanip.main(triggerargs, 1).lower()[1:]
|
||||
triggerargs = spicemanip.main(triggerargs, '2+', 'list')
|
||||
return triggerargs, prefixcommand
|
||||
|
||||
return triggerargs
|
||||
return triggerargs, command
|
||||
|
||||
|
||||
def command_permissions_check(bot, trigger, privslist):
|
||||
|
||||
commandrunconsensus = []
|
||||
|
||||
for botpriv in ["admins", "owner"]:
|
||||
if botpriv in privslist:
|
||||
botpriveval = eval("bot.config.core." + botpriv)
|
||||
if not isinstance(botpriveval, list):
|
||||
botpriveval = [botpriv]
|
||||
if not inlist(bot, trigger.nick, botpriveval):
|
||||
commandrunconsensus.append('False')
|
||||
else:
|
||||
commandrunconsensus.append('True')
|
||||
|
||||
if not trigger.is_privmsg:
|
||||
for chanpriv in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']:
|
||||
if chanpriv in privslist:
|
||||
chanpriveval = channel_privs(bot, trigger.sender, chanpriv)
|
||||
if not inlist(bot, trigger.nick, chanpriveval):
|
||||
commandrunconsensus.append('False')
|
||||
else:
|
||||
commandrunconsensus.append('True')
|
||||
|
||||
if privslist == []:
|
||||
commandrunconsensus.append('True')
|
||||
|
||||
if 'True' not in commandrunconsensus:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
"""List Manipulation Functions"""
|
||||
|
||||
@ -11,7 +11,7 @@ import sopel_modules.osd
|
||||
|
||||
import spicemanip
|
||||
|
||||
from sopel_modules.SpiceBot_SBTools import service_manip, spicebot_update, sopel_triggerargs
|
||||
from sopel_modules.SpiceBot_SBTools import service_manip, spicebot_update, sopel_triggerargs, command_permissions_check
|
||||
|
||||
|
||||
class SpiceBot_Update_MainSection(StaticSection):
|
||||
@ -33,7 +33,11 @@ def setup(bot):
|
||||
@sopel.module.nickname_commands('update')
|
||||
def nickname_comand_chanstats(bot, trigger):
|
||||
|
||||
triggerargs = sopel_triggerargs(bot, trigger, 'nickname_command')
|
||||
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
|
||||
bot.say("I was unable to process this Bot Nick command due to privilege issues.")
|
||||
return
|
||||
|
||||
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command')
|
||||
|
||||
if not len(triggerargs):
|
||||
commandused = 'nodeps'
|
||||
@ -46,9 +50,6 @@ def nickname_comand_chanstats(bot, trigger):
|
||||
|
||||
triggerargs = spicemanip.main(triggerargs, '2+', 'list')
|
||||
|
||||
if not trigger.admin:
|
||||
bot.say("You are not authorized to perform this function.")
|
||||
|
||||
stderr("Recieved Command to update.")
|
||||
bot.osd("Received command from " + trigger.nick + " to update from Github and restart. Be Back Soon!", bot.channels.keys())
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user