def __init__(self, db_name): self.db_name = db_name self.jobs = core.obtconfig(self.db_name) if not self.jobs: self.jobs = {} core.addconfig(db_name, self.jobs) self.start = False
def mps(self): if not core.obtconfig('mps'): core.addconfig('mps', 0.4) r = float(i(_('mensajes por segundos', lang))) if r > 0: core.upconfig('mps', r)
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
def prefix(self): prefix = core.obtconfig('prefix') if prefix: print _('el prefijo actual es: ', lang) + prefix r = i(_('prefijo', lang))[0] if r.isalpha(): print _('prefijo invalido el caracter no debe ser alfabetico', lang) else: if not prefix: core.addconfig('prefix', r) else: core.upconfig('prefix', r)
def __init__(self, ircobject, name, extra=None): self.irc = ircobject self.name = name self.lang = core.obtconfig('lang', cache=True) self.__core__ = core.obtconfig(name + '_' + self.irc.base.name) if not self.__core__: self.__core__ = {} core.addconfig(name + '_' + self.irc.base.name, self.__core__) if isinstance(extra, dict): for name, item in extra.items(): setattr(self, name, item)
def addserver(self): name = i(_('nombre de la red', lang)) host = i(_('direccion del servidor', lang)) port = int(i(_('numero de puerto', lang))) ssl = sn(_('usar ssl?', lang)) if sn(_('usar contrasena?', lang)): passwd = (True, i(_('contraseña del servidor', lang))) else: passwd = (False,) nick = i(_('nombre para userbot', lang)) user = i(_('nombre de usuario', lang)) if sn(_('usar sasl?', lang)): sasl = (True, (i(_('nombre de la cuenta', lang)), i(_('contraseña', lang)))) else: sasl = (False,) connect_to_beginning = sn(_('conectar al inicio?', lang)) ircbase = core.obtconfig('ircbase') if not ircbase: core.addconfig('ircbase', []) ircbase = [] for base in ircbase: if base.name.lower() is name.lower(): print ((_('el nombre "%s" ya esta en uso,', lang) % name) + _('por favor utilice otro nombre', lang)) return kwargs = vars() del kwargs['self'] del kwargs['ircbase'] try: del kwargs['base'] except KeyError: pass ircbase.append(IRCBase(**kwargs)) core.upconfig('ircbase', ircbase)
def addoper(self): opers = core.obtconfig('opers') if not opers: core.addconfig('opers', []) opers = [] user = i(_('usuario', lang)) print _('NOTA: La contraseña debe ser ingresada bajo sha256', lang) passwd = i(_('contraseña', lang)) print _('niveles disponibles: ', lang) + 'global local noob' level = i(_('nivel', lang)) if level is 'global': level = (level,) elif level in ('local', 'noob'): print _('ingrese el nombre del servidor para el operador', lang) ircbase = core.obtconfig('ircbase') if not ircbase: print _('no hay servidores agregados', lang) return name = i('') for server in ircbase: if name == server.name: level = (level, server.name) break if not isinstance(level, tuple): print _('el servidor no existe', lang) return kwargs = vars() del kwargs['self'] del kwargs['opers'] try: del kwargs['ircbase'] del kwargs['name'] del kwargs['server'] except KeyError: pass opers.append(kwargs) core.upconfig('opers', opers)
def lang(self): print _('Por favor ingrese su codigo de lenguaje:', 'en') num = 1 print '+' + ('=' * 78) + '+' for langcode in locale._tr_aval(): print '|%-78s|' % (' [ %s ] %s: %s' % (num, langcode, i18n.LC_ALL[langcode].decode('utf-8'))) num += 1 print '+' + ('=' * 78) + '+' while True: lang = i('langcode').lower() if not lang in locale._tr_aval(): print _('codigo de lenguaje invalido.', 'en') continue else: if core.obtconfig('lang'): core.upconfig('lang', lang) else: core.addconfig('lang', lang) print _('idioma actualizado', lang) global lang break
def plaintext(self): if not isinstance(core.obtconfig('plaintext'), bool): core.addconfig('plaintext', False) if sn(_('guardar texto plano?', lang)): core.upconfig('plaintext', True)