diff --git a/sopel_modules/SpiceBot_Docs/Docs.py b/sopel_modules/SpiceBot_Docs/Docs.py new file mode 100644 index 0000000..16b7116 --- /dev/null +++ b/sopel_modules/SpiceBot_Docs/Docs.py @@ -0,0 +1,22 @@ +# coding=utf-8 + +from __future__ import unicode_literals, absolute_import, division, print_function + +import sopel.module + +import spicemanip + +from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, bot_privs, github_dict + + +def configure(config): + pass + + +def setup(bot): + pass + + +@sopel.module.nickname_commands('help', 'docs', 'wiki') +def bot_command_owners(bot, trigger): + bot.osd(["IRC Modules Repository", str(github_dict["url_main"] + github_dict["repo_owner"] + "/" + github_dict["repo_name"] + github_dict["url_path_wiki"])]) diff --git a/sopel_modules/SpiceBot_Docs/__init__.py b/sopel_modules/SpiceBot_Docs/__init__.py new file mode 100644 index 0000000..a9e845b --- /dev/null +++ b/sopel_modules/SpiceBot_Docs/__init__.py @@ -0,0 +1,8 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function + +from .Docs import * + +__author__ = 'Sam Zick' +__email__ = 'sam@deathbybandaid.net' +__version__ = '0.1.1' diff --git a/sopel_modules/SpiceBot_FriendlyBot/FriendlyBot.py b/sopel_modules/SpiceBot_FriendlyBot/FriendlyBot.py new file mode 100644 index 0000000..e14e5a2 --- /dev/null +++ b/sopel_modules/SpiceBot_FriendlyBot/FriendlyBot.py @@ -0,0 +1,23 @@ +# coding=utf-8 + +from __future__ import unicode_literals, absolute_import, division, print_function + +import sopel.module +from sopel.tools import stderr + +import spicemanip + + +def configure(config): + pass + + +def setup(bot): + pass + + +@sopel.module.rule(r'(?i)(hi|hello|hey),? $nickname[ \t]*$') +def bot_command_hello(bot, trigger): + hello = spicemanip.main(['Hi', 'Hey', 'Hello'], "random") + punctuation = spicemanip.main(['', '!', '?'], "random") + bot.osd(hello + ' ' + trigger.nick + punctuation) diff --git a/sopel_modules/SpiceBot_FriendlyBot/__init__.py b/sopel_modules/SpiceBot_FriendlyBot/__init__.py new file mode 100644 index 0000000..5f142f9 --- /dev/null +++ b/sopel_modules/SpiceBot_FriendlyBot/__init__.py @@ -0,0 +1,8 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function + +from .FriendlyBot import * + +__author__ = 'Sam Zick' +__email__ = 'sam@deathbybandaid.net' +__version__ = '0.1.1' diff --git a/sopel_modules/SpiceBot_Gender/Gender.py b/sopel_modules/SpiceBot_Gender/Gender.py new file mode 100644 index 0000000..5d5b5b1 --- /dev/null +++ b/sopel_modules/SpiceBot_Gender/Gender.py @@ -0,0 +1,21 @@ +# coding=utf-8 + +from __future__ import unicode_literals, absolute_import, division, print_function + +import sopel.module +from sopel.tools import stderr + +import spicemanip + + +def configure(config): + pass + + +def setup(bot): + pass + + +@sopel.module.nickname_commands('gender') +def bot_command_gender(bot, trigger): + bot.osd("If societal genders are binary, my gender is female") diff --git a/sopel_modules/SpiceBot_Gender/__init__.py b/sopel_modules/SpiceBot_Gender/__init__.py new file mode 100644 index 0000000..5bbadf2 --- /dev/null +++ b/sopel_modules/SpiceBot_Gender/__init__.py @@ -0,0 +1,8 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function + +from .Gender import * + +__author__ = 'Sam Zick' +__email__ = 'sam@deathbybandaid.net' +__version__ = '0.1.1' diff --git a/sopel_modules/SpiceBot_InsultHandler/InsultHandler.py b/sopel_modules/SpiceBot_InsultHandler/InsultHandler.py new file mode 100644 index 0000000..ae18b36 --- /dev/null +++ b/sopel_modules/SpiceBot_InsultHandler/InsultHandler.py @@ -0,0 +1,28 @@ +# coding=utf-8 + +from __future__ import unicode_literals, absolute_import, division, print_function + +import sopel.module +from sopel.tools import stderr + +import spicemanip + +from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, command_permissions_check, inlist, inlist_match + + +def configure(config): + pass + + +def setup(bot): + pass + + +@sopel.module.rule(r'(?i)(Fuck|Screw) (you|off),? $nickname[ \t]*$') +def bot_command_srewyou(bot, trigger): + bot.osd("Watch your mouth, " + trigger.nick + ", or I'll tell your mother!") + + +@sopel.module.rule(r'(?i)(Damnit|Lazy)? $nickname[ \t]*$') +def bot_command_damnlazy(bot, trigger): + bot.osd("I do not tell you how to do your job, " + trigger.nick + "!!!") diff --git a/sopel_modules/SpiceBot_InsultHandler/__init__.py b/sopel_modules/SpiceBot_InsultHandler/__init__.py new file mode 100644 index 0000000..6f1bdc3 --- /dev/null +++ b/sopel_modules/SpiceBot_InsultHandler/__init__.py @@ -0,0 +1,8 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function + +from .InsultHandler import * + +__author__ = 'Sam Zick' +__email__ = 'sam@deathbybandaid.net' +__version__ = '0.1.1' diff --git a/sopel_modules/SpiceBot_Logs/Logs.py b/sopel_modules/SpiceBot_Logs/Logs.py new file mode 100644 index 0000000..0e8d6be --- /dev/null +++ b/sopel_modules/SpiceBot_Logs/Logs.py @@ -0,0 +1,57 @@ +# coding=utf-8 + +from __future__ import unicode_literals, absolute_import, division, print_function + +import sopel.module +from sopel.tools import stderr + +import spicemanip + +from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, command_permissions_check, inlist, inlist_match + + +def configure(config): + pass + + +def setup(bot): + stderr("[SpiceBot_Logs] Starting Setup Procedure") + bot.memory['SpiceBot_Logs'] = {} + + +@sopel.module.nickname_commands('logs') +def bot_command_action(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') + + logtype = spicemanip.main(triggerargs, 1) or None + if not logtype or not inlist(bot, logtype, bot.memory['SpiceBot_Logs'].keys()): + bot.osd("Current valid log(s) include: " + spicemanip.main(bot.memory['SpiceBot_Logs'].keys(), 'andlist'), trigger.sender, 'action') + return + + logtype = inlist_match(bot, logtype, bot.memory['SpiceBot_Logs'].keys()) + + if len(bot.memory['SpiceBot_Logs'][logtype]) == 0: + bot.osd("No logs found for " + str(logtype) + ".") + return + + bot.osd("Is Examining " + str(logtype) + " log(s).") + for line in bot.memory['SpiceBot_Logs'][logtype]: + bot.osd(str(line), trigger.sender, 'action') + + +def bot_logging(bot, logtype, logentry): + + if 'SpiceBot_Logs' not in bot.memory: + bot.memory['SpiceBot_Logs'] = {} + + if logtype not in bot.memory['SpiceBot_Logs'].keys(): + bot.memory['SpiceBot_Logs'][logtype] = [] + + bot.memory['SpiceBot_Logs'][logtype].append(logentry) + if len(bot.memory['SpiceBot_Logs'][logtype]) > 10: + del bot.memory['SpiceBot_Logs'][logtype][0] diff --git a/sopel_modules/SpiceBot_Logs/__init__.py b/sopel_modules/SpiceBot_Logs/__init__.py new file mode 100644 index 0000000..f9d038a --- /dev/null +++ b/sopel_modules/SpiceBot_Logs/__init__.py @@ -0,0 +1,8 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function + +from .Logs import * + +__author__ = 'Sam Zick' +__email__ = 'sam@deathbybandaid.net' +__version__ = '0.1.1' diff --git a/sopel_modules/SpiceBot_SBTools/__init__.py b/sopel_modules/SpiceBot_SBTools/__init__.py index d67ef4f..4bbd84e 100644 --- a/sopel_modules/SpiceBot_SBTools/__init__.py +++ b/sopel_modules/SpiceBot_SBTools/__init__.py @@ -15,6 +15,18 @@ import codecs import spicemanip +"""Variable References""" + +github_dict = { + "url_main": "https://github.com/", + "url_api": "https://api.github.com/repos/", + "url_raw": "https://raw.githubusercontent.com/", + "url_path_wiki": "/wiki", + "url_path_issues": "/issues", + "repo_owner": "SpiceBot", + "repo_name": "SpiceBot", + } + """Sopel Wrapping Tools""" @@ -75,6 +87,42 @@ def command_permissions_check(bot, trigger, privslist): return True +""" +Time +""" + + +def humanized_time(countdownseconds): + time = float(countdownseconds) + if time == 0: + return "just now" + year = time // (365 * 24 * 3600) + time = time % (365 * 24 * 3600) + day = time // (24 * 3600) + time = time % (24 * 3600) + time = time % (24 * 3600) + hour = time // 3600 + time %= 3600 + minute = time // 60 + time %= 60 + second = time + displaymsg = None + timearray = ['year', 'day', 'hour', 'minute', 'second'] + for x in timearray: + currenttimevar = eval(x) + if currenttimevar >= 1: + timetype = x + if currenttimevar > 1: + timetype = str(x+"s") + if displaymsg: + displaymsg = str(displaymsg + " " + str(int(currenttimevar)) + " " + timetype) + else: + displaymsg = str(str(int(currenttimevar)) + " " + timetype) + if not displaymsg: + return "just now" + return displaymsg + + """List Manipulation Functions""" @@ -99,6 +147,26 @@ def inlist(bot, searchterm, searchlist): return False +def inlist_match(bot, searchterm, searchlist): + # verify we are searching a list + if isinstance(searchlist, collections.abc.KeysView) or isinstance(searchlist, dict): + searchlist = [x for x in searchlist] + if not isinstance(searchlist, list): + searchlist = [searchlist] + rebuildlist = [] + for searchitem in searchlist: + rebuildlist.append(str(searchitem)) + + searchterm = str(searchterm) + if searchterm in rebuildlist: + return searchterm + else: + for searching in rebuildlist: + if searching.lower() == searchterm.lower(): + return searching + return searchterm + + """Channel Functions""" diff --git a/sopel_modules/SpiceBot_Uptime/Uptime.py b/sopel_modules/SpiceBot_Uptime/Uptime.py new file mode 100644 index 0000000..282eb71 --- /dev/null +++ b/sopel_modules/SpiceBot_Uptime/Uptime.py @@ -0,0 +1,26 @@ +# coding=utf-8 + +from __future__ import unicode_literals, absolute_import, division, print_function + +import sopel.module +from sopel.tools import stderr + +import spicemanip + +import time + +from sopel_modules.SpiceBot_SBTools import humanized_time + + +def configure(config): + pass + + +def setup(bot): + bot.memory["SpiceBot_Uptime"] = time.time() + + +@sopel.module.nickname_commands('uptime') +def bot_command_srewyou(bot, trigger): + timesince = str(humanized_time(time.time() - bot.memory["SpiceBot_Uptime"])) + " ago." + bot.osd("I have been running since " + timesince) diff --git a/sopel_modules/SpiceBot_Uptime/__init__.py b/sopel_modules/SpiceBot_Uptime/__init__.py new file mode 100644 index 0000000..d0079c0 --- /dev/null +++ b/sopel_modules/SpiceBot_Uptime/__init__.py @@ -0,0 +1,8 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function + +from .Uptime import * + +__author__ = 'Sam Zick' +__email__ = 'sam@deathbybandaid.net' +__version__ = '0.1.1'