예제 #1
0
    def __init__(self):
        lang = core.obtconfig('lang')
        if lang is None:
            core.addconfig('package_translate', 'db/userbot.json')
        else:
            global lang

        locale = i18n.turn('es',
                 core.obtconfig('package_translate', cache=True),
                 i18n.parsename(__name__))
        _ = locale.turn_tr_str

        def sn(string):
            string = unicode(string)
            raw = raw_input('%s %s ?>' % (string.decode('utf-8'), _('s/N', lang)))
            return raw.lower() in ['s', 'y']
        i = lambda x: raw_input(x + ' ?> ')

        global locale
        global _
        global sn
        global i

        if lang is None:
            self.lang()
            self.clear()

        vrn = core.obtconfig('VERSION', cache=True)
        vrn = (vrn[0] + ' ' + '.'.join(str(num) for num in vrn[1:]))

        print _('Bienvenido al sistema de configuracion de ', lang) + vrn
        print _('ingrese "help" o "license" para mas informacion', lang)

        while True:
            try:
                name = i('')
                if name is '':
                    continue

                for func in make_handlers:
                    if func.__name__ == name:
                        func(self)
                        raise GeneratorExit
                raise AttributeError
            except AttributeError:
                print _('orden "%s" desconocida', lang) % name
            except (KeyboardInterrupt, OSError, EOFError, GeneratorExit):
                pass
            except SystemExit:
                exit()
            except:
                for line in traceback.format_exc().splitlines():
                    print line
예제 #2
0
"""
UserBot module
Copyright 2015, Ismael R. Lugo G.
"""

import re, os, imp, logg, types, Thread, traceback, i18n

from config import core
from config import conf
from irc.client import buffer_input
from irc.request import whois
from irc.connection import servers

log = logg.getLogger(__name__)
locale = i18n.turn(
    'es',
    core.obtconfig('package_translate', cache=True),
    'commands')
_ = locale.turn_tr_str


class commands(object):

    def __init__(self):
        self.modules = {}
        self.endless_process()
        self.lang = core.obtconfig('lang', cache=True)

    def __getitem__(self, key):
        try:
            return self.modules[key]
        except KeyError: