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 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 add(self, irc, rpl_ev, func_name, args, kwargs, exec_l, seconds, name=None): if irc in base and not irc in self.jobs: self.jobs[irc] = [] self.jobs[irc].append({ 'rpl': rpl_ev if not rpl_ev else None, 'func_name': getattr(base[irc][0], func_name).func_name, 'args': args, 'kwargs': kwargs, 'exec_n': 0, 'exec_l': exec_l, 'seconds': time.time() + seconds if seconds >= 0 else seconds, 'name': name}) core.upconfig(self.db_name, self.jobs)
def delserver(self): ircbase = core.obtconfig('ircbase') if not ircbase: print _('no hay servidores agregados', lang) return print _('ingrese el nombre del servidor a eliminar.', lang) print _('servidores: ', lang) + ', '.join(sv.name for sv in ircbase) while True: name = i(':::') for server in ircbase: if name == server.name: del ircbase[ircbase.index(server)] core.upconfig('ircbase', ircbase) return print _('el servidor no existe, vuelva a intentarlo', lang)
def deloper(self): opers = core.obtconfig('opers') if not opers: return for oper in opers: print '=' * 80 print _('usuario', lang) + ': ' + oper['user'] print _('nivel', lang) + ': ' + oper['level'][0] try: print _('servidores: ', lang) + oper['level'][1] except IndexError: pass if sn(_('es este el operador a eliminar?', lang)): opers.remove(oper) core.upconfig('opers', opers) print '=' * 80
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 process(self, irc, jobls, epoch): try: if not irc.registered: time.sleep(4) except AttributeError: time.sleep(4) for job in jobls: remove = False if epoch >= job['seconds']: if job['exec_n'] >= job['exec_l']: remove = True else: job['exec_n'] += 1 getattr(irc, job['func_name'])(*job['args'], **job['kwargs']) else: continue if remove: jobls.remove(job) core.upconfig(self.db_name, self.jobs)
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)
def save(self): core.upconfig(self.name + '_' + self.irc.base.name, self.__core__)