diff --git a/modules/active/tell.py b/modules/active/tell.py index a02dc5a..95732e4 100644 --- a/modules/active/tell.py +++ b/modules/active/tell.py @@ -12,13 +12,16 @@ import config # HOLDBACK ... how long will brathuhn wait # to tell someone DELAY = 60*60*24 -HOLDBACK = 60*60*24*7 +HOLDBACK = 60*60*24*7 # TODO make brathuhn tell if it deletes messages ############################################## -store = [] +container = PersistentContainer(__name__+'_data',config.PCACHE) +if not "store" in container: + container["store"] = [] def tell(msg, args): - global store + global container + store = container["store"] if( len(args) <= 2): brathuhn.sendMsg(brathuhn.ROOM,"Usage: "+args[0]+" nick text",'groupchat') @@ -36,10 +39,12 @@ def tell(msg, args): nick = spl[1] origin = msg.getFrom().getResource() store.append( (nick, message, origin, datetime.today()) ) + container["store"] = store brathuhn.sendMsg(brathuhn.ROOM,origin+": will do!",'groupchat') def tellCB(nick, msg, status): - global store + global container + store = container["store"] if(status != brathuhn.STATUS_JOIN): return @@ -55,9 +60,11 @@ def tellCB(nick, msg, status): for r in rem: store.remove(r) + container["store"] = store def cleartell(): - global store + global container + store = container["store"] now = datetime.today() rem = [] for l in store: @@ -65,6 +72,7 @@ def cleartell(): rem.append(l) for r in rem: store.remove(r) + container["store"] = store brathuhn.callAt(cleartell, time.time()+DELAY, []) @@ -77,13 +85,15 @@ brathuhn.callAt(cleartell, time.time()+DELAY, []) ############################################## #def flushtell(msg, args): -# global store +# global container + store = container["store"] # store = [] # #brathuhn.addCommand("flush","Usage: !flush ", flushtell) #def showtell(msg, args): -# #global store +# #global container + store = container["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)