localCHANNEL_HELP=7localmuted=Condition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT)
muted:setParameter(CONDITION_PARAM_SUBID, CHANNEL_HELP)
muted:setParameter(CONDITION_PARAM_TICKS, 3600000)
functiononSpeak(player, type, message)
localplayerAccountType=player:getAccountType()
localplayerLevel=player:getLevel()
ifplayerLevel==1andplayerAccountType==ACCOUNT_TYPE_NORMALthenplayer:sendCancelMessage("You may not speak into channels as long as you are on level 1.")
returnfalseendifplayer:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP) thenplayer:sendCancelMessage("You are muted from the Help channel for using it inappropriately.")
returnfalseendlocalplayerName=player:getName()
ifplayerAccountType>=ACCOUNT_TYPE_TUTORthenifstring.sub(message, 1, 6) =="!mute " thenlocaltargetName=string.sub(message, 7)
localtarget=Player(targetName)
iftargetthenifplayerAccountType>target:getAccountType() thenifnottarget:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP) thentarget:addCondition(muted)
sendChannelMessage(CHANNEL_HELP, TALKTYPE_CHANNEL_R1, target:getName() .." has been muted by " ..playerName.." for using Help Channel inappropriately.")
elseplayer:sendCancelMessage("That player is already muted.")
endelseplayer:sendCancelMessage("You are not authorized to mute that player.")
endelseplayer:sendCancelMessage(RETURNVALUE_PLAYERWITHTHISNAMEISNOTONLINE)
endreturnfalseelseifstring.sub(message, 1, 8) =="!unmute " thenlocaltargetName=string.sub(message, 9)
localtarget=Player(targetName)
iftargetthenifplayerAccountType>target:getAccountType() theniftarget:getCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP) thentarget:removeCondition(CONDITION_CHANNELMUTEDTICKS, CONDITIONID_DEFAULT, CHANNEL_HELP)
sendChannelMessage(CHANNEL_HELP, TALKTYPE_CHANNEL_R1, target:getName() .." has been unmuted by " ..playerName..".")
elseplayer:sendCancelMessage("That player is not muted.")
endelseplayer:sendCancelMessage("You are not authorized to unmute that player.")
endelseplayer:sendCancelMessage(RETURNVALUE_PLAYERWITHTHISNAMEISNOTONLINE)
endreturnfalseendendiftype==TALKTYPE_CHANNEL_YthenifplayerAccountType>=ACCOUNT_TYPE_TUTORorplayer:hasFlag(PlayerFlag_TalkOrangeHelpChannel) thentype=TALKTYPE_CHANNEL_Oendelseiftype==TALKTYPE_CHANNEL_OthenifplayerAccountType<ACCOUNT_TYPE_TUTORandnotplayer:hasFlag(PlayerFlag_TalkOrangeHelpChannel) thentype=TALKTYPE_CHANNEL_Yendelseiftype==TALKTYPE_CHANNEL_R1thenifplayerAccountType<ACCOUNT_TYPE_GAMEMASTERandnotplayer:hasFlag(PlayerFlag_CanTalkRedChannel) thenifplayerAccountType>=ACCOUNT_TYPE_TUTORorplayer:hasFlag(PlayerFlag_TalkOrangeHelpChannel) thentype=TALKTYPE_CHANNEL_Oelsetype=TALKTYPE_CHANNEL_YendendendlocalescapedName=db.escapeString(playerName)
localgroupId=player:getGroup():getId()
localmessage=db.escapeString(words)
db.asyncQuery(("INSERT INTO `help_ingame` (`name`, `level`, `group_id`, `message`) VALUES (%s, %d, %d, %s);"):format(escapedName, playerLevel, groupId, message))
returntypeend
Starting the bot up
Install NodeJS, on Ubuntu or Debian you can do so via sudo apt install nodejs
Install the Node Package Manager (NPM) via sudo apt install npm
Install PM2, like so npm install pm2 -g
Start the bot like so pm2 start bot.js --name "help-bot"