Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # coding:utf8
- import xchat
- __module_name__ = "clones"
- __module_version__ = "1.0"
- __module_description__ = "Muestra antiguos nicks y muestra clones, permite expulsarlos"
- xchat.emit_print("Channel Message", "\x02\x033"+__module_name__+"\x0f", "cargado.")
- users = {}
- MaxClones = 2
- KickReason = "Demasiados clones"
- def Update_cb(userdata=None):
- global users
- try:
- for chan in xchat.get_list("channels"):
- c = chan.channel.lower()
- if not c.startswith("#"):
- continue
- if not c in users:
- users[c] = {}
- if not "on" in users[c]:
- users[c]["on"] = []
- context = xchat.find_context(channel=c)
- if context:
- for user in context.get_list("users"):
- host = user.host.split("@")[1].lower()
- nick = user.nick.lower()
- if host in users[c]:
- if not nick in users[c][host]:
- users[c][host].append(nick)
- else:
- users[c][host] = [nick]
- if not nick in users[c]["on"]:
- users[c]["on"].append(nick)
- except:
- pass
- return 1
- Update_cb()
- def Clones_cb(word, word_eol, userdata):
- chan = xchat.get_info("channel").lower()
- clones = []
- if not chan in users:
- return xchat.EAT_XCHAT
- xchat.emit_print("Channel Message", __module_name__, "Clones en \02%s\02:" % chan)
- for host in users[chan].keys():
- if host == "on": continue
- if len(users[chan][host]) > 1:
- for user in users[chan][host]:
- if user in users[chan]["on"]:
- if not user in clones:
- clones.append(user)
- if len(clones) > 1:
- xchat.emit_print("Channel Message",
- __module_name__,
- " \02*!*@%s\02: %s" % (host, ', '.join(clones)))
- clones = []
- return xchat.EAT_XCHAT
- def kbClones_cb(word, word_eol, userdata):
- chan = xchat.get_info("channel").lower()
- kusers = []
- for host in users[chan].keys():
- if host == "on": continue
- if len(users[chan][host]) > MaxClones:
- for user in users[chan][host]:
- if user in users[chan]["on"]:
- kusers.append(user)
- if len(kusers) > MaxClones:
- xchat.command("ban *!*@%s" % host)
- for user in kusers:
- xchat.command("kick %s %s" % (user, KickReason))
- kusers = []
- return xchat.EAT_XCHAT
- def kClones_cb(word, word_eol, userdata):
- chan = xchat.get_info("channel").lower()
- kusers = []
- for host in users[chan].keys():
- if host == "on": continue
- if len(users[chan][host]) > MaxClones:
- for user in users[chan][host]:
- if user in users[chan]["on"]:
- kusers.append(user)
- if len(kusers) > MaxClones:
- for user in kusers:
- xchat.command("kick %s %s" % (user, KickReason))
- kusers = []
- return xchat.EAT_XCHAT
- def Join_cb(word, word_eol, userdata):
- global users
- nick = word[0][1:].split("!")[0].lower()
- host = word[0].split("@")[1].lower()
- chan = word[2].lstrip(":").lower()
- if nick == xchat.get_info("nick").lower():
- return xchat.EAT_NONE
- if not chan in users:
- users[chan] = {}
- if not "on" in users[chan]:
- users[chan]["on"] = []
- if host in users[chan]:
- cnicks = []
- for n in users[chan][host]:
- if n == nick: continue
- if n in users[chan]["on"]:
- cnicks.append("\x0319%s\x03" % n)
- else:
- cnicks.append("\x034%s\x03" % n)
- if cnicks:
- context = xchat.find_context(channel=chan)
- context.emit_print("Channel Message",
- __module_name__,
- "Nicks usados por %s: %s" % (nick, ', '.join(cnicks)))
- if not nick in users[chan][host]:
- users[chan][host].append(nick)
- else:
- users[chan][host] = [nick]
- if not nick in users[chan]["on"]:
- users[chan]["on"].append(nick)
- return xchat.EAT_NONE
- def Part_cb(word, word_eol, userdata):
- global users
- nick = word[0][1:].split("!")[0].lower()
- chan = word[2].lower()
- if chan in users and "on" in users[chan] and nick in users[chan]["on"]:
- users[chan]["on"].remove(nick)
- return xchat.EAT_NONE
- def Quit_cb(word, word_eol, userdata):
- global users
- nick = word[0][1:].split("!")[0].lower()
- for chan in users.keys():
- if nick in users[chan]["on"]:
- users[chan]["on"].remove(nick)
- return xchat.EAT_NONE
- def Kick_cb(word, word_eol, userdata):
- global users
- nick = word[3].lower()
- chan = word[2].lower()
- if chan in users and "on" in users[chan] and nick in users[chan]["on"]:
- users[chan]["on"].remove(nick)
- return xchat.EAT_NONE
- def Nick_cb(word, word_eol, userdata):
- global users
- old = word[0][1:].split("!")[0].lower()
- host = word[0].split("@")[1].lower()
- new = word[2].lstrip(":").lower()
- for chan in users.keys():
- if "on" in users[chan] and old in users[chan]["on"]:
- users[chan]["on"].remove(old)
- users[chan]["on"].append(new)
- if host in users[chan]:
- if not new in users[chan][host]:
- users[chan][host].append(new)
- return xchat.EAT_NONE
- def unload_cb(userdata):
- xchat.emit_print("Channel Message", "\x02\x034"+__module_name__+"\x0f", "descargado.")
- xchat.hook_server("JOIN", Join_cb)
- xchat.hook_server("PART", Part_cb)
- xchat.hook_server("QUIT", Quit_cb)
- xchat.hook_server("KICK", Kick_cb)
- xchat.hook_server("NICK", Nick_cb)
- xchat.hook_timer(5000, Update_cb)
- xchat.hook_command("CLONES", Clones_cb)
- xchat.hook_command("KCLONES", kClones_cb)
- xchat.hook_command("KBCLONES", kbClones_cb)
- xchat.hook_unload(unload_cb)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement