예제 #1
0
파일: cmddo.py 프로젝트: xixitalk/xixiguys
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'
예제 #2
0
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
예제 #3
0
파일: funcs.py 프로젝트: xixitalk/xixiguys
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
예제 #4
0
파일: funcs.py 프로젝트: xixitalk/xixiguys
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)
예제 #5
0
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)
예제 #6
0
파일: cmddo.py 프로젝트: jn7163/xixiguys
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'