identication errors...

master
Stefan Krulj 14 years ago
parent 4d336b3fea
commit e6610ca7d5
  1. 118
      modules/active/tell.py

@ -17,64 +17,64 @@ HOLDBACK = 60*60*24*7 # TODO make brathuhn tell if it deletes messages
container = PersistentContainer(__name__+'_data',config.PCACHE) container = PersistentContainer(__name__+'_data',config.PCACHE)
if not "store" in container: if not "store" in container:
container["store"] = [] container["store"] = []
def tell(msg, args): def tell(msg, args):
global container global container
store = container["store"] store = container["store"]
if( len(args) <= 2): if( len(args) <= 2):
brathuhn.sendMsg(brathuhn.ROOM,"Usage: "+args[0]+" nick text",'groupchat') brathuhn.sendMsg(brathuhn.ROOM,"Usage: "+args[0]+" nick text",'groupchat')
return return
userJID = brathuhn.getUsers().items() userJID = brathuhn.getUsers().items()
for a in userJID: for a in userJID:
if( args[1] == a[0].getResource()): if( args[1] == a[0].getResource()):
brathuhn.sendMsg(brathuhn.ROOM,"User "+args[1]+" is already here, tell them yourself!",'groupchat') brathuhn.sendMsg(brathuhn.ROOM,"User "+args[1]+" is already here, tell them yourself!",'groupchat')
return return
body = unicode(msg.getBody()) body = unicode(msg.getBody())
spl = body.split(' ', 2) spl = body.split(' ', 2)
message = spl[2] message = spl[2]
nick = spl[1] nick = spl[1]
origin = msg.getFrom().getResource() origin = msg.getFrom().getResource()
store.append( (nick, message, origin, datetime.today()) ) store.append( (nick, message, origin, datetime.today()) )
container["store"] = store container["store"] = store
brathuhn.sendMsg(brathuhn.ROOM,origin+": will do!",'groupchat') brathuhn.sendMsg(brathuhn.ROOM,origin+": will do!",'groupchat')
def tellCB(nick, msg, status): def tellCB(nick, msg, status):
global container global container
store = container["store"] store = container["store"]
if(status != brathuhn.STATUS_JOIN): if(status != brathuhn.STATUS_JOIN):
return return
user = nick.getResource() user = nick.getResource()
rem = [] rem = []
for l in store: for l in store:
if(l[0] == unicode(user)): if(l[0] == unicode(user)):
timestamp = "{0:02}:{1:02}, {2}-{3:02}-{4:02}".format(l[3].hour, l[3].minute, l[3].year, l[3].month, l[3].day) timestamp = "{0:02}:{1:02}, {2}-{3:02}-{4:02}".format(l[3].hour, l[3].minute, l[3].year, l[3].month, l[3].day)
brathuhn.sendMsg(brathuhn.ROOM,(l[0]+": User "+l[2]+" told me at "+timestamp+" to tell you: \""+l[1]+"\""),'groupchat') brathuhn.sendMsg(brathuhn.ROOM,(l[0]+": User "+l[2]+" told me at "+timestamp+" to tell you: \""+l[1]+"\""),'groupchat')
rem.append(l) rem.append(l)
for r in rem: for r in rem:
store.remove(r) store.remove(r)
container["store"] = store container["store"] = store
def cleartell(): def cleartell():
global container global container
store = container["store"] store = container["store"]
now = datetime.today() now = datetime.today()
rem = [] rem = []
for l in store: for l in store:
if(now - l[3] < HOLDBACK): if(now - l[3] < HOLDBACK):
rem.append(l) rem.append(l)
for r in rem: for r in rem:
store.remove(r) store.remove(r)
container["store"] = store container["store"] = store
brathuhn.callAt(cleartell, time.time()+DELAY, []) brathuhn.callAt(cleartell, time.time()+DELAY, [])
############################################## ##############################################
@ -85,19 +85,19 @@ brathuhn.callAt(cleartell, time.time()+DELAY, [])
############################################## ##############################################
#def flushtell(msg, args): #def flushtell(msg, args):
# global container # global container
store = container["store"] store = container["store"]
# store = [] # store = []
# #
#brathuhn.addCommand("flush","Usage: !flush ", flushtell) #brathuhn.addCommand("flush","Usage: !flush ", flushtell)
#def showtell(msg, args): #def showtell(msg, args):
# #global container # #global container
store = container["store"] store = container["store"]
# #
# for l in store: # for l in store:
# timestamp = "{:02}:{:02}, {}-{:02}-{:02}".format(l[3].hour, l[3].minute, l[3].year, l[3].month, l[3].day) # timestamp = "{:02}:{:02}, {}-{:02}-{:02}".format(l[3].hour, l[3].minute, l[3].year, l[3].month, l[3].day)
# brathuhn.sendMsg(brathuhn.ROOM,(l[2]+" -> "+ l[0]+"; "+l[1]+"; "+timestamp),'groupchat') # brathuhn.sendMsg(brathuhn.ROOM,(l[2]+" -> "+ l[0]+"; "+l[1]+"; "+timestamp),'groupchat')
# #
#brathuhn.addCommand("show","Usage: !show ", showtell) #brathuhn.addCommand("show","Usage: !show ", showtell)

Loading…
Cancel
Save