hello.py est un script très simple écrit en python qui permet de saluer automatiquement des personnes sur IRC.
Voici le code
#
# hello.py
# xcfaudio at gmail dot com
#
__module_name__ = "hello"
__module_version__ = "0.1"
__module_description__ = "Said hello automatically"
__module_author__ = "xcfaudio"
try:
import hexchat as xchat
except ImportError:
import xchat
Liste = {
'Nom_1' : False,'Nom_2' : False,'Nom_3' : False,'Nom_4' : False,'Nom_5' : False,'Nom_6' : False
};
myhook = None # Trace timer
def func_scan_users():
"""Compare la liste aux utilsateurs du salon"""
global Liste
StringUser = ""
print'func_scan_users():'
userlist = xchat.get_list('users')
for user in userlist:
Champs = user.nick.strip()
if len(Champs) > 0:
for elem in Liste:
if elem.lower() == Champs.lower():
if Liste[ Champs ] == False:
Liste[ Champs ] = True
# xchat.command("say Salut %s" % Champs)
# adressage de liste : salut un, deux, trois, etc ...
StringUser = StringUser + Champs + ''
if StringUser:
# print( 'Salut ' + StringUser )
xchat.command("say Salut %s" % StringUser)
def autoJoin_timeout_cb(userdata):
"""Timer quand quelqu'un rejoint le salon"""
global myhook
func_scan_users()
# Disabling the timeout
if myhook is not None:
xchat.unhook(myhook)
myhook = None
print "TIMEOUT deactivate !"
return 1
# ------------------------------------------------------------
# Bascule vers un canal l'IRC mode auto ou ligne de commande
# ------------------------------------------------------------
def autoJoin(word,word_eol,userdata):
"""Bascule vers un canal l'IRC"""
global myhook
myhook = xchat.hook_timer(2000, autoJoin_timeout_cb)
xchat.hook_print('You Join', autoJoin)
# ------------------------------------------------------------
# Un utilisateur rejoint l'IRC
# ------------------------------------------------------------
def user_join_channel(word,word_eol,userdata):
"""Un utilisateur rejoint l'IRC: word[0]"""
global myhook
myhook = xchat.hook_timer(2000, autoJoin_timeout_cb)
xchat.hook_print('Join', user_join_channel)
# ------------------------------------------------------------
# Bascule vers un canal IRC par click bouton
# ------------------------------------------------------------
def goto_Join(word, wordEOL, userData):
"""Bascule vers un canal IRC par click bouton"""
func_scan_users()
xchat.hook_command('Join', goto_Join)
# ------------------------------------------------------------
# Script Loaded
# ------------------------------------------------------------
print
print "[ hello.py ] Loaded !"
printModification de la liste
Vous avez juste besoin de: ajouter / retirer / remplacer les chaines [ 'Nom_1', 'Nom_2', etc ] par des pseudos de votre connaissance
Liste = {'Nom_1' : False,'Nom_2' : False,'Nom_3' : False,'Nom_4' : False,'Nom_5' : False,'Nom_6' : False
};Documentations utilisées
Il apparaît comme évident que ...
... ce script peut / doit être complété par exemple avec une fonction de surveillance du signal away afin de ne pas saluer un nouvel arrivant connu durant notre absence ou inversement !, une autre fonction de sauvegarde / récupération des noms du jour, etc ...
Bref ! La seule limite est l'imagination ...