def info(irc, result, group, other): rpl = whois(irc, group('nick')) account = result('account') lc = other['global_lang'] if rpl['is logged']: if base[irc.base.name][1][rpl['is logged']]: lc = base[irc.base.name][1][rpl['is logged']]['lang'] else: print None if not account: account = rpl['is logged'] if not account: account = group('nick') user = base[irc.base.name][1][account] t = other['target'] if not user: irc.err(t, _('usuario no registrado', lc) + ': ' + account) return irc.notice(t, _('nombre de usuario: ', lc) + user['name']) irc.notice(t, _('fecha de registro: ', lc) + user['time']) irc.notice(t, _('idioma de usuario: ', lc) + i18n.LC_ALL[user['lang']]) irc.notice(t, _('nivel del usuario: ', lc) + user['status']) irc.notice(t, _('cuenta bloqueada: ', lc) + str(user['lock'][0])) if user['lock'][0]: irc.notice(t, _('razon de bloqueo: ', lc) + user['lock'][1])
def ban(irc, result, group, other): lang = base[irc.base.name][1][other['rpl_whois']['is logged']]['lang'] time = result('time') target = result('target') channel = other['channel'] # Mensaje de expulsion! message = result('message') p = True if not message: message = '' p = False if not message.endswith('.') and p: message = message + '.' if not message.endswith(' ') and p: message = message + ' ' message = message + _('expulsado por', lang) + ' ' + group('nick') banned = False if util.val_mask(target): # Esto se activa sí... es una mascara banned = True irc.mode(channel, '+b ' + target) for nick in util.make_nick_ls(irc, channel, target)[0]: irc.kick(channel, nick, message) elif irc.features.network == 'freenode' and util.val_extban(target): # Esto se activa sí... # La red es freenode y el ban es extendido banned = True irc.mode(channel, '+b ' + target) else: # Esto se activa sí... es un nick, o no coincide con nada rpl_whois = whois(irc, target) if rpl_whois['error']: irc.err(channel, rpl_whois['error']) return else: target = '*!*@' + rpl_whois['mask']['host'] banned = True irc.mode(channel, '+b ' + target) for nick in util.make_nick_ls(irc, channel, target)[0]: irc.kick(channel, nick, message) if time and banned: try: time = center.mode.conv_parse_txt(time) center.mode.add(irc.base.name, channel, '-b ' + target) except ValueError: irc.err(other['target'], _('tiempo invalido', lang)) return
def security(self, handler, irc, nick, channel=None, target=None): if handler['anyuser']: return True if handler['logged']: rpl_whois = whois(irc, nick) lang = self.lang if not rpl_whois['is logged']: irc.err(nick, _('debe loguearse via nickserv', lang)) return if handler['registered']: user = servers[irc.base.name][1][rpl_whois['is logged']] if not user: irc.err(nick, _('no se encuentra registrado, registrese', lang)) return lang = user['lang'] if user['lock'][0]: irc.err(nick, _('su cuenta esta bloqueada, razon: "%s"', lang) % user['lock'][1]) return if handler['oper']: if not user['status'] in handler['oper']: irc.err(nick, _('comando solo para operadores: ', lang) + ', '.join(handler['oper'])) return if handler['channels']: if not channel or not channel[0] in '#': irc.err(nick, _('debe ingresar un canal valido', lang)) return if handler['chn_registered']: if not servers[irc.base.name][2][channel]: irc.err(nick, _('canal "%s" no registrado, registrelo.', lang) % channel) return if handler['privs']: if not servers[irc.base.name][2].privs(channel, rpl_whois['is logged'].lower(), handler['privs']): irc.err(nick, _('permiso denegado, requiere +%s', lang) % handler['privs']) return return rpl_whois
def ip2(irc, result, group, other): rpl = whois(irc, group("nick")) lc = other["global_lang"] user = None target = other["target"] if rpl["is logged"] and base[irc.base.name][1][rpl["is logged"]]: user = base[irc.base.name][1][rpl["is logged"]] if user: lc = user["lang"] host = result("hostname") try: page = urllib.urlopen("http://freegeoip.net/json/" + host) data = json.loads(page.read()) except: irc.err(target, _("Soy una tetera!", lc)) else: response = "[IP/Host Lookup] " if re_ip.findall(host): ## IP Address try: hostname = socket.gethostbyaddr(data)[0] except: hostname = _("Host desconocido", lc) response += "Hostname: " + str(hostname) else: ## Host name response += "IP: " + data["ip"] spacing = " |" for key in data: if not data[key]: data[key] = "N/A" form = "%s \2{}\2: {}" % spacing if "city" in data: response += form.format(_("Ciudad", lc), data["city"]) if "region_name" in data: response += form.format(_("Región", lc), data["region_name"]) if "country_name" in data: response += form.format(_("País", lc), data["country_name"]) if "zipcode" in data: response += form.format("ZIP", data["zipcode"]) response += form.format(_("Latitud", lc), data["latitude"]) response += form.format(_("Longitud", lc), data["longitude"]) irc.notice(target, response)
def ip(irc, result, group, other): rpl = whois(irc, group("nick")) lc = other["global_lang"] user = None target = other["target"] if rpl["is logged"] and base[irc.base.name][1][rpl["is logged"]]: user = base[irc.base.name][1][rpl["is logged"]] if user: lc = user["lang"] host = result("hostname") text = urllib.quote(host) try: http = httplib.HTTPConnection("ip-api.com") http.request("GET", "/json/{0}?fields=65535".format(text)) data = json.loads(http.getresponse().read().decode("utf-8")) if data["status"] != "success": raise ValueError except: irc.err(target, _("Soy una tetera!", lc)) else: form = "\2{}\2: {}, " resp = "IP \2{}\2 ".format(host) if data["reverse"] != "": resp += "- {} ".format(data["reverse"]) if data["country"] != "": resp += form.format(_("País", lc), data["country"]) if data["region"] != "": resp += form.format(_("Región", lc), data["region"]) if data["city"] != "": resp += form.format(_("Ciudad", lc), data["city"]) if data["isp"] != "": resp += form.format("ISP", data["isp"]) if data["org"] != "": resp += form.format(_("Organización", lc), data["org"]) if data["as"] != "": resp += form.format("ASN", data["as"]) if data["timezone"] != "": resp += form.format(_("Zona horaria", lc), data["org"]) resp += "\2\2: {0}, ".format(data["timezone"]) irc.notice(target, resp[: len(resp) - 2])
def translate2_2(irc, result, group, other): input, output, text = result('in', 'out', 'text') rpl = whois(irc, group('nick')) lc = other['global_lang'] user = None target = other['target'] if rpl['is logged'] and base[irc.base.name][1][rpl['is logged']]: user = base[irc.base.name][1][rpl['is logged']] if user: lc = user['lang'] if not output in langcodes: irc.err(target, _('codigo de lenguaje invalido: %s', lc) % output) return elif not input in langcodes: irc.err(target, _('codigo de lenguaje invalido: %s', lc) % input) return irc.notice(target, '(%s -> %s): %s' % (input, output, translate(input, output, text, 2)))
def help(irc, result, group, other): rpl = whois(irc, group('nick')) lc = other['global_lang'] user = None command = result('command') target = other['target'] if rpl['is logged'] and base[irc.base.name][1][rpl['is logged']]: user = base[irc.base.name][1][rpl['is logged']] if user: lc = user['lang'] vrn = core.obtconfig('VERSION', cache=True) vrn = (vrn[0] + ' ' + '.'.join(str(num) for num in vrn[1:])) irc.notice(target, vrn + ' - ' + _('codigo fuente: ', lc) + 'https://goo.gl/vVSG8i') if command: res = search(command.lower().split()) if len(res) == 1: res = res[0] if len(res) == 0: pass else: mod = res['module'] else: mod = res[1] res = res[0] if res: irc.notice(target, _('ayuda para: ', lc) + command) if isinstance(res['desc'], tuple) or isinstance(res['desc'], list): irc.notice(target, _('descripcion: ', lc)) for line in res['desc']: irc.notice(target, ' ' + _(line, lc, mod=mod, err=False)) else: irc.notice(target, _('descripcion: ', lc) + _(res['desc'], lc, mod=mod, err=False)) if 'alias' in res: irc.notice(target, 'alias: ' + ', '.join(res['alias'])) irc.notice(target, _('sintaxis: ', lc) + res['sintax']) irc.notice(target, _('ejemplo: ', lc) + res['example']) irc.notice(target, _('?: parametro opcional, |: opciones varias', lc)) else: irc.notice(target, _('el comando no existe', lc)) else: post = {} first = [] for dic in cmls.items(): if 'sub' in dic[1]: if not dic[0] in post: post[dic[0]] = [] for sub in dic[1]['sub']: post[dic[0]].append(sub) else: first.append(dic[0]) irc.notice(target, _('prefijo %s, comandos disponibles: ', lc) % other['global_prefix']) msg = textwrap.wrap(', '.join(first), 400) for o in msg: irc.notice(target, o) for pr, sub in post.items(): if pr == 'admin': if user and user['status'] in ('noob', 'local', 'global'): for o in textwrap.wrap(', '.join(sub), 400): irc.notice(target, '%s: %s' % (pr, o)) else: irc.notice(target, 'admin: id') else: for o in textwrap.wrap(', '.join(sub), 400): irc.notice(target, '%s: %s' % (pr, o)) irc.notice(target, _('envie: help <comando> <subcomando>?', lc)) irc.notice(target, _('?: parametro opcional, |: opciones varias', lc))