All pastes #801687 Raw Edit

[XChat] Auto-Op/Voice

public python v1 · immutable
#801687 ·published 2007-11-29 14:34 UTC
rendered paste body
# -*- coding: iso-8859-15 -*-__module_name__ = "Auto-Op/Voice"__module_version__ = "1.0"__module_description__ = "Auto-Op/Voice au join :)"__module_author__ = "Xn - dev@0x586e.info"import xchat import stringMyContext = ''MyChansOp = []MyChansVoice = []def MyAutoThing(word,word_eol,usersata):    global MyChans, MyContext    NickOn = word[0].split('!')    NickOn = NickOn[0].replace(':','')    if (NickOn <> xchat.get_info('nick')):        ChannelOn = word_eol[2].replace(':','')        MyContext = xchat.find_context(channel=ChannelOn)        IsOp = MeIsOp()        if ((ChannelOn in MyChansOp) and (ChannelOn in MyChansVoice)):            if (IsOp is not None):                MyContext.command("MODE %s +ov %s %s" % (ChannelOn, NickOn, NickOn))            else:                MyContext.prnt('Vous n\'êtes pas opérateur sur ce salon !!')        elif (ChannelOn in MyChansOp):            if (IsOp is not None):                MyContext.command("MODE %s +o %s" % (ChannelOn, NickOn))            else:                MyContext.prnt('Vous n\'êtes pas opérateur sur ce salon !!')        elif (ChannelOn in MyChansVoice):            if (IsOp is not None):                MyContext.command("MODE %s +v %s" % (ChannelOn, NickOn))            else:                MyContext.prnt('Vous n\'êtes pas opérateur sur ce salon !!')    return xchat.EAT_NONEdef MeIsOp():    global MyContext    MyList = MyContext.get_list('users')    for i in MyList:        if (i.nick == xchat.get_info('nick')):            if (i.prefix == '@'):                return True                break                def AddAutoOpChannel(word,word_eol,userdata):    global MyChansOp    if (len(word) <> 2):        xchat.prnt('Erreur : Mauvais Format')    elif (word[1][0] <> '#'):        xchat.prnt('Ajout Incorrect, erreur.')    elif (word[1] in MyChansOp):        xchat.prnt('Erreur : Salon déjà dans l\'autoop Liste')    elif (len(word) == 2):        MyChansOp.append(word[1])        UpdateIt()        xchat.prnt("Salon : %s ajouté a la liste d'auto-op" % word[1])    return xchat.EAT_ALL    def AddAutoVoiceChannel(word,word_eol,userdata):    global MyChansVoice    if (len(word) <> 2):        xchat.prnt('Erreur : Mauvais Format')    elif (word[1][0] <> '#'):        xchat.prnt('Ajout Incorrect, erreur.')    elif (word[1] in MyChansVoice):        xchat.prnt('Erreur : Salon déjà dans l\'autovoice Liste')    elif (len(word) == 2):        MyChansVoice.append(word[1])        UpdateIt()        xchat.prnt("Salon : %s ajouté a la liste d'auto-voice" % word[1])    return xchat.EAT_ALLdef RemAutoOpChannel(word,word_eol,userdata):    global MyChansOp    if (len(word) <> 2):        xchat.prnt('Erreur : Mauvais Format')    elif (word[1][0] <> '#'):        xchat.prnt('Erreur : Mauvais Format')    elif not(word[1] in MyChansOp):        xchat.prnt('Erreur : Salon Inconnu')    elif (len(word) == 2):        MyChansOp.remove(word[1])        UpdateIt()        xchat.prnt("Salon : %s supprimé de la liste d'auto-op" % word[1])    return xchat.EAT_ALL    def RemAutoVoiceChannel(word,word_eol,userdata):    global MyChansVoice    if (len(word) <> 2):        xchat.prnt('Erreur : Mauvais Format')    elif (word[1][0] <> '#'):        xchat.prnt('Erreur : Mauvais Format')    elif not(word[1] in MyChansVoice):        xchat.prnt('Erreur : Salon Inconnu')    elif (len(word) == 2):        MyChansVoice.remove(word[1])        UpdateIt()        xchat.prnt("Salon : %s supprimé de la liste d'auto-voice" % word[1])    return xchat.EAT_ALL    def AopList(word,word_eol,userdata):    global MyChansOp    xchat.prnt(':: Salons en Auto-Op ::')    for i in MyChansOp:        xchat.prnt(i)    xchat.prnt(':: Fin de la liste Auto-Op ::')    return xchat.EAT_ALL    def VopList(word,word_eol,userdata):    global MyChansVoice    xchat.prnt(':: Salons en Auto-Voice ::')    for i in MyChansVoice:        xchat.prnt(i)    xchat.prnt(':: Fin de la liste Auto-Voice ::')    return xchat.EAT_ALL        def InitIt():    global MyChansOp, MyChansVoice    XChatPath = xchat.get_info("xchatdir")+'\\xnauto.txt'    try:        fh = open(XChatPath,'r')        MyData = fh.read()        fh.close()    except:        fh = file(XChatPath,'w')        fh.write('|')        fh.close    try:        MyOps = MyData.split('|')        print len(MyOps)        print MyOps        MyChansOp = MyOps[0].split(',')        MyChansVoice = MyOps[1].split(',')    except:        pass    fh.close()    xchat.prnt(':: Auto-op/voice list loaded successfully ::')    return xchat.EAT_ALL    def UpdateIt():    global MyChansOp, MyChansVoice    XChatPath = xchat.get_info("xchatdir")+'\\xnauto.txt'    fh = open(XChatPath,'w')    MyString = string.join(MyChansOp,",") + '|' + string.join(MyChansVoice,",")     fh.write(MyString)    fh.close()    return xchat.EAT_ALLdef MyHelp(word,word_eol,userdata):    xchat.prnt("Bienvenue dans l'aide de ce Plugin Auto-OP/Voice")    xchat.prnt("Commandes principales : ")    xchat.prnt(":: /addaop #Salon :: Permet d'ajouter un salon a la liste d'Auto-OP")    xchat.prnt(":: /addavo #Salon :: Permet d'ajouter un salon a la liste d'Auto-Voice")    xchat.prnt(":: /remaop #Salon :: Permet de retirer un salon de la liste d'Auto-OP")    xchat.prnt(":: /remavo #Salon :: Permet de retirer un salon de la liste d'Auto-Voice")    xchat.prnt(":: /aoplist :: Liste des salons actuellement en Auto-OP")    xchat.prnt(":: /voplist :: Liste des salons actuellement en Auto-Voice")    xchat.prnt(":: /autohelp :: Montre cette aide")    xchat.prnt("- Xn :: dev@0x586e.info -")    return xchat.EAT_ALL       xchat.hook_server('JOIN',MyAutoThing)xchat.hook_command('addaop',AddAutoOpChannel,help="Syntax /addaop #Channel")xchat.hook_command('addavo',AddAutoVoiceChannel,help="Syntax /addavo #Channel")xchat.hook_command('remaop',RemAutoOpChannel,help="Syntax /remaop #Channel")xchat.hook_command('remavo',RemAutoVoiceChannel,help="Syntax /remavo #Channel")xchat.hook_command('aoplist',AopList,help="Syntax /AopList")xchat.hook_command('voplist',VopList,help="Syntax /Voplist")xchat.hook_command('autohelp',MyHelp,help="Montre l'aide de ce PlugIN")InitIt()xchat.prnt('%s - %s' % (__module_author__,__module_name__))