Skip to content

Commit

Permalink
Core(impl): add pass command as a shortcut for quote PASS (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
Exagone313 authored Aug 28, 2024
1 parent 8258011 commit b55a273
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ Please refer to :ref:`faq-relay-message-transform` see its effect.
Pattern **SHOULD** consider the case where the mIRC color code is
included in the message.

.. _commands-quote:

/quote
------

Expand All @@ -453,6 +455,17 @@ Clear all messages in current buffer.

.. versionadded:: 1.4

/pass
------

Usage::

/pass <password>

Equivalent to using :ref:`commands-quote` `PASS <password>`.

.. versionadded:: 1.8

Obsoleted Commands
==================

Expand Down
13 changes: 13 additions & 0 deletions src/core/chat_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,19 @@ SrnRet on_command_clear(SrnCommand *cmd, void *user_data){
return SRN_OK;
}

SrnRet on_command_pass(SrnCommand *cmd, void *user_data){
SrnServer *srv;
const char *msg;

srv = ctx_get_server(user_data);
g_return_val_if_fail(srv, SRN_ERR);

msg = srn_command_get_arg(cmd, 0);
g_return_val_if_fail(msg, SRN_ERR);

return sirc_cmd_raw(srv->irc, "PASS %s\r\n", msg);
}

/*******************************************************************************
* Misc
******************************************************************************/
Expand Down
7 changes: 7 additions & 0 deletions src/core/chat_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ SrnRet on_command_render(SrnCommand *cmd, void *user_data);
SrnRet on_command_unrender(SrnCommand *cmd, void *user_data);
SrnRet on_command_quote(SrnCommand *cmd, void *user_data);
SrnRet on_command_clear(SrnCommand *cmd, void *user_data);
SrnRet on_command_pass(SrnCommand *cmd, void *user_data);

static SrnCommandBinding cmd_bindings[] = {
{
Expand Down Expand Up @@ -258,6 +259,12 @@ static SrnCommandBinding cmd_bindings[] = {
.opt = { SRN_COMMAND_EMPTY_OPT },
.cb = on_command_clear,
},
{
.name = "/pass",
.argc = 1, // <command string>
.opt = { SRN_COMMAND_EMPTY_OPT },
.cb = on_command_pass,
},
SRN_COMMAND_EMPTY,
};

Expand Down

0 comments on commit b55a273

Please sign in to comment.