Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Mod away command

Frug edited this page Oct 11, 2012 · 1 revision

There are currently two versions of the away (afk) command created as modifications for AJAX Chat. Both versions allow users to type the command "/afk" and will change their name in the chat list to indicate this status by adding a tag of some kind.

Version 1: Automatically remove status.
This version will remove the afk status of a user the next time the user types a message (or private message).
Open lib/class/CustomAJAXChat.php and add the following before the last closing bracket } at the end of the file:

	function onNewMessage($text) {
		// Reset AFK status on first inserted message:
		if($this->getSessionVar('AwayFromKeyboard')) {
			$this->setUserName($this->subString($this->getUserName(), 6));
			$this->updateOnlineList();
			$this->addInfoMessage($this->getUserName(), 'userName');
			$this->setSessionVar('AwayFromKeyboard', false);
		}
		return true;
	}

Version 2: Wait for /online.
This version will remove the afk status of a user only when the user types /online.
Open lib/class/CustomAJAXChat.php and add the following inside the function parseCustomCommands:

case '/away':
		$this->insertChatBotMessage($this->getChannel(), $this->getLoginUserName().' has set their status to Away');
		$this->setUserName($this->getLoginUserName().'[Away]');
		$this->updateOnlineList();
		$this->addInfoMessage($this->getUserName(), 'userName');
		return true;
	case '/online':
		$this->insertChatBotMessage($this->getChannel(), $this->getLoginUserName().' has set their status to Online');
		$this->setUserName($this->getLoginUserName());
		$this->updateOnlineList();
		$this->addInfoMessage($this->getUserName(), 'userName');
		return true;

Credit for the second version to KID52.