quarta-feira, julho 20, 2005

Plugin pro xchat avisar sobre mensagens

Plugin quick'n'dirty pro X-chat Aqua notificar por voz quando alguem digita:

seunick: alou!?!?!
Coloque em /Applications/X-chat Aqua/Plugins/notify.py:

import xchat
import os
import time

__module_name__ = "notify"
__module_version__ = "1.0"
__module_description__ = "Notify through voice when someone talks to us"

mynicks= ["mrbrocoli", "mrbro", "mrb"]
delay= 5

last_notify= 0
def notify_cb(word, word_eol, userdata):
global last_notify
target= word[2]
line= " ".join(word[3:])[1:]
for_me= 0
source= word[0][1:].split("!")[0]

if target[0]!='#':
for_me= 1
else:
for n in mynicks:
if line.lower().find(n)>=0:
for_me=1
break
if for_me:
if time.time() - last_notify >= delay:
msg= "message from %s"%source.replace("'","").replace("\\","")
os.system("say '%s' &"%msg)
last_notify= time.time()

return xchat.EAT_NONE

xchat.hook_server("PRIVMSG", notify_cb)