πŸŸͺ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 the target parameter.

  • Colors are optional and must follow the IRC Color Table.

  • If a color parameter is provided, it will override the default messageColor set during connection.

  • If no color is specified in sendMessage, it will use the messageColor set in connect.

  • If neither sendMessage nor connect 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