Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 04/08/2017, à 00:42

PowaBanga

Script Hexchat pour faire un ban / auto déban

Salut à tous,

J'aurais besoin d'un script en python, que me permette de bannir un utilisateur, et qu'il soit débanni automatiquement après un certain temps.

__module_name__ = 'ChronoBan'
__module_version__ = '0.1'
__module_description__ = 'Ban user for a spécific time, with a random reason.'
__module_author__ = 'Powa'
 
import xchat
import time
 
c = '\x02\x0303'
help = '%sType /ban{1-3-5-10} [nick] - to kick [user] with a random reason. ' % c + \
       'Exclude the user to kick a random user, with a reason!'
 
print('%s%s has been loaded.' % (c, __module_name__))
 
def ban1(word, word_eol, userdata):
    global myhook
    #try:
    if len(word) == 2:
        # Assume they supplied a username
        return xchat.command('ban %s!*@*' % (word[1]))
        myhook = xchat.hook_timer(30, unbanishment)
 
    elif len(word) == 1:
        # Assume they want a random user
        list = xchat.get_list("users")
        if not list:
            return xchat.prnt(help)
        user = select((list))
        return xchat.command('ban %s@*' % (user.nick))
        myhook = xchat.hook_timer(30, unbanishment)
    else:
        # Assume they entered some weird stuff
        return xchat.prnt(help)
    #except:
    #    xchat.prnt(help)
def unbanishment(word, word_eol, userdata):
    if len(word) == 2:
        # Assume they supplied a username
        return xchat.command('unban %s!*@*' % (word[1]))
 
    elif len(word) == 1:
        # Assume they want a random user
        list = xchat.get_list("users")
        if not list:
            return xchat.prnt(help)
        user = select((list))
        return xchat.command('unban %s@*' % (user.nick))
     
    return xchat.EAT_ALL
 
def onUnload(userdata):
    xchat.prnt('%s%s has been unloaded.' % (c, __module_name__))
 
xchat.hook_command('ban1', ban1, help=help)
xchat.hook_unload(onUnload)

Alors voilà mon script à l'air de fonctionner, sauf qu'il ne lance apparemment pas la balise "unbanishment", j'imagine que je dois avoir un souci avec le timer, mais je ne reçois acun messages d'erreurs, donc j'ai un peu du mal à comprendre d'ou vient le souci... hmm

Si quelqu'un sait m'aider, ça serait carément super génial !

ici je test avec un script plus simple pour essayer de comprendre

__module_name__ = 'tes'
__module_version__ = '0.1'
__module_description__ = 'Ban user for a spécific time.'
__module_author__ = 'Powa'
 
import xchat
import time
 
c = '\x02\x0303'
help = '%sType /ban{1-3-5-10} [nick] - to kick [user] with a random reason. ' % c + \
       'Exclude the user to kick a random user, with a reason!'
 
print('%s%s has been loaded.' % (c, __module_name__))
 
def test1(word, word_eol, userdata):
		xchat.command("say test")
		xchat.hook_timer(30, test2)
		xchat.command("say test1.2")
    
def test2(word):
         xchat.command("say test2.2")

def onUnload(userdata):
    xchat.prnt('%s%s has been unloaded.' % (c, __module_name__))
 
xchat.hook_command('test1', test1, help=help)
xchat.hook_unload(onUnload)

ce script me fais dire

<PowaBanga> test
<PowaBanga> test1.2
<PowaBanga> test2.2

de façon quasiment instantanée...

Dernière modification par PowaBanga (Le 04/08/2017, à 17:22)

Hors ligne