πͺsendMessage
The sendMessage
method allows the bot to send a message to a specific IRC channel or user.
Syntax
bot.sendMessage(target, message, color);
Parameters
target
(string, required) β The channel (e.g.,#channelname
) or username to send the message to.message
(string, required) β The content of the message.color
(string, optional) β The color of the message, based on the IRC Color Table.
Example Usage
Send a message to a channel:
bot.sendMessage('#YOUR-CHANNEL', 'Hello, IRC! MyBotNickname has joined.', 'red');
Send a private message to a user:
bot.sendMessage('NICKNAME', 'Hello, IRC! MyBotNickname has joined.');
Notes
Messages sent to a channel should begin with
#
in thetarget
parameter.Colors are optional and must follow the IRC Color Table.
If a
color
parameter is provided, it will override the defaultmessageColor
set during connection.If no
color
is specified insendMessage
, it will use themessageColor
set inconnect
.If neither
sendMessage
norconnect
specify a color, the default IRC color will be used.Ensure the bot has the necessary permissions to send messages in the channel.
Last updated