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.
63 lines
2.1 KiB
63 lines
2.1 KiB
import brathuhn, tempfile
|
|
|
|
user_logs = dict()
|
|
|
|
def show_log(msg,args):
|
|
if len(args)!=1:
|
|
brathuhn.sendMsg(msg.getFrom(),"Usage: !"+args[0])
|
|
return
|
|
if msg.getFrom() in user_logs:
|
|
user_logs[msg.getFrom()].seek(0)
|
|
log = user_logs[msg.getFrom()].read()
|
|
brathuhn.sendMsg(msg.getFrom(),'\n'+log)
|
|
else:
|
|
brathuhn.sendMsg(msg.getFrom(),"I'm currently not logging for you")
|
|
|
|
def del_log(msg,args):
|
|
if len(args)!=1:
|
|
brathuhn.sendMsg(msg.getFrom(),"Usage: !"+args[0])
|
|
return
|
|
if msg.getFrom() in user_logs:
|
|
user_logs[msg.getFrom()].seek(0)
|
|
user_logs[msg.getFrom()].truncate(0)
|
|
brathuhn.sendMsg(msg.getFrom(),"Done!")
|
|
else:
|
|
brathuhn.sendMsg(msg.getFrom(),"I'm currently not logging for you")
|
|
|
|
def stop_log(msg,args):
|
|
if len(args)!=1:
|
|
brathuhn.sendMsg(brathuhn.ROOM,"Usage: !"+args[0],'groupchat')
|
|
return
|
|
brathuhn.sendMsg(brathuhn.ROOM,"/me stopped logging for "+unicode(msg.getFrom()),'groupchat')
|
|
if msg.getFrom() in user_logs:
|
|
del user_logs[msg.getFrom()]
|
|
|
|
|
|
def start_log(msg,args):
|
|
if len(args)!=1:
|
|
brathuhn.sendMsg(brathuhn.ROOM,"Usage: !"+args[0],'groupchat')
|
|
return
|
|
brathuhn.sendMsg(brathuhn.ROOM,"/me started logging for "+unicode(msg.getFrom()),'groupchat')
|
|
user_logs[msg.getFrom()]=open(tempfile.mkstemp(brathuhn.NAME)[1],"w+")
|
|
|
|
def message_logger(mfrom,msg):
|
|
for key in user_logs:
|
|
user_logs[key].write(mfrom+": "+msg+"\n")
|
|
|
|
def status_logger(mfrom,msg,status):
|
|
for key in user_logs:
|
|
if status==brathuhn.STATUS_JOIN:
|
|
user_logs[key].write(unicode(mfrom)+" joined\n")
|
|
if status==brathuhn.STATUS_ONLINE:
|
|
user_logs[key].write(unicode(mfrom)+" is now online\n")
|
|
pass
|
|
if status==brathuhn.STATUS_OFFLINE:
|
|
user_logs[key].write(unicode(mfrom)+" left\n")
|
|
if status==brathuhn.STATUS_RENAME:
|
|
user_logs[key].write(unicode(mfrom)+" is now known as "+msg.getName()+"\n")
|
|
if status==brathuhn.STATUS_XAWAY:
|
|
user_logs[key].write(unicode(mfrom)+" is now extended away\n")
|
|
if status==brathuhn.STATUS_AWAY:
|
|
user_logs[key].write(unicode(mfrom)+" is now away\n")
|
|
if status==brathuhn.STATUS_UNKNOWN:
|
|
user_logs[key].write(unicode(mfrom)+" is now ???\n")
|
|
|