bool permission_isMember(const char* name) { User* tempuser = userFromName(std::string(name)); if (tempuser == NULL) { return false; } return (IS_MEMBER(tempuser->permissions) != 0); }
bool permission_isMember(const char* name) { User* tempuser = User::byNick(name); if (tempuser == NULL) { return false; } return (IS_MEMBER(tempuser->permissions) != 0); }
void Chat::sendHelp(User* user, std::deque<std::string> args) { // TODO: Add paging support, since not all commands will fit into // the screen at once. CommandList* commandList = &m_guestCommands; // defaults std::string commandColor = MC_COLOR_BLUE; if(IS_ADMIN(user->permissions)) { commandList = &m_adminCommands; commandColor = MC_COLOR_RED; // different color for admin commands } else if(IS_OP(user->permissions)) { commandList = &m_opCommands; commandColor = MC_COLOR_GREEN; } else if(IS_MEMBER(user->permissions)) { commandList = &m_memberCommands; } if(args.size() == 0) { for(CommandList::iterator it = commandList->begin(); it != commandList->end(); it++) { std::string args = it->second->arguments; std::string description = it->second->description; sendMsg(user, commandColor + CHATCMDPREFIX + it->first + " " + args + " : " + MC_COLOR_YELLOW + description, Chat::USER); } } else { CommandList::iterator iter; if((iter = commandList->find(args.front())) != commandList->end()) { std::string args = iter->second->arguments; std::string description = iter->second->description; sendMsg(user, commandColor + CHATCMDPREFIX + iter->first + " " + args, Chat::USER); sendMsg(user, MC_COLOR_YELLOW + CHATCMDPREFIX + description, Chat::USER); } else { sendMsg(user, MC_COLOR_RED + "Unknown Command: " + args.front(), Chat::USER); } } }
void Chat::registerCommand(Command* command) { // Loop thru all the words for this command std::string currentWord; std::deque<std::string> words = command->names; while(!words.empty()) { currentWord = words[0]; words.pop_front(); if(IS_ADMIN(command->permissions)) { m_adminCommands[currentWord] = command; continue; } if(IS_OP(command->permissions)) { m_opCommands[currentWord] = command; m_adminCommands[currentWord] = command; continue; } if(IS_MEMBER(command->permissions)) { m_memberCommands[currentWord] = command; m_opCommands[currentWord] = command; m_adminCommands[currentWord] = command; continue; } if(IS_GUEST(command->permissions)) { // insert into all m_guestCommands[currentWord] = command; m_memberCommands[currentWord] = command; m_opCommands[currentWord] = command; m_adminCommands[currentWord] = command; } } }