Esempio n. 1
0
def CmdNickDo(from_name,msg):
	if GetCmdNum(msg) < 2:
		return 'need nickname'
	ret_msg = None
	nickname = GetCmdByNum(msg,2)
	if len(nickname) > 20:
		ret_msg = u'nickname %s too long(<=20)' % nickname
		return ret_msg.encode('utf-8')
	user = funcs.getUserByNickname(nickname)
	if user:
		if user.gtalk == from_name:
			ret_msg = u'your nickname is %s already.' % nickname
		else:
			ret_msg = u'nickname:%s is taken by somebody' % nickname
		return ret_msg.encode('utf-8')
	user = funcs.getUserByNameFromDb(from_name)
	if user is None:
		return 'you are not joined'
	old_name = user.nickname
	user.nickname = nickname
	user.put()
	funcs.updateUserListFromCache(user)
	
	try:
		ret_msg = u'%s change nickname to %s' % (old_name,nickname)
		funcs.broastcastMsg(ret_msg,from_name)
	except:
		pass
	ret_msg = u'you have changed nickname:%s' % nickname
	return ret_msg.encode('utf-8')
Esempio n. 2
0
def CmdNickDo(from_name, msg):
    if GetCmdNum(msg) < 2:
        return 'need nickname'
    ret_msg = None
    nickname = GetCmdByNum(msg, 2)
    if len(nickname) > 20:
        ret_msg = u'nickname %s too long(<=20)' % nickname
        return ret_msg.encode('utf-8')
    user = funcs.getUserByNickname(nickname)
    if user:
        if user.gtalk == from_name:
            ret_msg = u'your nickname is %s already.' % nickname
        else:
            ret_msg = u'nickname:%s is taken by somebody' % nickname
        return ret_msg.encode('utf-8')
    user = funcs.getUserByNameFromDb(from_name)
    if user is None:
        return 'you are not joined'
    old_name = user.nickname
    user.nickname = nickname
    user.put()
    funcs.updateUserListFromCache(user)

    try:
        ret_msg = u'%s change nickname to %s' % (old_name, nickname)
        funcs.broastcastMsg(ret_msg, from_name)
    except:
        pass
    ret_msg = u'you have changed nickname:%s' % nickname
    return ret_msg.encode('utf-8')
Esempio n. 3
0
            logging.error(sys.exc_info()[0])
            raise "under attack:" + from_name.encode("UTF-8")
            return
        from_name = xmpp_api.get_mail_name(self.request.get("from")).lower()
        msgbody = funcs.MsgBlankClean(message.body)
        e = cmddiv.MsgCheckCmd(from_name, msgbody)
        if e == "NOTCMD":
            if not funcs.isInGroupUser(from_name):
                message.reply(
                    "u r NOT in this group,pls join first,see more http://code.google.com/p/twpost/wiki/xixiguys_start"
                )
                return
            if len(msgbody) > 1024:
                message.reply("error:msg too long(<=1024)")
                return
            e = funcs.broastcastMsg(msgbody, from_name, False)
            funcs.updateUserCount(from_name)
            # funcs.Add2OnlineList(from_name)
        else:
            message.reply(str(e))


class OnlineHandler(webapp.RequestHandler):
    def post(self):
        # sender = self.request.get('from').split('/')[0]
        sender = xmpp_api.get_mail_name(self.request.get("from")).lower()
        if funcs.isInGroupUser(sender):
            funcs.addUserToOnlineUserList(sender)
            # else:
            # logging.error('error sender %s incoming online' % sender)
            # msg_str = 'Please delete me from your contacts or join us,more info at http://is.gd/xixiguys_start'
Esempio n. 4
0
            logging.error(sys.exc_info()[0])
            raise "under attack:" + from_name.encode("UTF-8")
            return
        from_name = xmpp_api.get_mail_name(self.request.get('from')).lower()
        msgbody = funcs.MsgBlankClean(message.body)
        e = cmddiv.MsgCheckCmd(from_name, msgbody)
        if e == 'NOTCMD':
            if not funcs.isInGroupUser(from_name):
                message.reply(
                    'u r NOT in this group,pls join first,see more http://code.google.com/p/twpost/wiki/xixiguys_start'
                )
                return
            if len(msgbody) > 1024:
                message.reply('error:msg too long(<=1024)')
                return
            e = funcs.broastcastMsg(msgbody, from_name, False)
            funcs.updateUserCount(from_name)
            #funcs.Add2OnlineList(from_name)
        else:
            message.reply(str(e))


class OnlineHandler(webapp.RequestHandler):
    def post(self):
        #sender = self.request.get('from').split('/')[0]
        sender = xmpp_api.get_mail_name(self.request.get('from')).lower()
        if funcs.isInGroupUser(sender):
            funcs.addUserToOnlineUserList(sender)
        #else:
        #logging.error('error sender %s incoming online' % sender)
        #msg_str = 'Please delete me from your contacts or join us,more info at http://is.gd/xixiguys_start'