def CmdPasswordDo(from_name,msg): if GetCmdNum(msg) == 1: if funcs.isHavePassword(): passwd = funcs.getPassword() ret_str = u'password:%s' % passwd return ret_str.encode('utf-8') else: return 'no password' if not funcs.isAdmin(from_name): return 'you are not administrator' if GetCmdNum(msg) == 2: cmd = GetCmdByNum(msg,2) if cmd == 'del': funcs.delPassword() return 'delete password sucess' else: return 'cmd para error ' if GetCmdNum(msg) == 3: cmd = GetCmdByNum(msg,2) passwd = GetCmdByNum(msg,3) if cmd=='set' and passwd: funcs.setPassword(passwd) ret_str = u'set password:%s sucess' % passwd return ret_str.encode('utf-8') return 'cmd para error '
def CmdPasswordDo(from_name, msg): if GetCmdNum(msg) == 1: if funcs.isHavePassword(): passwd = funcs.getPassword() ret_str = u'password:%s' % passwd return ret_str.encode('utf-8') else: return 'no password' if not funcs.isAdmin(from_name): return 'you are not administrator' if GetCmdNum(msg) == 2: cmd = GetCmdByNum(msg, 2) if cmd == 'del': funcs.delPassword() return 'delete password sucess' else: return 'cmd para error ' if GetCmdNum(msg) == 3: cmd = GetCmdByNum(msg, 2) passwd = GetCmdByNum(msg, 3) if cmd == 'set' and passwd: funcs.setPassword(passwd) ret_str = u'set password:%s sucess' % passwd return ret_str.encode('utf-8') return 'cmd para error '
def CmdJoinDo(from_name,msg): if funcs.isInBalckList(from_name): return 'you are in black list,contact administrator' if funcs.isHavePassword() and not funcs.isInWhiteList(from_name): if GetCmdNum(msg) != 3: if not funcs.isInGroupUser(from_name): ret_str = '%s was trying to join group' % from_name funcs.sendMsgToAdminUsers(ret_str) return 'ERROR:this group need password!' passwd = GetCmdByNum(msg,3) if not funcs.checkPassword(passwd): if not funcs.isInGroupUser(from_name): ret_str = '%s was trying to join group' % from_name funcs.sendMsgToAdminUsers(ret_str) return 'ERROR:group password not correct!' if GetCmdNum(msg) < 2: return 'need nickname' nickname = GetCmdByNum(msg,2) user = funcs.getUserByNickname(nickname) if user: return 'nickname:%s is taken by somebody' % nickname user = funcs.getUserByName(from_name) if user: return 'you have been joined already' funcs.userJoin(from_name,nickname) ret_msg = u'welcome %s joined this group' % nickname funcs.Broadcast(ret_msg) return 'you join successfully'
def CmdJoinDo(from_name, msg): if funcs.isInBalckList(from_name): return 'you are in black list,contact administrator' if funcs.isHavePassword() and not funcs.isInWhiteList(from_name): if GetCmdNum(msg) != 3: if not funcs.isInGroupUser(from_name): ret_str = '%s was trying to join group' % from_name funcs.sendMsgToAdminUsers(ret_str) return 'ERROR:this group need password!' passwd = GetCmdByNum(msg, 3) if not funcs.checkPassword(passwd): if not funcs.isInGroupUser(from_name): ret_str = '%s was trying to join group' % from_name funcs.sendMsgToAdminUsers(ret_str) return 'ERROR:group password not correct!' if GetCmdNum(msg) < 2: return 'need nickname' nickname = GetCmdByNum(msg, 2) user = funcs.getUserByNickname(nickname) if user: return 'nickname:%s is taken by somebody' % nickname user = funcs.getUserByName(from_name) if user: return 'you have been joined already' funcs.userJoin(from_name, nickname) ret_msg = u'welcome %s joined this group' % nickname funcs.Broadcast(ret_msg) return 'you join successfully'