From 4fafc5484d0729ec630cdd74dc5853084ffef322 Mon Sep 17 00:00:00 2001 From: decoded Date: Sun, 26 Mar 2023 15:08:10 -0500 Subject: [PATCH] update3 --- plugins/tool_colors_plugin.py | 149 ---------------------- storage/bot/plugins/net_discord_plugin.py | 6 +- storage/bot/plugins/tool_colors_plugin.py | 7 +- 3 files changed, 9 insertions(+), 153 deletions(-) delete mode 100644 plugins/tool_colors_plugin.py diff --git a/plugins/tool_colors_plugin.py b/plugins/tool_colors_plugin.py deleted file mode 100644 index 70ffbab..0000000 --- a/plugins/tool_colors_plugin.py +++ /dev/null @@ -1,149 +0,0 @@ -# -*- coding: utf-8 -*- ############################################################### SOF -########################################################################################### -from irc3.plugins.command import command -import irc3 -import sys -import inspect - -########################################################################################### -########################################################################################### - -@irc3.plugin -class Plugin: - - ####################################################################################### - ####################################################################################### - - def __init__(self, bot): - from tool_colors_plugin import colorform as print - from tool_colors_plugin import COLORFORM as INFO - self.bot = bot - self.bot.info=INFO(self) - -########################################################################################### -########################################################################################### - -def rgb(r=0,g=0,b=0):return f"\033[38;2;{r};{g};{b}m" - -########################################################################################### -########################################################################################### - -def rgbe():return f"\033[38;2;255;255;255m" - -########################################################################################### -########################################################################################### - -def rgbt(t='',r=0,g=0,b=0):return f"\033[38;2;{r};{g};{b}m{t}\033[38;2;255;255;255m" - -########################################################################################### -########################################################################################### - -def colorform(data): - - frame = inspect.currentframe().f_back - try: - codeobj = frame.f_code - try: - self_name = codeobj.co_varnames[0] - except IndexError: - self_name = None - caller = None - raise Exception() - try: - self_obj = frame.f_locals[self_name] - except KeyError: - caller = None - raise Exception() - self_type = type(self_obj) - func_name = codeobj.co_name - for cls in self_type.__mro__: - try: - method = vars(cls)[func_name] - except KeyError: - continue - try: - method = inspect.unwrap(method) - except ValueError: - pass - if getattr(method, '__code__', None) is codeobj: - caller = self_type.__name__ - raise Exception() - caller = None - raise Exception() - except: - pass - finally: - del frame - - ################################################################################### - ################################################################################### - - self = None - - ################################################################################### - ################################################################################### - - - the_caller_path_to_file=sys._getframe().f_code.co_filename - the_caller=the_caller_path_to_file.split('/')[-1].split('.')[0] - the_call=sys._getframe(1).f_code.co_name - the_function=sys._getframe().f_code.co_name - the_origin=codeobj.co_filename.split('/')[-1].replace('.py','') - the_origin="_"*(19-len(the_origin))+the_origin - try: - msg=f'{rgb(b=255)}<<<{rgb(g=255,b=255)} {the_origin} {rgb(b=255)}>>> ' - except: - msg='break' - - if self and data and caller: - the_class="" - the_class=type(self).__name__ - if codeobj.co_filename==the_caller_path_to_file: - msg+=f'{rgb(r=255)}[ {rgb(r=255,b=255)}{caller}.{the_class}.{the_call} {rgb(r=255)}]' - else: - origin=codeobj.co_filename.split('/')[-1].replace('.py','') - msg+=f'{rgb(r=255)}[ {rgb(r=255,b=255)}{the_call}.{caller} {rgb(r=255)}]' - msg+=f'{rgb(b=255)} - ' - msg+=f'{rgb(g=128,b=128,r=128)}{data}' - else: - try: - caller=str(self).split(f'<{__name__}.')[1].split()[0] - except: - caller="" - if not self_name and the_call=="": - if codeobj.co_filename==the_caller_path_to_file: - msg+=f'{rgb(r=255)}[ {rgb(r=255,b=255)}{__name__}.{caller}.{the_function} {rgb(r=255)}]' - else: - origin=codeobj.co_filename.split('/')[-1].replace('.py','') - msg+=f'{rgb(r=255)}[ {rgb(r=255,b=255)}{origin} {rgb(r=255)}]' - else: - if codeobj.co_filename==the_caller_path_to_file: - msg+=f'{rgb(r=255)}[ {rgb(r=255,b=255)}{the_call} {rgb(r=255)}]' - else: - caller=codeobj.co_filename.split('/')[-1].replace('.py','') - try: - the_origin=str(self_type).split("'")[1] - except: - pass - msg+=f'{rgb(r=255)}[ {rgb(r=255,b=255)}{the_origin}.{the_call} {rgb(r=255)}]'.replace(f'plugins.{caller}.Plugin.','').replace(f'plugins.{caller}.','').replace(f'{caller}.','').replace('Plugin.','') - msg+=f'{rgb(b=255)} - ' - msg+=f'{rgb(g=128,b=128,r=128)}{data}' - print(msg) - -########################################################################################### -########################################################################################### - -class COLORFORM: - def __init__(self,c): - c.bot.log.info=self.info - def info(self,s=None,cfg=None): - try: - s = s % cfg - except: - s = "" - msg=f'[ {s} ]' - globals()['colorform'](msg) - -########################################################################################### -####################################################################################### EOF - diff --git a/storage/bot/plugins/net_discord_plugin.py b/storage/bot/plugins/net_discord_plugin.py index 817d1f9..09d6313 100644 --- a/storage/bot/plugins/net_discord_plugin.py +++ b/storage/bot/plugins/net_discord_plugin.py @@ -34,7 +34,7 @@ if SERVICES_DISCORD: ####################################################################################### ####################################################################################### - + from irc3.plugins.command import command ####################################################################################### @@ -102,7 +102,7 @@ if SERVICES_DISCORD: #################### if SERVICES_DISCORD: #################### - + intents=discord.Intents.default() intents.members = True intents.messages = True @@ -110,6 +110,8 @@ if SERVICES_DISCORD: intents.message_content = True client=discord.Client(intents=intents) def __init__(self): + discord.gateway._log=print + discord.client._log=print self.ircbot=guds.memory('ircbot') self.dbname="discordchat" self.db=self.ircbot.db.getlist(self.dbname) diff --git a/storage/bot/plugins/tool_colors_plugin.py b/storage/bot/plugins/tool_colors_plugin.py index aded924..1329f6d 100644 --- a/storage/bot/plugins/tool_colors_plugin.py +++ b/storage/bot/plugins/tool_colors_plugin.py @@ -122,8 +122,11 @@ def colorform(data): msg+=f'{rgb(r=255)}[ {rgb(r=255,b=255)}{the_call} {rgb(r=255)}]' else: caller=codeobj.co_filename.split('/')[-1].replace('.py','') - the_origin=str(self_type).split("'")[1] - msg+=f'{rgb(r=255)}[ {rgb(r=255,b=255)}{the_origin}.{the_call} {rgb(r=255)}]'.replace(f'plugins.{caller}.Plugin.','').replace(f'plugins.{caller}.','') + try: + the_origin=str(self_type).split("'")[1] + except: + pass + msg+=f'{rgb(r=255)}[ {rgb(r=255,b=255)}{the_origin}.{the_call} {rgb(r=255)}]'.replace(f'plugins.{caller}.Plugin.','').replace(f'plugins.{caller}.','').replace(f'{caller}.','').replace('Plugin.','') msg+=f'{rgb(b=255)} - ' msg+=f'{rgb(g=128,b=128,r=128)}{data}' print(msg)