mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
Gif Tweaks
This commit is contained in:
parent
f9f030b1a5
commit
86b0f7c91d
@ -8,11 +8,11 @@ from sopel.config.types import StaticSection, ValidatedAttribute
|
|||||||
|
|
||||||
import sopel_modules.osd
|
import sopel_modules.osd
|
||||||
|
|
||||||
from sopel_modules.SpiceBot_Botevents.BotEvents import set_bot_event
|
from sopel_modules.SpiceBot_Botevents.BotEvents import set_bot_event, check_bot_events, startup_bot_event
|
||||||
|
|
||||||
from sopel_modules.SpiceBot_CommandsQuery.CommandsQuery import commandsquery_register
|
from sopel_modules.SpiceBot_CommandsQuery.CommandsQuery import commandsquery_register
|
||||||
|
|
||||||
from sopel_modules.SpiceBot_SBTools import read_directory_json_to_dict
|
from sopel_modules.SpiceBot_SBTools import read_directory_json_to_dict, sopel_triggerargs
|
||||||
|
|
||||||
import spicemanip
|
import spicemanip
|
||||||
|
|
||||||
@ -62,6 +62,8 @@ def setup(bot):
|
|||||||
|
|
||||||
def setup_thread(bot):
|
def setup_thread(bot):
|
||||||
|
|
||||||
|
startup_bot_event(bot, "SpiceBot_GifSearch")
|
||||||
|
|
||||||
bot.memory["SpiceBot_GifSearch"] = {"cache": {}, "badgiflinks": [], 'valid_gif_api_dict': {}}
|
bot.memory["SpiceBot_GifSearch"] = {"cache": {}, "badgiflinks": [], 'valid_gif_api_dict': {}}
|
||||||
|
|
||||||
dir_to_scan = []
|
dir_to_scan = []
|
||||||
@ -85,9 +87,7 @@ def setup_thread(bot):
|
|||||||
valid_gif_api_dict[gif_api]["apikey"] = None
|
valid_gif_api_dict[gif_api]["apikey"] = None
|
||||||
bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'][gif_api] = valid_gif_api_dict[gif_api]
|
bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'][gif_api] = valid_gif_api_dict[gif_api]
|
||||||
|
|
||||||
set_bot_event(bot, "SpiceBot_GifSearch")
|
while not check_bot_events(bot, ["SpiceBot_CommandsQuery"]):
|
||||||
|
|
||||||
while 'SpiceBot_CommandsQuery' not in bot.memory:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for prefix_command in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys():
|
for prefix_command in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys():
|
||||||
@ -95,6 +95,8 @@ def setup_thread(bot):
|
|||||||
|
|
||||||
stderr("[SpiceBot_CommandsQuery] Found " + str(len(bot.memory['SpiceBot_CommandsQuery']["prefix_command"].keys())) + " " + "prefix_command" + " commands.")
|
stderr("[SpiceBot_CommandsQuery] Found " + str(len(bot.memory['SpiceBot_CommandsQuery']["prefix_command"].keys())) + " " + "prefix_command" + " commands.")
|
||||||
|
|
||||||
|
set_bot_event(bot, "SpiceBot_GifSearch")
|
||||||
|
|
||||||
|
|
||||||
@sopel.module.commands('gif')
|
@sopel.module.commands('gif')
|
||||||
def gif_trigger(bot, trigger):
|
def gif_trigger(bot, trigger):
|
||||||
@ -114,25 +116,6 @@ def gif_trigger(bot, trigger):
|
|||||||
bot.osd(str(gifdict['gifapi'].title() + " Result (" + str(query) + " #" + str(gifdict["returnnum"]) + "): " + str(gifdict["returnurl"])))
|
bot.osd(str(gifdict['gifapi'].title() + " Result (" + str(query) + " #" + str(gifdict["returnnum"]) + "): " + str(gifdict["returnurl"])))
|
||||||
|
|
||||||
|
|
||||||
def sopel_triggerargs(bot, trigger, command_type='module_command'):
|
|
||||||
triggerargs = []
|
|
||||||
|
|
||||||
if len(trigger.args) > 1:
|
|
||||||
triggerargs = spicemanip.main(trigger.args[1], 'create')
|
|
||||||
triggerargs = spicemanip.main(triggerargs, 'create')
|
|
||||||
|
|
||||||
if command_type in ['module_command']:
|
|
||||||
triggerargs = spicemanip.main(triggerargs, '2+', 'list')
|
|
||||||
elif command_type in ['nickname_command']:
|
|
||||||
triggerargs = spicemanip.main(triggerargs, '3+', 'list')
|
|
||||||
elif command_type in ['prefix_command']:
|
|
||||||
prefixcommand = spicemanip.main(triggerargs, 1).lower()[1:]
|
|
||||||
triggerargs = spicemanip.main(triggerargs, '2+', 'list')
|
|
||||||
return triggerargs, prefixcommand
|
|
||||||
|
|
||||||
return triggerargs
|
|
||||||
|
|
||||||
|
|
||||||
def getGif(bot, searchdict):
|
def getGif(bot, searchdict):
|
||||||
|
|
||||||
# list of defaults
|
# list of defaults
|
||||||
|
|||||||
@ -30,6 +30,10 @@ def sopel_triggerargs(bot, trigger, command_type):
|
|||||||
triggerargs = spicemanip.main(triggerargs, '2+', 'list')
|
triggerargs = spicemanip.main(triggerargs, '2+', 'list')
|
||||||
elif command_type in ['nickname_command']:
|
elif command_type in ['nickname_command']:
|
||||||
triggerargs = spicemanip.main(triggerargs, '3+', 'list')
|
triggerargs = spicemanip.main(triggerargs, '3+', 'list')
|
||||||
|
elif command_type in ['prefix_command']:
|
||||||
|
prefixcommand = spicemanip.main(triggerargs, 1).lower()[1:]
|
||||||
|
triggerargs = spicemanip.main(triggerargs, '2+', 'list')
|
||||||
|
return triggerargs, prefixcommand
|
||||||
|
|
||||||
return triggerargs
|
return triggerargs
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user