Skip to content

Commands

Julien edited this page Mar 6, 2019 · 2 revisions

Commands

libtwirc comes with a large number of functions that allow you to easily send commands to the Twitch IRC server. All of these functions return 0 on success and -1 on error. Note, however, that success and error do not indicate whether the command was processed by the server, but simply whether or not libtwirc managed to send the command in the first place.

twirc_cmd_raw()

This just sends your message to the server as-is. Well, it does add the line break required by IRC at the end.

int twirc_cmd_raw(twirc_state_t *s, const char *msg)

twirc_cmd_pass()

This sends the PASS command to the server, which is used for authentication. libtwirc initiates authentication automatically for you once the connection has been established, so there should be no reason for you to use this.

int twirc_cmd_pass(twirc_state_t *s, const char *pass)

twirc_cmd_nick()

This sends the NICK command to the server, which is used for authentication. libtwirc initiates authentication automatically for you once the connection has been established, so there should be no reason for you to use this.

int twirc_cmd_nick(twirc_state_t *s, const char *nick)

twirc_cmd_join()

Attempts to join the specified channel. chan needs to include the leading pound character, as in #channel.

int twirc_cmd_join(twirc_state_t *s, const char *chan)

twirc_cmd_part()

Attempts to leave the specified channel. chan needs to include the leading pound character, as in #channel.

int twirc_cmd_part(twirc_state_t *s, const char *chan)

twirc_cmd_ping()

Sends a PING to the server. param is optional.

int twirc_cmd_ping(twirc_state_t *s, const char *param)

twirc_cmd_pong()

Sends a PONG to the server. param is optional. If given, if will be prefixed with :. You should not need to use this, as libtwirc will automatically reply to PING message from the server for you.

int twirc_cmd_pong(twirc_state_t *s, const char *param)

twirc_cmd_quit()

Sends the QUIT command to the server. The server will usually close the connection in reaction to this. It should always be send when we want to disconnect. However, if you use twirc_disconnect() or twirc_kill(), then libtwirc will send this command for you automatically.

int twirc_cmd_quit(twirc_state_t *s)

twirc_cmd_privmsg()

Sends the given chat message to the specified channel. chan needs to include the leading pound sign.

int twirc_cmd_privmsg(twirc_state_t *s, const char *chan, const char *msg)

twirc_cmd_action()

Sends the given chat message to the specified channel, as if it had been sent with the /me command. chan needs to include the leading pound sign.

int twirc_cmd_action(twirc_state_t *s, const char *chan, const char *msg)

twirc_cmd_whisper()

Sends the msg as whisper to the specified user. Note, however, that Twitch sometimes prevents bots from doing this in order to avoid spam.

int twirc_cmd_whisper(twirc_state_t *s, const char *nick, const char *msg)

twirc_cmd_req_tags()

Requests the tags capability from the server. libtwirc does this automatically once the connection has been established, so you should not need this.

int twirc_cmd_req_tags(twirc_state_t *s)

twirc_cmd_req_membership()

Requests the membership capability from the server. libtwirc does this automatically once the connection has been established, so you should not need this.

int twirc_cmd_req_membership(twirc_state_t *s)

twirc_cmd_req_commands()

Requests the commands capability from the server. libtwirc does this automatically once the connection has been established, so you should not need this.

int twirc_cmd_req_commands(twirc_state_t *s)

twirc_cmd_mods()

Sends the /mods command to the specified channel. chan needs to include the leading pound sign.

int twirc_cmd_mods(twirc_state_t *s, const char *chan)

twirc_cmd_vips()

Sends the /vips command to the specified channel. chan needs to include the leading pound sign.

int twirc_cmd_vips(twirc_state_t *s, const char *chan)

twirc_cmd_color()

Sends the /color command to the server. This will change your chat color to the specified color, if you have the permission. color can be either a hex color or a named color, please check the Twitch docs for further details.

int twirc_cmd_color(twirc_state_t *s, const char *color)

twirc_cmd_delete()

Sends the /delete message to the specified channel. This will delete the message with the UUID id, given that you have the permission to do this.

int twirc_cmd_delete(twirc_state_t *s, const char *chan, const char *id)

twirc_cmd_timeout()

Times out the specified user in the given channel for secs seconds. reason is optional. Only works if you have the required permissions.

int twirc_cmd_timeout(twirc_state_t *s, const char *chan, const char *nick, int secs, const char *reason)

twirc_cmd_untimeout()

Remove the timeout for the specified user in the specified channel, granted that you have the permissions for this.

int twirc_cmd_untimeout(twirc_state_t *s, const char *chan, const char *nick)

twirc_cmd_ban()

Ban the specified user in the specified channel. reason is optional. Required appropriate permissions.

int twirc_cmd_ban(twirc_state_t *s, const char *chan, const char *nick, const char *reason)

twirc_cmd_unban()

Un-ban the specified user in the specified channel, given that you have permissions to do so.

int twirc_cmd_unban(twirc_state_t *s, const char *chan, const char *nick)

twirc_cmd_slow()

Activates slow mode in the specified channel. User will only be able to send messages every secs seconds. Requires appropriate permissions.

int twirc_cmd_slow(twirc_state_t *s, const char *chan, int secs)

twirc_cmd_slowoff()

Deactivates slow mode in the specified channel. Requires appropriate permissions.

int twirc_cmd_slowoff(twirc_state_t *s, const char *chan)

twirc_cmd_followers()

Activates followers only mode in the specified channel. Only user who are followers for the specified time will be able to chat. Consult the Twitch docs for details. Requires appropriate permissions.

int twirc_cmd_followers(twirc_state_t *s, const char *chan, const char *time)

twirc_cmd_followersoff()

Deactivates followers only mode in the specified channel. Requires appropriate permissions.

int twirc_cmd_followersoff(twirc_state_t *s, const char *chan)

twirc_cmd_subscribers()

Activates sub only mode in the specified channel. Only subscribers will be able to chat. Requires appropriate permissions.

int twirc_cmd_subscribers(twirc_state_t *s, const char *chan)

twirc_cmd_subscribersoff()

Deactivates sub only mode in the specified channel. Requires appropriate permissions.

int twirc_cmd_subscribersoff(twirc_state_t *s, const char *chan)

twirc_cmd_clear()

Clear the chat history in the specified channel, given that you have permissions to do so. Notice, however, that this just sends a CLEARCHAT command to all clients. Whether the clients actually remove the messages is entirely up to them.

int twirc_cmd_clear(twirc_state_t *s, const char *chan)

twirc_cmd_r9k()

Activates r9kbeta mode in the given channel, given that you have the permissions to do so. Consult the Twitch docs for more information on r9kbeta mode.

int twirc_cmd_r9k(twirc_state_t *s, const char *chan)

twirc_cmd_r9koff()

Deactivates r9kbeta mode in the given channel, given that you have the permissions to do so.

int twirc_cmd_r9koff(twirc_state_t *s, const char *chan)

twirc_cmd_emoteonly()

Activates emote-only mode in the given channel, given that you have the permissions to do so.

int twirc_cmd_emoteonly(twirc_state_t *s, const char *chan)

twirc_cmd_emoteonlyoff()

Deactivates emote-only mode in the given channel, given that you have the permissions to do so.

int twirc_cmd_emoteonlyoff(twirc_state_t *s, const char *chan)

twirc_cmd_commercial()

int twirc_cmd_commercial(twirc_state_t *s, const char *chan, int secs)

twirc_cmd_host()

int twirc_cmd_host(twirc_state_t *s, const char *chan, const char *target)

twirc_cmd_unhost()

int twirc_cmd_unhost(twirc_state_t *s, const char *chan)

twirc_cmd_mod()

int twirc_cmd_mod(twirc_state_t *s, const char *chan, const char *nick)

twirc_cmd_unmod()

int twirc_cmd_unmod(twirc_state_t *s, const char *chan, const char *nick)

twirc_cmd_vip()

int twirc_cmd_vip(twirc_state_t *s, const char *chan, const char *nick)

twirc_cmd_unvip()

int twirc_cmd_unvip(twirc_state_t *s, const char *chan, const char *nick)

twirc_cmd_marker()

int twirc_cmd_marker(twirc_state_t *s, const char *chan, const char *comment)