예제 #1
0
파일: bot.py 프로젝트: olgabots/plugins
 def add_handler_by_type(types: str, handler_method):
     if types in plugin_import.returns:
         function = plugin_import.returns.get(types).get('func')
         filters = plugin_import.returns.get(types).get('filters')
         performer = plugin_import.returns.get(types).get('performer')
         print('{} -> {}.{}'.format(plugin, performer, types))
         if performer == 'api':
             app = api
         elif performer == 'cli':
             app = cli
         else:
             if types == 'msg':
                 app = api or cli
             elif types == 'callback':
                 app = api
             else:
                 app = cli
         if types == 'update':
             handler = handler_method(function)
         else:
             handler = handler_method(function, filters)
         try:
             app.add_handler(handler, groups.get(types))
             groups[types] += 1
         except:
             pass
예제 #2
0
파일: bot.py 프로젝트: olgabots/plugins
def create_config():
    print('\t>> Creating Config...', 'cyan')
    config = ConfigParser(interpolation=ExtendedInterpolation())
    config.add_section('Plugins')
    for i in plugins_dir_list():
        config['Plugins'][i] = 'enabled'
    with open(path.join(rp, 'data', 'config.ini'), 'w') as file:
        config.write(file)
예제 #3
0
파일: bot.py 프로젝트: olgabots/plugins
def start(**kwargs: Client):
    if ('api' not in kwargs) and ('cli' not in kwargs):
        print('App Is Not Set', 'red')
        return
    if 'api' in kwargs:
        app = kwargs['api']
        if app.is_started:
            app.stop()
        app.start()
    if 'cli' in kwargs:
        app = kwargs['cli']
        if app.is_started:
            app.stop()
        app.start()
예제 #4
0
파일: bot.py 프로젝트: olgabots/plugins
def check_config():
    print('\nChecking Config...', 'green')
    config = ConfigParser(interpolation=ExtendedInterpolation())
    if not path.exists(path.join(rp, 'data', 'config.ini')):
        create_config()
    update_config_plugins()
    config.read(path.join(rp, 'data', 'config.ini'))
    if 'Plugins' not in config.sections():
        print('#! ["Plugins"] not in config sections. !#', 'red')
    print('Done!', 'magenta')
예제 #5
0
# response and status
response = conn.getresponse()
# .getresponse() method that returns the reSponse information from the server

#Print the status line -- OK
tc.cprint(f"Response received!: {response.status} {response.reason}\n", 'blue')

data = response.read().decode(
    "utf-8")  # It is necessary to decode the information
# read JSON
info_api = json.loads(
    data)  # loads(). is a method from JSON library  (read JSON response)

# Obtain information . We use 'seq' and 'desc' as keys
sequence = info_api['seq']
description = info_api['desc']

# PRINTING info
tc.cprint("Gene: ", 'green', end="")
print(gene)

tc.cprint("Description: ", 'green', end="")
print(description)

tc.cprint("Total length: ", 'green',
          end="")  #stored function in seq_information
print(len(seq_info))

tc.print("Most frequent Base: ", 'green', end="")
print(most_frecuent_base)