mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
add dummy command
This commit is contained in:
parent
92ef8c107e
commit
fe60378a68
@ -12,6 +12,9 @@ from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, googlesearch, bot_
|
||||
@sopel.module.nickname_commands('(.*)')
|
||||
def bot_command_gender(bot, trigger):
|
||||
|
||||
while not bot_events_check(bot, ['1004', '2002']):
|
||||
pass
|
||||
|
||||
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command')
|
||||
|
||||
if not triggercommand:
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
"""Useful miscellaneous tools and shortcuts for SpiceBot Sopel modules
|
||||
"""
|
||||
@ -318,6 +319,46 @@ def channel_list_current(bot):
|
||||
"""Environment Functions"""
|
||||
|
||||
|
||||
def stock_modules_begone(bot):
|
||||
|
||||
# Remove stock modules, if present
|
||||
main_sopel_dir = os.path.dirname(os.path.abspath(sopel.__file__))
|
||||
modules_dir = os.path.join(main_sopel_dir, 'modules')
|
||||
stockdir = os.path.join(modules_dir, "stock")
|
||||
if not os.path.exists(stockdir) or not os.path.isdir(stockdir):
|
||||
os.system("sudo mkdir " + stockdir)
|
||||
if "SpiceBot_dummycommand.py" not in os.listdir(modules_dir):
|
||||
import sopel_modules
|
||||
for plugin_dir in set(sopel_modules.__path__):
|
||||
for pathname in os.listdir(plugin_dir):
|
||||
if pathname == 'SpiceBot_SopelPatches':
|
||||
pypi_modules_dir = os.path.join(plugin_dir, pathname)
|
||||
if "SpiceBot_dummycommand.py" in os.listdir(pypi_modules_dir):
|
||||
if "SpiceBot_dummycommand.py" not in os.listdir(modules_dir):
|
||||
os.system("sudo cp " + os.path.join(pypi_modules_dir, "SpiceBot_dummycommand.py") + " " + modules_dir)
|
||||
for pathname in os.listdir(modules_dir):
|
||||
path = os.path.join(modules_dir, pathname)
|
||||
if (os.path.isfile(path) and pathname.endswith('.py') and not pathname.startswith('_')):
|
||||
if not pathname in ["__init__.py", "SpiceBot_dummycommand.py"]:
|
||||
os.system("sudo mv " + path + " " + stockdir)
|
||||
|
||||
|
||||
def spicebot_update(bot, deps=False):
|
||||
|
||||
pipcommand = "sudo pip3 install --upgrade"
|
||||
if not deps:
|
||||
pipcommand += " --no-deps"
|
||||
pipcommand += " --force-reinstall"
|
||||
pipcommand += " git+" + str(bot.config.SpiceBot_Update.gitrepo) + "@" + str(bot.config.SpiceBot_Update.gitbranch)
|
||||
|
||||
bot_logging(bot, 'SpiceBot_Update', "Running `" + pipcommand + "`")
|
||||
# for line in os.popen(pipcommand).read().split('\n'):
|
||||
# bot_logging(bot, 'SpiceBot_Update', " " + line)
|
||||
os.system(pipcommand)
|
||||
|
||||
stock_modules_begone(bot)
|
||||
|
||||
|
||||
def spicebot_reload(bot, log_from='service_manip', quitmessage='Recieved QUIT'):
|
||||
# service_manip(bot, bot.nick, 'restart', log_from)
|
||||
bot.restart(quitmessage)
|
||||
|
||||
@ -3,12 +3,19 @@
|
||||
from __future__ import unicode_literals, absolute_import, print_function, division
|
||||
|
||||
# sopel imports
|
||||
import sopel
|
||||
import sopel.module
|
||||
|
||||
from sopel_modules.SpiceBot_SBTools import bot_logging
|
||||
from sopel_modules.SpiceBot_SBTools import bot_logging, stock_modules_begone
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def setup(bot):
|
||||
|
||||
bot_logging(bot, 'Sopel_Patch', "Patching Sopels built-in url_callbacks")
|
||||
if 'url_callbacks' not in bot.memory:
|
||||
bot.memory['url_callbacks'] = sopel.tools.SopelMemory()
|
||||
|
||||
bot_logging(bot, 'Sopel_Patch', "Removing Stock Modules and verifying Dummy Command is present.")
|
||||
stock_modules_begone(bot)
|
||||
|
||||
11
sopel_modules/SpiceBot_SopelPatches/SpiceBot_dummycommand.py
Normal file
11
sopel_modules/SpiceBot_SopelPatches/SpiceBot_dummycommand.py
Normal file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
"""dummycommand"""
|
||||
from __future__ import unicode_literals, absolute_import, print_function, division
|
||||
|
||||
import sopel.module
|
||||
|
||||
|
||||
@sopel.module.commands("?zz_dummycommand")
|
||||
def dummycommand(bot, trigger):
|
||||
return
|
||||
@ -6,11 +6,9 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
|
||||
import sopel.module
|
||||
from sopel.config.types import StaticSection, ValidatedAttribute
|
||||
|
||||
import os
|
||||
|
||||
import spicemanip
|
||||
|
||||
from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, command_permissions_check, bot_logging, spicebot_reload
|
||||
from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, command_permissions_check, bot_logging, spicebot_reload, spicebot_update
|
||||
|
||||
|
||||
class SpiceBot_Update_MainSection(StaticSection):
|
||||
@ -60,33 +58,3 @@ def nickname_comand_update(bot, trigger):
|
||||
|
||||
# service_manip(bot, bot.nick, 'restart', 'SpiceBot_Update')
|
||||
spicebot_reload(bot, 'SpiceBot_Update', quitmessage)
|
||||
|
||||
|
||||
def spicebot_update(bot, deps=False):
|
||||
|
||||
pipcommand = "sudo pip3 install --upgrade"
|
||||
if not deps:
|
||||
pipcommand += " --no-deps"
|
||||
pipcommand += " --force-reinstall"
|
||||
pipcommand += " git+" + str(bot.config.SpiceBot_Update.gitrepo) + "@" + str(bot.config.SpiceBot_Update.gitbranch)
|
||||
|
||||
bot_logging(bot, 'SpiceBot_Update', "Running `" + pipcommand + "`")
|
||||
# for line in os.popen(pipcommand).read().split('\n'):
|
||||
# bot_logging(bot, 'SpiceBot_Update', " " + line)
|
||||
os.system(pipcommand)
|
||||
|
||||
stock_modules_begone(bot)
|
||||
|
||||
|
||||
def stock_modules_begone(bot):
|
||||
|
||||
# Remove stock modules, if present
|
||||
main_sopel_dir = os.path.dirname(os.path.abspath(sopel.__file__))
|
||||
modules_dir = os.path.join(main_sopel_dir, 'modules')
|
||||
stockdir = os.path.join(modules_dir, "stock")
|
||||
if not os.path.exists(stockdir) or not os.path.isdir(stockdir):
|
||||
os.system("sudo mkdir " + stockdir)
|
||||
for pathname in os.listdir(modules_dir):
|
||||
path = os.path.join(modules_dir, pathname)
|
||||
if (os.path.isfile(path) and pathname.endswith('.py') and not pathname.startswith('_')):
|
||||
os.system("sudo mv " + path + " " + stockdir)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user