mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 15:09:54 -05:00
commit
50c539469b
@ -5,3 +5,4 @@ fake-useragent
|
|||||||
google-api-python-client
|
google-api-python-client
|
||||||
num2words
|
num2words
|
||||||
word2number
|
word2number
|
||||||
|
upsidedown
|
||||||
|
|||||||
2
setup.py
2
setup.py
@ -25,7 +25,7 @@ with open('dev-requirements.txt') as dev_requirements_file:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='sopel_modules.SpiceBot',
|
name='sopel_modules.SpiceBot',
|
||||||
version='0.1.1',
|
version='0.3.0',
|
||||||
description='SpiceBot aims to run SpiceBot as an IRC service',
|
description='SpiceBot aims to run SpiceBot as an IRC service',
|
||||||
long_description=readme + '\n\n' + history,
|
long_description=readme + '\n\n' + history,
|
||||||
author='Sam Zick',
|
author='Sam Zick',
|
||||||
|
|||||||
@ -291,6 +291,10 @@ class BotCommands():
|
|||||||
line = str(line).split("commands")[-1]
|
line = str(line).split("commands")[-1]
|
||||||
line = "commands" + line
|
line = "commands" + line
|
||||||
detected_lines.append(line)
|
detected_lines.append(line)
|
||||||
|
elif str(line).startswith(tuple(["action_commands", "module.action_commands", "sopel.module.action_commands"])):
|
||||||
|
line = str(line).split("action_commands")[-1]
|
||||||
|
line = "action_commands" + line
|
||||||
|
detected_lines.append(line)
|
||||||
elif str(line).startswith(tuple(["nickname_commands", "module.nickname_commands", "sopel.module.nickname_commands"])):
|
elif str(line).startswith(tuple(["nickname_commands", "module.nickname_commands", "sopel.module.nickname_commands"])):
|
||||||
line = str(line).split("nickname_commands")[-1]
|
line = str(line).split("nickname_commands")[-1]
|
||||||
line = "nickname_commands" + line
|
line = "nickname_commands" + line
|
||||||
@ -326,6 +330,13 @@ class BotCommands():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
validcoms = e
|
validcoms = e
|
||||||
validcoms = []
|
validcoms = []
|
||||||
|
elif str(detected_line).startswith("action_commands"):
|
||||||
|
comtype = "action"
|
||||||
|
try:
|
||||||
|
validcoms = eval(str(detected_line).split("action_commands")[-1])
|
||||||
|
except Exception as e:
|
||||||
|
validcoms = e
|
||||||
|
validcoms = []
|
||||||
elif str(detected_line).startswith("nickname_commands"):
|
elif str(detected_line).startswith("nickname_commands"):
|
||||||
comtype = "nickname"
|
comtype = "nickname"
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -4,6 +4,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
|
|||||||
This is the SpiceBot Update system.
|
This is the SpiceBot Update system.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
from sopel.config.types import StaticSection, ValidatedAttribute
|
from sopel.config.types import StaticSection, ValidatedAttribute
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
71
sopel_modules/SpiceBot/Version.py
Normal file
71
sopel_modules/SpiceBot/Version.py
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# coding=utf8
|
||||||
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
"""
|
||||||
|
This is the SpiceBot Update system.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sopel
|
||||||
|
|
||||||
|
import requests
|
||||||
|
import feedparser
|
||||||
|
import pkg_resources
|
||||||
|
from fake_useragent import UserAgent
|
||||||
|
import urllib
|
||||||
|
|
||||||
|
from .Config import config as botconfig
|
||||||
|
|
||||||
|
|
||||||
|
class BotVersion():
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.header = {'User-Agent': str(UserAgent().chrome)}
|
||||||
|
self.sopel = {
|
||||||
|
"version_local": sopel.version_info,
|
||||||
|
"version_local_num": sopel.__version__,
|
||||||
|
"version_url": 'https://sopel.chat/latest.json',
|
||||||
|
"version_online": None,
|
||||||
|
"version_online_num": None,
|
||||||
|
}
|
||||||
|
self.spicebot = {
|
||||||
|
"version_local_num": pkg_resources.get_distribution("sopel-modules.SpiceBot").version,
|
||||||
|
"version_url": "https://api.github.com/repos/SpiceBot/SpiceBot/commits/master",
|
||||||
|
"version_online_num": None,
|
||||||
|
}
|
||||||
|
|
||||||
|
self.check_sopel()
|
||||||
|
self.check_spicebot()
|
||||||
|
|
||||||
|
def check_sopel(self):
|
||||||
|
info = requests.get(self.sopel["version_url"], verify=botconfig.core.verify_ssl).json()
|
||||||
|
if self.sopel["version_local"].releaselevel == 'final':
|
||||||
|
self.sopel["version_online_num"] = info['version']
|
||||||
|
self.sopel["notes"] = info['release_notes']
|
||||||
|
else:
|
||||||
|
self.sopel["version_online_num"] = info['unstable']
|
||||||
|
self.sopel["notes"] = info.get('unstable_notes', '')
|
||||||
|
if self.sopel["notes"]:
|
||||||
|
self.sopel["notes"] = 'Full release notes at ' + self.sopel["notes"]
|
||||||
|
|
||||||
|
self.sopel["version_online"] = sopel._version_info(self.sopel["version_online_num"])
|
||||||
|
|
||||||
|
def check_spicebot(self):
|
||||||
|
|
||||||
|
htmlfile = urllib.request.urlopen("https://raw.githubusercontent.com/SpiceBot/SpiceBot/master/setup.py")
|
||||||
|
lines = htmlfile.read().splitlines()
|
||||||
|
self.spicebot["version_online_num"] = self.spicebot["version_local_num"]
|
||||||
|
for line in lines:
|
||||||
|
line = str(line)
|
||||||
|
if "version=" in line:
|
||||||
|
line = line.replace("\" ", '')
|
||||||
|
line = line.replace(",\"", '')
|
||||||
|
line = line.replace("version=", '')
|
||||||
|
line = line.replace("'", '')
|
||||||
|
line = line.replace("b", '')
|
||||||
|
self.spicebot["version_online_num"] = line
|
||||||
|
continue
|
||||||
|
|
||||||
|
feedjson = feedparser.parse("https://github.com/SpiceBot/SpiceBot/commits/master.atom")
|
||||||
|
self.spicebot["version_online_num"] = str(self.spicebot["version_online_num"]) + "." + str(len(feedjson.entries))
|
||||||
|
|
||||||
|
|
||||||
|
version = BotVersion()
|
||||||
@ -7,6 +7,11 @@ This module contains references only for other modules to utilize.
|
|||||||
"""
|
"""
|
||||||
# pylama:ignore=W0401,W0611
|
# pylama:ignore=W0401,W0611
|
||||||
|
|
||||||
|
|
||||||
|
from .configure import *
|
||||||
|
from .setup import *
|
||||||
|
from .shutdown import *
|
||||||
|
|
||||||
from .Config import *
|
from .Config import *
|
||||||
from .Logs import *
|
from .Logs import *
|
||||||
from .Database import *
|
from .Database import *
|
||||||
@ -32,12 +37,9 @@ from .Reddit import *
|
|||||||
from .DictComs import *
|
from .DictComs import *
|
||||||
from .Read import *
|
from .Read import *
|
||||||
from .Translate import *
|
from .Translate import *
|
||||||
|
from .Version import *
|
||||||
|
|
||||||
|
|
||||||
from .configure import *
|
|
||||||
from .setup import *
|
|
||||||
from .shutdown import *
|
|
||||||
|
|
||||||
__author__ = 'Sam Zick'
|
__author__ = 'Sam Zick'
|
||||||
__email__ = 'sam@deathbybandaid.net'
|
__email__ = 'sam@deathbybandaid.net'
|
||||||
__version__ = '0.1.1'
|
__version__ = '0.3.0'
|
||||||
|
|||||||
@ -103,6 +103,7 @@ def setup_startupmonologue(bot):
|
|||||||
botevents.BOT_STARTUPMONOLOGUE_CHANNELS,
|
botevents.BOT_STARTUPMONOLOGUE_CHANNELS,
|
||||||
botevents.BOT_STARTUPMONOLOGUE_COMMANDS,
|
botevents.BOT_STARTUPMONOLOGUE_COMMANDS,
|
||||||
botevents.BOT_STARTUPMONOLOGUE_AI,
|
botevents.BOT_STARTUPMONOLOGUE_AI,
|
||||||
|
botevents.BOT_STARTUPMONOLOGUE_VERSION,
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
25
sopel_modules/SpiceBot_Core_Commands/Version.py
Normal file
25
sopel_modules/SpiceBot_Core_Commands/Version.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# coding=utf8
|
||||||
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
"""
|
||||||
|
This is the SpiceBot Users system.
|
||||||
|
"""
|
||||||
|
import sopel
|
||||||
|
|
||||||
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
|
|
||||||
|
@SpiceBot.prerun('nickname')
|
||||||
|
@sopel.module.nickname_commands('version')
|
||||||
|
def nickname_comand_version(bot, trigger, botcom):
|
||||||
|
fulldisp = []
|
||||||
|
|
||||||
|
# sopel
|
||||||
|
displayval = "I am running Sopel " + str(SpiceBot.version.sopel["version_local_num"])
|
||||||
|
if SpiceBot.version.sopel["version_local"] < SpiceBot.version.sopel["version_online"]:
|
||||||
|
displayval += " Update Available to " + SpiceBot.version.sopel["version_online_num"]
|
||||||
|
fulldisp.append(displayval)
|
||||||
|
|
||||||
|
# SpiceBot
|
||||||
|
fulldisp.append("I am running SpiceBot " + str(SpiceBot.version.spicebot["version_local_num"]))
|
||||||
|
|
||||||
|
bot.osd(fulldisp)
|
||||||
@ -22,7 +22,8 @@ from .BotPrivs import *
|
|||||||
from .AI import *
|
from .AI import *
|
||||||
from .DictComs import *
|
from .DictComs import *
|
||||||
from .TODO import *
|
from .TODO import *
|
||||||
|
from .Version import *
|
||||||
|
|
||||||
__author__ = 'Sam Zick'
|
__author__ = 'Sam Zick'
|
||||||
__email__ = 'sam@deathbybandaid.net'
|
__email__ = 'sam@deathbybandaid.net'
|
||||||
__version__ = '0.1.1'
|
__version__ = '0.3.0'
|
||||||
|
|||||||
@ -6,4 +6,4 @@ from .flip import *
|
|||||||
|
|
||||||
__author__ = 'Sam Zick'
|
__author__ = 'Sam Zick'
|
||||||
__email__ = 'sam@deathbybandaid.net'
|
__email__ = 'sam@deathbybandaid.net'
|
||||||
__version__ = '0.1.1'
|
__version__ = '0.3.0'
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import sopel.module
|
|||||||
|
|
||||||
from upsidedown import transform
|
from upsidedown import transform
|
||||||
# TODO add upsidedown to spicemanip
|
# TODO add upsidedown to spicemanip
|
||||||
|
# TODO add prerun functionality as well as command handling
|
||||||
|
|
||||||
|
|
||||||
@sopel.module.rule('^flips (.+)')
|
@sopel.module.rule('^flips (.+)')
|
||||||
|
|||||||
@ -19,6 +19,14 @@ def bot_startup_monologue_start(bot, trigger):
|
|||||||
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue")
|
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue")
|
||||||
|
|
||||||
|
|
||||||
|
@sopel.module.event(SpiceBot.events.BOT_CONNECTED)
|
||||||
|
@sopel.module.rule('.*')
|
||||||
|
def bot_startup_monologue_sopel_version(bot, trigger):
|
||||||
|
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_VERSION, "SpiceBot_StartupMonologue")
|
||||||
|
SpiceBot.startupmonologue.dict["sopel_version"] = "Sopel " + str(SpiceBot.version.sopel["version_local_num"])
|
||||||
|
SpiceBot.startupmonologue.dict["spicebot_version"] = "SpiceBot " + str(SpiceBot.version.spicebot["version_local_num"])
|
||||||
|
|
||||||
|
|
||||||
@sopel.module.event(SpiceBot.events.BOT_CHANNELS)
|
@sopel.module.event(SpiceBot.events.BOT_CHANNELS)
|
||||||
@sopel.module.rule('.*')
|
@sopel.module.rule('.*')
|
||||||
def bot_startup_monologue_channels(bot, trigger):
|
def bot_startup_monologue_channels(bot, trigger):
|
||||||
|
|||||||
27
sopel_modules/SpiceBot_Core_Processing/Updates_Available.py
Normal file
27
sopel_modules/SpiceBot_Core_Processing/Updates_Available.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# coding=utf8
|
||||||
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
|
||||||
|
import sopel
|
||||||
|
|
||||||
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
|
wait_time = 24 * 60 * 60 # check once per day
|
||||||
|
|
||||||
|
message = (
|
||||||
|
'A new Sopel version, {}, is available. I am running {}. Please update '
|
||||||
|
'me. Full release notes at {}'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@sopel.module.interval(wait_time)
|
||||||
|
def check_updates_sopel_interval(bot):
|
||||||
|
SpiceBot.version.check_sopel()
|
||||||
|
|
||||||
|
msg = message.format(
|
||||||
|
SpiceBot.version.sopel["version_online_num"],
|
||||||
|
SpiceBot.version.sopel["version_local_num"],
|
||||||
|
SpiceBot.version.sopel["notes"]
|
||||||
|
)
|
||||||
|
|
||||||
|
if SpiceBot.version.sopel["version_local"] < SpiceBot.version.sopel["version_online"]:
|
||||||
|
bot.osd(msg, bot.config.core.owner)
|
||||||
@ -17,9 +17,10 @@ from .osd import *
|
|||||||
from .StartupMonologue import *
|
from .StartupMonologue import *
|
||||||
from .Logs import *
|
from .Logs import *
|
||||||
from .Kick import *
|
from .Kick import *
|
||||||
|
from .Updates_Available import *
|
||||||
# from .Watch_URL import *
|
# from .Watch_URL import *
|
||||||
|
|
||||||
|
|
||||||
__author__ = 'Sam Zick'
|
__author__ = 'Sam Zick'
|
||||||
__email__ = 'sam@deathbybandaid.net'
|
__email__ = 'sam@deathbybandaid.net'
|
||||||
__version__ = '0.1.1'
|
__version__ = '0.3.0'
|
||||||
|
|||||||
@ -9,4 +9,4 @@ from .Search import *
|
|||||||
|
|
||||||
__author__ = 'Sam Zick'
|
__author__ = 'Sam Zick'
|
||||||
__email__ = 'sam@deathbybandaid.net'
|
__email__ = 'sam@deathbybandaid.net'
|
||||||
__version__ = '0.1.1'
|
__version__ = '0.3.0'
|
||||||
|
|||||||
@ -6,4 +6,4 @@ from .Patches import *
|
|||||||
|
|
||||||
__author__ = 'Sam Zick'
|
__author__ = 'Sam Zick'
|
||||||
__email__ = 'sam@deathbybandaid.net'
|
__email__ = 'sam@deathbybandaid.net'
|
||||||
__version__ = '0.1.1'
|
__version__ = '0.3.0'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user