def check_plugins(): # Check the plugins res = 0 for p in utils.clean_plugins(utils.get_all_plugins()): try: m = importlib.import_module('plugins.{}'.format(p)) if not hasattr(m, '__info__'): print_error("Don't have __info__", p) res = 1 if type(m.__info__) is not dict: print_error("__info__ is not a dictionary.", p) res = 1 info = m.__info__ haverun = hasattr(info.get("run"), '__call__') havecron = hasattr(info.get("cron"), '__call__') haveprec = hasattr(info.get("pre_process"), '__call__') if not (haverun or havecron or haveprec): print_error( "Every plugin need a run, cron or pre_process function, and this does't have any of that.", p) res = 1 except Exception as e: print('\033[31mError loading plugin {}\033[39m'.format(p)) print('\033[31m{}\033[39m'.format(e)) res = 1 return res
def list_plugins(only_enabled=False, receiver='', in_chat=False): text = "" allp = settings.ALL_PLUGINS if hasattr( settings, 'ALL_PLUGINS') else utils.clean_plugins( utils.get_all_plugins()) for plug in allp: status = utils.emojis.get('nope') if plug in settings.ENABLED_PLUGINS: status = utils.emojis.get('ok') if utils.is_plugin_disabled_on_chat(plug, receiver): status = '{} (in chat)'.format(utils.emojis.get('nope')) if not only_enabled or status == utils.emojis.get('ok'): text += "{} {}\n".format(plug, status) elif in_chat: text += "{} {}\n".format(plug, status) return text
def check_plugins(): # Check the plugins res = 0 for p in utils.clean_plugins(utils.get_all_plugins()): try: m = importlib.import_module('plugins.{}'.format(p)) if not hasattr(m, '__info__'): print_error("Don't have __info__", p) res = 1 if type(m.__info__) is not dict: print_error("__info__ is not a dictionary.", p) res = 1 info = m.__info__ haverun = hasattr(info.get("run"), '__call__') havecron = hasattr(info.get("cron"), '__call__') haveprec = hasattr(info.get("pre_process"), '__call__') if not (haverun or havecron or haveprec): print_error("Every plugin need a run, cron or pre_process function, and this does't have any of that.", p) res = 1 except Exception as e: print('\033[31mError loading plugin {}\033[39m'.format(p)) print('\033[31m{}\033[39m'.format(e)) res = 1 return res
activate_this_file = "./env/bin/activate_this.py" if not os.path.isfile(activate_this_file): print("You need to install the virtualenv") safe_exit(1) if not hasattr(sys, 'real_prefix'): print("You are not inside the virtualenv.") print("Do 'source env/bin/activate' before executing this") safe_exit(1) import tgl from gl import utils from gl import settings plugins = utils.clean_plugins(utils.get_all_plugins()) text = "| Name | Description | Usage |\n| ---- | ----------- | ----- |\n" base = "| {} | {} | {} |\n" utils.import_plugins(plugins, plugins) for p in sorted(plugins): realname = "{}.py".format(p) if not settings.PLUGINS.get(p): continue plug = settings.PLUGINS.get(p) desc, usage = get_values(plug) text += base.format(realname, desc, usage) with open("README.md", "r") as f: readmetext = f.read()
def list_plugins(only_enabled=False, receiver="", in_chat=False): text = "" allp = settings.ALL_PLUGINS if hasattr(settings, "ALL_PLUGINS") else utils.clean_plugins(utils.get_all_plugins()) for plug in allp: status = utils.emojis.get("nope") if plug in settings.ENABLED_PLUGINS: status = utils.emojis.get("ok") if utils.is_plugin_disabled_on_chat(plug, receiver): status = "{} (in chat)".format(utils.emojis.get("nope")) if not only_enabled or status == utils.emojis.get("ok"): text += "{} {}\n".format(plug, status) elif in_chat: text += "{} {}\n".format(plug, status) return text