# # Modulo per xchat 2.6.x: bankickadvanced - Banna e kicka uno o piu' utenti, con diversi schemi. # Digita "/bkick help" per maggiori informazioni. # ----------------------------------------------- # Copyright (C) 2006 Simone Economo # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ----------------------------------------------- # # Autore: Simone Economo (aka eKoeS) (http://www.lineheight.net) # Contatto: my.ekoes@gmail.com # # Potete trovare informazioni sulla licenza GPL2 in uso su: # http://www.gnu.org/licenses/gpl.html # ITA (Non ufficiale): http://www.softwarelibero.it/gnudoc/gpl.it.txt # __module_name__ = "bankickadvanced" __module_version__ = "1.2" __module_description__ = "Banna e kicka uno o piu' utenti, con diversi schemi." __module_author__ = "eKoeS (my.ekoes@gmail.com)" helpText = """ {text} = obbligatorio [test] = opzionale USO: /bkick {nick}[,nick[,nick]] {tipo} [ragione] Es. /bkick Bill,Gates 1,2 Utenti windows! Tipi di ban permessi: \t- 0 *!*@*.host \t- 1 *!*@domain \t- 2 *!*user@*.host \t- 3 *!*user@domain \t- 1,2 *!*@domain,*!*user@*.host Puoi trovare informazioni sulla licenza GPL2 in uso su: \t http://www.gnu.org/licenses/gpl.html \t ITA (Non ufficiale): http://www.softwarelibero.it/gnudoc/gpl.it.txt """ import xchat def bantype(mask, mode): """ Questa funzione suddivide la mask, in modo tale che possano essere impostati 4 differenti tipi di ban. """ try: user = mask.split("@")[0] domain = mask.split("@")[1] host = domain.replace(domain.split(".")[0],"") except IndexError: print "Errore! Non posso leggere questa mask." return xchat.EAT_NONE command = None if mode == "0": command = "mode +b *!*@*"+host elif mode == "1": command = "mode +b *!*@"+domain elif mode == "2": command = "mode +b *!*"+user+"@*"+host elif mode == "3": command = "mode +b *!*"+user+"@"+domain elif mode == "1,2": command = ["mode +b *!*@"+domain,"mode +b *!*"+user+"@*"+host] return command def searchandban(nickname, mode, reason): """ Controlla che il nick sia presente nel canale, infine lo banna con lo schema desiderato. """ for username in xchat.get_list("users"): if nickname == username.nick: if type(bantype(username.host, mode)) is list: # Se il bantype e' "1,2" xchat.command(bantype(username.host, mode)[0]) xchat.command(bantype(username.host, mode)[1]) else: xchat.command(bantype(username.host, mode)) xchat.command("kick %s %s" % (nickname, reason)) return xchat.EAT_NONE else: print "Errore! \"%s\": nickname non trovato." % nickname return xchat.EAT_NONE def bkick(word, word_eol, userdata): """ Effettua alcuni controlli: - Se siamo operatori del canale - Se inseriamo tutti i valori obbligatori - Se digitiamo il comando in un canale """ for me in xchat.get_list("users"): if me.nick == xchat.get_info("nick") and me.prefix != "@": print "Error! Devi essere un'operatore per eseguire questo comando." return xchat.EAT_NONE if len(word) == 1: print "Error! Devi dichiarare nickname e tipo di ban." return xchat.EAT_NONE elif len(word) == 2: if word[1] == "help": # /bkick help - Visualizza l'aiuto. print helpText else: print "Errore! Devi dichiarare il tipo di ban." return xchat.EAT_NONE elif len(word) >= 3: if xchat.get_info("channel") is None or not xchat.get_info("channel").startswith("#"): print "Errore! Questo comando e' valido SOLO nei canali." return xchat.EAT_NONE try: if word[2] != "1,2": btype = int(word[2]) if btype >= 4: # Se il bantype è maggiore di 4 e diverso da "1,2" print "Errore! \"%d\": tipo di ban sconosciuto. Per maggiori informazioni digita: \"/bkick help\"." % btype return xchat.EAT_NONE else: btype = word[2] # Controlla che ci sia una ragione, altrimenti lascia vuoto try: reason = word_eol[3] except IndexError: reason = "" # Se il bkick è desiderato per più nickname if len(word[1].split(",")) != 1: names = word[1].split(",") for i in range(len(names)): searchandban(names[i], str(btype), reason) else: searchandban(word[1], str(btype), reason) except ValueError: print "Errore! Devi dichiarare il tipo di ban." return xchat.EAT_NONE xchat.hook_command("bkick", bkick, help=helpText) print """ Modulo \"%s\" v.%s caricato correttamente! \n\nPer maggiori informazioni digita: \"/bkick help\". Bankickadvanced version 0.1, Copyright (C) 2006 Simone Economo Bankickadvanced comes with ABSOLUTELY NO WARRANTY; this is free software, and you are welcome to redistribute it under certain conditions. For details type "/bkick help". """ % (__module_name__,__module_version__)