You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
839 B
33 lines
839 B
import brathuhn, datetime, time
|
|
|
|
last_active = dict()
|
|
|
|
def active(mfrom,msg):
|
|
global last_active
|
|
body = unicode(msg.getBody())
|
|
res = mfrom.getResource()
|
|
date=datetime.datetime.fromtimestamp(time.time())
|
|
last_active[res]=(body,date.strftime("%a, %d-%b-%Y %H:%M:%S"))
|
|
brathuhn.addGroupListener(active)
|
|
|
|
|
|
def last_active_cmd(msg,args):
|
|
if( len(args)==2 ):
|
|
res = args[1]
|
|
if res in last_active:
|
|
if res[-1]!='s':
|
|
mymsg=res+"'s"
|
|
else:
|
|
mymsg=res+"'"
|
|
la = last_active[res]
|
|
mymsg+= " last message on "+la[1]+' : "'+la[0]+'"'
|
|
|
|
brathuhn.sendMsg(brathuhn.ROOM,mymsg,'groupchat')
|
|
else:
|
|
brathuhn.sendMsg(brathuhn.ROOM,"no message in record",'groupchat')
|
|
else:
|
|
brathuhn.sendMsg(brathuhn.ROOM,"Usage: "+args[0]+" nick",'groupchat')
|
|
brathuhn.addCommand("last_active","Usage: !last_active nick",last_active_cmd)
|
|
|
|
|
|
|
|
|