Gestion des Hilights Xchat python

Voici un script pas encore tout a fait au point, mais fonctionnel malgre tout, qui permet d'afficher les Hilights dans une fenetre a part et/ou sur le salon courant. Pour charger ce script au demarrage de xchat, il faut le mettre dans le meme repertoire que le fichier xchat.conf ( sous linux dans ~/.xchat2/ )

Le bug des HL en message privé est corrigé
__module_name__ = "HiLights" 

__module_version__ = "1.1" 
__module_description__ = "Script de gestion de HL"
import xchat
import string

NOHL = ["Pegasus","Nemesis","Thetys"]
HLS = ["TroLL","Own3d","own3d"]

FENSUP = "oui"
CURCHAN = "oui"
def messages_cb(word, word_eol, userdata):

      CURRPSEUDO = xchat.get_info("nick")
      CRCH = xchat.find_context(channel=None)

      LE_MSG = word_eol[3]
      LEPSEUD = word[0]

      LEPSEUD = string.replace(LEPSEUD,':','')
      LEPSEUD = string.split(LEPSEUD,'!')

      LE_PSEUDO = LEPSEUD[0]
      LE_HOST = LEPSEUD[1]

      for NHL in NOHL:
           if LE_PSEUDO.count(NHL):

                return xchat.EAT_NONE
      for HL in HLS:
           if (LE_MSG.count(HL)) or (LE_MSG.count(CURRPSEUDO)):

                try:
                     CCRCH = CRCH.get_info("channel")
                     testa = xchat.find_context(channel=word[2])

                     testb = testa.get_info("channel")
                     if (CURCHAN == "oui") and (CCRCH != testb):

                          CRCH.prnt("\x0321\x02HIGHLIGHT\t%s  (%s) \x03\x02%s\n\x0318\x02%s " % (LE_PSEUDO, LE_HOST, word[2], word_eol[3]))

                except AttributeError:
                     CCRCH = CRCH.get_info("channel")

                     prout = word[0].split("!")
                     prout = string.replace(prout[0],':','')

                     testa = xchat.find_context(channel=prout)
                     testb = testa.get_info("channel")

                     if (CURCHAN == "oui") and (CCRCH != testb):

                          CRCH.prnt("\x0321\x02HIGHLIGHT\t%s  (%s) \x03Message Prive\n\x0318\x02%s " % (LE_PSEUDO, LE_HOST, word_eol[3]))

           if (LE_MSG.count(HL)) or (LE_MSG.count(CURRPSEUDO)):

                if FENSUP == "oui":
                     LAFEN = xchat.find_context(channel="HiLight")

                     if LAFEN == None:
                          xchat.command("query -nofocus HiLight")

                          LAFEN = xchat.find_context(channel="HiLight")
                          LAFEN.prnt("\x0321\x02%s\t%s (%s) \x03\x02%s" % (word[2],LE_PSEUDO, LE_HOST, word_eol[3]))

                          return xchat.EAT_NONE
                     else:
                          LAFEN.prnt("\x0321\x02%s\t%s (%s) \x03\x02%s" % (word[2],LE_PSEUDO, LE_HOST, word_eol[3]))

                          return xchat.EAT_NONE
      return xchat.EAT_NONE
xchat.hook_server("PRIVMSG", messages_cb) 

print "%s %s loaded" % (__module_name__, __module_version__)

0 commentaires: