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