From 399d23d6ccfa72bf3930dcded5933d4061ff6520 Mon Sep 17 00:00:00 2001 From: decoded Date: Mon, 20 Mar 2023 10:59:06 -0500 Subject: [PATCH] update --- storage/bot/databases/maple_db.sqlite | 0 storage/bot/plugins/auth_nickserv_plugin.py | 66 ++++++++++ storage/bot/plugins/auth_plugin.py | 57 --------- storage/bot/plugins/auth_sasl_plugin.py | 117 ++++++++++++++++++ storage/bot/plugins/sasl_custom_plugin.py | 108 ---------------- storage/bot/plugins/tool_colors_plugin.py | 5 +- storage/bot/status/status_id | 1 + .../core/bot_maple__core__initial_plugins.txt | 3 +- .../bot_maple__default__initial_plugins.txt | 3 +- .../bot_maple__devops__initial_plugins.txt | 5 +- .../bot_maple__services__initial_plugins.txt | 3 +- 11 files changed, 197 insertions(+), 171 deletions(-) create mode 100644 storage/bot/databases/maple_db.sqlite create mode 100644 storage/bot/plugins/auth_nickserv_plugin.py delete mode 100644 storage/bot/plugins/auth_plugin.py create mode 100644 storage/bot/plugins/auth_sasl_plugin.py delete mode 100644 storage/bot/plugins/sasl_custom_plugin.py create mode 100644 storage/bot/status/status_id diff --git a/storage/bot/databases/maple_db.sqlite b/storage/bot/databases/maple_db.sqlite new file mode 100644 index 0000000..e69de29 diff --git a/storage/bot/plugins/auth_nickserv_plugin.py b/storage/bot/plugins/auth_nickserv_plugin.py new file mode 100644 index 0000000..3149478 --- /dev/null +++ b/storage/bot/plugins/auth_nickserv_plugin.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- ############################################################### SOF +########################################################################################### + +???AUTHNICKSERV??? + +########################################################################################### +########################################################################################### + +######################### +if SERVICES_AUTHNICKSERV: +######################### + + from irc3.plugins.cron import cron + import irc3, os, sys + from plugins.tool_colors_plugin import colorform as print + + ################################################################################### + ################################################################################### + + def getenv(s): + try: + s = os.environ[s] + return s + except: + error_type="environmental variable error" + error_reason=f"exported {s} not found" + print(f"{error_type}: {error_reason}") + sys.exit(1) + + ########################################################################### + ########################################################################### + + NICKSERV_USERNAME=getenv('NICKSERV_USERNAME') + NICKSERV_PASSWORD=getenv('NICKSERV_PASSWORD') + + ########################################################################### + ########################################################################### + + @irc3.plugin + class Plugin: + + ########################################################################### + ########################################################################### + + def __init__(self,bot): + self.bot=bot + + ########################################################################### + ########################################################################### + + @irc3.event(irc3.rfc.CONNECTED) + def connected(self, **kw): + MSG=f"identify {NICKSERV_USERNAME} {NICKSERV_PASSWORD}" + self.bot.privmsg('NICKSERV',MSG) + + ################################################################################### + ################################################################################### + + @cron('*/1 * * * *') + def cron_auth(bot): + if not bot.nick==bot.original_nick: + MSG=f"identify {NICKSERV_USERNAME} {NICKSERV_PASSWORD}" + bot.privmsg('NICKSERV',MSG) + +########################################################################################### +####################################################################################### EOF diff --git a/storage/bot/plugins/auth_plugin.py b/storage/bot/plugins/auth_plugin.py deleted file mode 100644 index cbc830d..0000000 --- a/storage/bot/plugins/auth_plugin.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- ############################################################### SOF -########################################################################################### - -from irc3.plugins.cron import cron -import irc3, os, sys -from plugins.tool_colors_plugin import colorform as print - -########################################################################################### -########################################################################################### - -def getenv(s): - try: - s = os.environ[s] - return s - except: - error_type="environmental variable error" - error_reason=f"exported {s} not found" - print(f"{error_type}: {error_reason}") - sys.exit(1) - -########################################################################################### -########################################################################################### - -NICKSERV_USERNAME=getenv('NICKSERV_USERNAME') -NICKSERV_PASSWORD=getenv('NICKSERV_PASSWORD') - -########################################################################################### -########################################################################################### - -@irc3.plugin -class Plugin: - - ####################################################################################### - ####################################################################################### - - def __init__(self,bot): - self.bot=bot - - ####################################################################################### - ####################################################################################### - - @irc3.event(irc3.rfc.CONNECTED) - def connected(self, **kw): - MSG=f"identify {NICKSERV_USERNAME} {NICKSERV_PASSWORD}" - self.bot.privmsg('NICKSERV',MSG) - -########################################################################################### -########################################################################################### - -@cron('*/1 * * * *') -def cron_auth(bot): - if not bot.nick==bot.original_nick: - MSG=f"identify {NICKSERV_USERNAME} {NICKSERV_PASSWORD}" - bot.privmsg('NICKSERV',MSG) - -########################################################################################### -####################################################################################### EOF diff --git a/storage/bot/plugins/auth_sasl_plugin.py b/storage/bot/plugins/auth_sasl_plugin.py new file mode 100644 index 0000000..64ba772 --- /dev/null +++ b/storage/bot/plugins/auth_sasl_plugin.py @@ -0,0 +1,117 @@ +# -*- coding: utf-8 -*- ############################################################### SOF +########################################################################################### + +???AUTHSASL??? + +########################################################################################### +########################################################################################### + +##################### +if SERVICES_AUTHSASL: +##################### + + import irc3,os,sys,base64 + from plugins.tool_colors_plugin import colorform as print + + ####################################################################################### + ####################################################################################### + + def getenv(s): + try: + s = os.environ[s] + return s + except: + error_type="environmental variable error" + error_reason=f"exported {s} not found" + print(f"{error_type}: {error_reason}") + sys.exit(1) + + ####################################################################################### + ####################################################################################### + + BOT_SASL_USERNAME=getenv('BOT_SASL_USERNAME') + BOT_SASL_PASSWORD=getenv('BOT_SASL_PASSWORD') + + ####################################################################################### + ####################################################################################### + + @irc3.plugin + class DR1PSASL: + + ################################################################################### + ################################################################################### + + def __init__(self, bot): + print('<<< _sasl_custom_plugin >>> [ custom sasl initiated ]') + self.bot=bot + self.auth=(f'{BOT_SASL_USERNAME}\0{BOT_SASL_USERNAME}\0{BOT_SASL_PASSWORD}') + self.auth=base64.encodebytes(self.auth.encode('utf8')) + self.auth=self.auth.decode('utf8').rstrip('\n') + self.events = [ + irc3.event(r'^:\S+ CAP \S+ LS :(?P.*)', self.cap_ls), + irc3.event(r'^:\S+ CAP \S+ ACK sasl', self.cap_ack), + irc3.event(r'AUTHENTICATE +', self.authenticate), + irc3.event(r'^:\S+ 903 \S+ :Authentication successful',self.cap_end), + ] + + ################################################################################### + ################################################################################### + + @classmethod + def reload(cls, old): + return cls(old.bot) + + ################################################################################### + ################################################################################### + + def before_reload(self): + pass + + ################################################################################### + ################################################################################### + + def after_reload(self): + pass + + ################################################################################### + ################################################################################### + + def connection_ready(self, *args, **kwargs): + print('<<< _sasl_custom_plugin >>> [ CAP LS ]') + self.bot.send('CAP LS\r\n') + self.bot.attach_events(*self.events) + + ################################################################################### + ################################################################################### + + def cap_ls(self, data=None, **kwargs): + print('<<< _sasl_custom_plugin >>> [ CAP REQ :sasl ]') + if 'sasl' in data.lower(): + self.bot.send_line('CAP REQ :sasl') + else: + self.cap_end() + + ################################################################################### + ################################################################################### + + def cap_ack(self, **kwargs): + print('<<< _sasl_custom_plugin >>> [ AUTHENTICATE PLAIN ]') + self.bot.send_line('AUTHENTICATE PLAIN') + + ################################################################################### + ################################################################################### + + def authenticate(self, **kwargs): + print(f'<<< _sasl_custom_plugin >>> [ AUTHENTICATE ]') + self.bot.send_line(f'AUTHENTICATE {self.auth}\n') + + ################################################################################### + ################################################################################### + + def cap_end(self, **kwargs): + print('<<< _sasl_custom_plugin >>> [ CAP END ]') + self.bot.send_line('CAP END\r\n') + self.bot.detach_events(*self.events) + +########################################################################################### +####################################################################################### EOF diff --git a/storage/bot/plugins/sasl_custom_plugin.py b/storage/bot/plugins/sasl_custom_plugin.py deleted file mode 100644 index d863b23..0000000 --- a/storage/bot/plugins/sasl_custom_plugin.py +++ /dev/null @@ -1,108 +0,0 @@ -# -*- coding: utf-8 -*- ############################################################### SOF -########################################################################################### - -import irc3,os,sys,base64 -from plugins.tool_colors_plugin import colorform as print - -########################################################################################### -########################################################################################### - -def getenv(s): - try: - s = os.environ[s] - return s - except: - error_type="environmental variable error" - error_reason=f"exported {s} not found" - print(f"{error_type}: {error_reason}") - sys.exit(1) - -########################################################################################### -########################################################################################### - -BOT_SASL_USERNAME=getenv('BOT_SASL_USERNAME') -BOT_SASL_PASSWORD=getenv('BOT_SASL_PASSWORD') - -########################################################################################### -########################################################################################### - -@irc3.plugin -class DR1PSASL: - - ####################################################################################### - ####################################################################################### - - def __init__(self, bot): - print('<<< _sasl_custom_plugin >>> [ custom sasl initiated ]') - self.bot=bot - self.auth=(f'{BOT_SASL_USERNAME}\0{BOT_SASL_USERNAME}\0{BOT_SASL_PASSWORD}') - self.auth=base64.encodebytes(self.auth.encode('utf8')) - self.auth=self.auth.decode('utf8').rstrip('\n') - self.events = [ - irc3.event(r'^:\S+ CAP \S+ LS :(?P.*)', self.cap_ls), - irc3.event(r'^:\S+ CAP \S+ ACK sasl', self.cap_ack), - irc3.event(r'AUTHENTICATE +', self.authenticate), - irc3.event(r'^:\S+ 903 \S+ :Authentication successful',self.cap_end), - ] - - ####################################################################################### - ####################################################################################### - - @classmethod - def reload(cls, old): - return cls(old.bot) - - ####################################################################################### - ####################################################################################### - - def before_reload(self): - pass - - ####################################################################################### - ####################################################################################### - - def after_reload(self): - pass - - ####################################################################################### - ####################################################################################### - - def connection_ready(self, *args, **kwargs): - print('<<< _sasl_custom_plugin >>> [ CAP LS ]') - self.bot.send('CAP LS\r\n') - self.bot.attach_events(*self.events) - - ####################################################################################### - ####################################################################################### - - def cap_ls(self, data=None, **kwargs): - print('<<< _sasl_custom_plugin >>> [ CAP REQ :sasl ]') - if 'sasl' in data.lower(): - self.bot.send_line('CAP REQ :sasl') - else: - self.cap_end() - - ####################################################################################### - ####################################################################################### - - def cap_ack(self, **kwargs): - print('<<< _sasl_custom_plugin >>> [ AUTHENTICATE PLAIN ]') - self.bot.send_line('AUTHENTICATE PLAIN') - - ####################################################################################### - ####################################################################################### - - def authenticate(self, **kwargs): - print(f'<<< _sasl_custom_plugin >>> [ AUTHENTICATE ]') - self.bot.send_line(f'AUTHENTICATE {self.auth}\n') - - ####################################################################################### - ####################################################################################### - - def cap_end(self, **kwargs): - print('<<< _sasl_custom_plugin >>> [ CAP END ]') - self.bot.send_line('CAP END\r\n') - self.bot.detach_events(*self.events) - -########################################################################################### -####################################################################################### EOF diff --git a/storage/bot/plugins/tool_colors_plugin.py b/storage/bot/plugins/tool_colors_plugin.py index 7a5de74..bb3b265 100644 --- a/storage/bot/plugins/tool_colors_plugin.py +++ b/storage/bot/plugins/tool_colors_plugin.py @@ -84,7 +84,10 @@ def colorform(data): msg+=f'{rgb(b=255)} - ' msg+=f'{rgb(g=128,b=128,r=128)}{data}' else: - caller=str(self).split(f'<{__name__}.')[1].split()[0] + try: + caller=str(self).split(f'<{__name__}.')[1].split()[0] + except: + caller=str(self).split(f'<{__name__}.')[0] if not self_name and the_caller=="": if codeobj.co_filename==PATHFILENAME: msg+=f'{rgb(r=255)}[ {rgb(r=255,b=255)}{__name__}.{caller}.{the_function} {rgb(r=255)}]' diff --git a/storage/bot/status/status_id b/storage/bot/status/status_id new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/storage/bot/status/status_id @@ -0,0 +1 @@ +default diff --git a/storage/bot/variants/core/bot_maple__core__initial_plugins.txt b/storage/bot/variants/core/bot_maple__core__initial_plugins.txt index 4a968b2..bcb20b5 100644 --- a/storage/bot/variants/core/bot_maple__core__initial_plugins.txt +++ b/storage/bot/variants/core/bot_maple__core__initial_plugins.txt @@ -3,7 +3,8 @@ irc3.plugins.command plugins.storage_plugin plugins.fifo_plugin - plugins.sasl_custom_plugin + plugins.auth_sasl_plugin + plugins.auth_nickserv_plugin plugins.net_hydra_plugin plugins.tool_colors_plugin plugins.tool_log_plugin diff --git a/storage/bot/variants/default/bot_maple__default__initial_plugins.txt b/storage/bot/variants/default/bot_maple__default__initial_plugins.txt index fc07047..cd1c754 100644 --- a/storage/bot/variants/default/bot_maple__default__initial_plugins.txt +++ b/storage/bot/variants/default/bot_maple__default__initial_plugins.txt @@ -9,7 +9,8 @@ plugins.tool_dims_plugin plugins.tool_guds_plugin plugins.tool_bus_plugin - plugins.sasl_custom_plugin + plugins.auth_sasl_plugin + plugins.auth_nickserv_plugin plugins.net_irc_plugin plugins.net_matrix_plugin plugins.net_discord_plugin diff --git a/storage/bot/variants/dupe/bot_maple__devops__initial_plugins.txt b/storage/bot/variants/dupe/bot_maple__devops__initial_plugins.txt index 4978953..ae83e73 100644 --- a/storage/bot/variants/dupe/bot_maple__devops__initial_plugins.txt +++ b/storage/bot/variants/dupe/bot_maple__devops__initial_plugins.txt @@ -9,7 +9,8 @@ plugins.tool_dims_plugin plugins.tool_guds_plugin plugins.tool_bus_plugin - plugins.sasl_custom_plugin + plugins.auth_sasl_plugin + plugins.auth_nickserv_plugin plugins.net_hydra_plugin plugins.net_irc_plugin plugins.cmd_irc_plugin @@ -48,4 +49,4 @@ # plugins.whoami_plugin # plugins.joke_plugin # plugins.maple_plugin - # plugins.openai_plugin \ No newline at end of file + # plugins.openai_plugin diff --git a/storage/bot/variants/dupe/bot_maple__services__initial_plugins.txt b/storage/bot/variants/dupe/bot_maple__services__initial_plugins.txt index 2390bfd..44d1587 100644 --- a/storage/bot/variants/dupe/bot_maple__services__initial_plugins.txt +++ b/storage/bot/variants/dupe/bot_maple__services__initial_plugins.txt @@ -9,7 +9,8 @@ plugins.tool_dims_plugin plugins.tool_guds_plugin plugins.tool_bus_plugin - plugins.sasl_custom_plugin + plugins.auth_sasl_plugin + plugins.auth_nickserv_plugin plugins.net_hydra_plugin plugins.net_irc_plugin plugins.net_matrix_plugin