def CmdInitUserFromDbDo(from_name,msg): if not funcs.isAdmin(from_name): return 'you are not administrator' users_data = {} all_users = DBUser.all().fetch(1000) users_online_list = [] users_onlinemsgon_list = [] users_onlinemsgoff_list = [] users_offlinemsgon_list = [] users_offlinemsgoff_list = [] for user in all_users: users_data[user.gtalk] = user if xmpp_api.isOnline(user.gtalk): users_online_list.append(user.gtalk) if user.recvOnlineMsg: users_onlinemsgon_list.append(user.gtalk) else: users_onlinemsgoff_list.append(user.gtalk) if user.recvOfflineMsg: users_offlinemsgon_list.append(user.gtalk) else: users_offlinemsgoff_list.append(user.gtalk) memcache.flush_all() memcache.set('cache_all_user_list',users_data,43200) funcs.setConfigValueWithCache('cache_online_user_list',users_online_list) funcs.setConfigValueWithCache('cache_online_msgon_user_list',users_onlinemsgon_list) funcs.setConfigValueWithCache('cache_online_msgoff_user_list',users_onlinemsgoff_list) funcs.setConfigValueWithCache('cache_offline_msgon_user_list',users_offlinemsgon_list) funcs.setConfigValueWithCache('cache_offline_msgoff_user_list',users_offlinemsgoff_list) return 'init cache from db ok'
def InitOnlineUserListFromDb(): users = DBUser.all().fetch(1000) users_list = [] for user in users: if xmpp_api.isOnline(user.gtalk): users_list.append(user.gtalk) return users_list
def checkUserOnline(): ret_msg = '' online_users = getOnlineUserListFromCache() all_users = getUserListFromCache() for user in all_users.values(): if user.gtalk.find('@gmail.com') == -1: continue if xmpp_api.isOnline(user.gtalk): if user.gtalk not in online_users: addUserToOnlineUserList(user.gtalk) if not user.recvOnlineMsg: xmpp_api.xmpp_sendmsg(user.gtalk,'[NOTICE]:You CANT Receive Any Msg Since Your OnlineMsgFlag is Off.') else: if user.gtalk in online_users: delUserFromOnlineUserList(user.gtalk)
def checkUserOnline(): ret_msg = '' online_users = getOnlineUserListFromCache() all_users = getUserListFromCache() for user in all_users.values(): if user.gtalk.find('@gmail.com') == -1: continue if xmpp_api.isOnline(user.gtalk): if user.gtalk not in online_users: addUserToOnlineUserList(user.gtalk) if not user.recvOnlineMsg: xmpp_api.xmpp_sendmsg( user.gtalk, '[NOTICE]:You CANT Receive Any Msg Since Your OnlineMsgFlag is Off.' ) else: if user.gtalk in online_users: delUserFromOnlineUserList(user.gtalk)
def CmdInitUserFromDbDo(from_name, msg): if not funcs.isAdmin(from_name): return 'you are not administrator' users_data = {} all_users = DBUser.all().fetch(1000) users_online_list = [] users_onlinemsgon_list = [] users_onlinemsgoff_list = [] users_offlinemsgon_list = [] users_offlinemsgoff_list = [] for user in all_users: users_data[user.gtalk] = user if xmpp_api.isOnline(user.gtalk): users_online_list.append(user.gtalk) if user.recvOnlineMsg: users_onlinemsgon_list.append(user.gtalk) else: users_onlinemsgoff_list.append(user.gtalk) if user.recvOfflineMsg: users_offlinemsgon_list.append(user.gtalk) else: users_offlinemsgoff_list.append(user.gtalk) memcache.flush_all() memcache.set('cache_all_user_list', users_data, 43200) funcs.setConfigValueWithCache('cache_online_user_list', users_online_list) funcs.setConfigValueWithCache('cache_online_msgon_user_list', users_onlinemsgon_list) funcs.setConfigValueWithCache('cache_online_msgoff_user_list', users_onlinemsgoff_list) funcs.setConfigValueWithCache('cache_offline_msgon_user_list', users_offlinemsgon_list) funcs.setConfigValueWithCache('cache_offline_msgoff_user_list', users_offlinemsgoff_list) return 'init cache from db ok'