def triggerLog(fromName, fromJid, params): (presence, fromJid, affiliation, role, newNick) = params msg_join_fmt = "*** {0} has joined the room as {1} and {2}" msg_left_fmt = "*** {0} has left the room" msg_nick_fmt = "*** {0} is now known as {1}" msg_kick_fmt = "*** {0} has been kicked" msg_ban_fmt = "*** {0} has been banned" [muc, author] = fromName.split("/", 1) lastRenamed = urusai_plugin.dbGet(muc + "_lastrenamed") if presence == "kick": message = msg_kick_fmt.format(author) elif presence == "ban": message = msg_ban_fmt.format(author) elif presence == "join" and lastRenamed != author: message = msg_join_fmt.format(author, affiliation, role) elif newNick: message = msg_nick_fmt.format(author, newNick) urusai_plugin.dbSet(muc + "_lastrenamed", newNick) elif lastRenamed != author: message = msg_left_fmt.format(author) else: urusai_plugin.dbSet(muc + "_lastrenamed", '') return '' now = datetime.now() target_file = now.strftime(FILE_FMT.format(muc)) element = now.strftime(STRING_FMT.format(message)) putElement(target_file, element) return ''
def loadStat(muc): stat = urusai_plugin.dbGet(muc + "_badwords") if not stat: return {} else: return marshal.loads(stat)