Skip to content

Client Script Snippets

SongSing edited this page May 7, 2014 · 4 revisions

Scripting/Client/Snippets

"Say" function

function say(message, channel) 
{ 
	if (channel === undefined) 
	{
		channel = client.currentChannel(); 
	} 
  
	client.network().sendChanMessage(channel, message); 
}

Use this function to programmatically send messages. Be cautious in doing this, however, since you can go overactive! Not passing a channel parameter will send the message to whatever channel's currently open.

Example(s): say("Wow!", channel); say("Amazing!");

GetMessage function

String.prototype.getMessage = function()
{
	if (this.indexOf(":") !== -1)
		return this.substr(this.indexOf(":") + 2);

	return this;
};

This can be used to get the actual message from the channelMessage event.

Example(s): var msg = message.getMessage();

GetUser function

String.prototype.getUser = function()
{
	return this.split(':')[0]; // users can't have colons in names
};

Gets the username from the channelMessage event.

Example(s): var user = message.getUser();