hirc

[archived] IRC client
git clone https://hhvn.uk/hirc
git clone git://hhvn.uk/hirc
Log | Files | Refs

commands.h (13654B)


      1 /*
      2  * src/data/commands.h from hirc
      3  *
      4  * Copyright (c) 2021-2022 hhvn <dev@hhvn.uk>
      5  *
      6  * Permission to use, copy, modify, and distribute this software for any
      7  * purpose with or without fee is hereby granted, provided that the above
      8  * copyright notice and this permission notice appear in all copies.
      9  *
     10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     17  *
     18  */
     19 
     20 #define COMMAND(func) static void func(struct Server *server, struct Channel *channel, char *str)
     21 
     22 /* IRC commands */
     23 COMMAND(command_away);
     24 COMMAND(command_msg);
     25 COMMAND(command_notice);
     26 COMMAND(command_me);
     27 COMMAND(command_ctcp);
     28 COMMAND(command_quit);
     29 COMMAND(command_join);
     30 COMMAND(command_part);
     31 COMMAND(command_kick);
     32 COMMAND(command_mode);
     33 COMMAND(command_nick);
     34 COMMAND(command_list);
     35 COMMAND(command_whois);
     36 COMMAND(command_who);
     37 COMMAND(command_whowas);
     38 COMMAND(command_ping);
     39 COMMAND(command_quote);
     40 COMMAND(command_connect);
     41 COMMAND(command_disconnect);
     42 COMMAND(command_names);
     43 COMMAND(command_topic);
     44 COMMAND(command_motd);
     45 COMMAND(command_oper);
     46 COMMAND(command_time);
     47 COMMAND(command_stats);
     48 COMMAND(command_kill);
     49 COMMAND(command_links);
     50 COMMAND(command_map);
     51 COMMAND(command_lusers);
     52 COMMAND(command_invite);
     53 COMMAND(command_cycle);
     54 
     55 /* Channel priviledges (use modelset only) */
     56 COMMAND(command_op);
     57 COMMAND(command_voice);
     58 COMMAND(command_halfop);
     59 COMMAND(command_admin);
     60 COMMAND(command_owner);
     61 COMMAND(command_deop);
     62 COMMAND(command_devoice);
     63 COMMAND(command_dehalfop);
     64 COMMAND(command_deadmin);
     65 COMMAND(command_deowner);
     66 COMMAND(command_ban);
     67 COMMAND(command_unban);
     68 
     69 /* UI commands */
     70 COMMAND(command_query);
     71 COMMAND(command_select);
     72 COMMAND(command_set);
     73 COMMAND(command_toggle);
     74 COMMAND(command_format);
     75 COMMAND(command_server);
     76 COMMAND(command_bind);
     77 COMMAND(command_help);
     78 COMMAND(command_echo);
     79 COMMAND(command_grep);
     80 COMMAND(command_clear);
     81 COMMAND(command_alias);
     82 COMMAND(command_scroll);
     83 COMMAND(command_source);
     84 COMMAND(command_dump);
     85 COMMAND(command_close);
     86 COMMAND(command_ignore);
     87 
     88 struct Command commands[] = {
     89 	/* IRC commands */
     90 	{"away", command_away, 0, {
     91 		"usage: /away [message]",
     92 		"Set yourself as away on the server.",
     93 		"An empty message will unset the away.", NULL}},
     94 	{"msg", command_msg, 1, {
     95 		"usage: /msg <nick|channel> message..",
     96 		"Send a message to a nick or channel.",
     97 		"Will appear in buffers if already open.", NULL}},
     98 	{"notice", command_notice, 1, {
     99 		"usage: /notice <nick|channel> message..",
    100 		"Send a notice to a nick or channel.",
    101 		"Will appear in buffers if already open.", NULL}},
    102 	{"me", command_me, 2, {
    103 		"usage: /me message..",
    104 		"Send a CTCP ACTION to the selected channel/query", NULL}},
    105 	{"ctcp", command_ctcp, 1, {
    106 		"usage: /ctcp [channel|nick] <TYPE>",
    107 		"Send a CTCP request to a channel or nick", NULL}},
    108 	{"quit", command_quit, 0, {
    109 		"usage: /quit",
    110 		"Cleanup and exit", NULL}},
    111 	{"quote", command_quote, 1, {
    112 		"usage: /quote <message>",
    113 		"Send raw message to server", NULL}},
    114 	{"join", command_join, 1, {
    115 		"usage: /join <channel>",
    116 		"Join channel", NULL}},
    117 	{"part", command_part, 1, {
    118 		"usage: /part <channel> [reason]",
    119 		"Part channel", NULL}},
    120 	{"cycle", command_cycle, 1, {
    121 		"usage: /cycle <channel> [reason]",
    122 		"Part channel and rejoin", NULL}},
    123 	{"kick", command_kick, 1, {
    124 		"usage: /kick [channel] <nick> [reason]",
    125 		"Kick nick from channel", NULL}},
    126 	{"mode", command_mode, 1, {
    127 		"usage: /mode <channel> modes...",
    128 		"Set/unset channel modes", NULL}},
    129 	{"nick", command_nick, 1, {
    130 		"usage: /nick <nick>",
    131 		"Get a new nick", NULL}},
    132 	{"list", command_list, 1, {
    133 		"usage: /list",
    134 		"Get list of channels.", NULL}},
    135 	{"whois", command_whois, 1, {
    136 		"usage: /whois [server] [nick]",
    137 		"Request information on a nick or oneself", NULL}},
    138 	{"who", command_who, 1, {
    139 		"usage: /whois [mask [options]]",
    140 		"Request short information on nicks", NULL}},
    141 	{"whowas", command_whowas, 1, {
    142 		"usage: /whowas [nick [count [server]]]",
    143 		"Request information on old nicks",
    144 		"Count defaults to 5", NULL}},
    145 	{"ping", command_ping, 1, {
    146 		"usage: /ping message...",
    147 		"Send a PING to server.",
    148 		"hirc will do this itself in the background,",
    149 		"but will hide it unless this command is used.", NULL}},
    150 	{"connect", command_connect, 0, {
    151 		"usage: /connect [-network <name>] [-nick <nick>] [-user <user>]",
    152 		"                [-real <comment>] [-pass <password]",
    153 		"                [-tls] [-verify] [host] [port]",
    154 		"Connect to a network/server.",
    155 		"If no host is given, it will attempt to connect to the\n",
    156 		"selected server if it is disconnected\n",
    157 		NULL}},
    158 	{"disconnect", command_disconnect, 0, {
    159 		"usage: /disconnect [network] [msg]",
    160 		"Disconnect from a network/server", NULL}},
    161 	{"names", command_names, 1, {
    162 		"usage: /names <channel>",
    163 		"List nicks in channel (pretty useless with nicklist.", NULL}},
    164 	{"topic", command_topic, 1, {
    165 		"usage: /topic [-clear] [channel] [topic]",
    166 		"Sets, clears, or checks topic in channel.",
    167 		"Provide only channel name to check.", NULL}},
    168 	{"oper", command_oper, 1, {
    169 		"usage: /oper [user] <password>",
    170 		"Authenticate for server operator status.",
    171 		"If a user is not specified, the current nickname is used.", NULL}},
    172 	{"motd", command_motd, 1, {
    173 		"usage: /motd [server/nick]",
    174 		"Get the Message Of The Day for the current server,",
    175 		"specified server, or the server with the specified nickname.", NULL}},
    176 	{"time", command_time, 1, {
    177 		"usage: /time [server/nick]",
    178 		"Get the time and timezone of the current server,",
    179 		"specified server, or the server with the specified nickname.", NULL}},
    180 	{"stats", command_stats, 1, {
    181 		"usage: /stats [type [server]]",
    182 		"Query server statistics. Servers will usually list",
    183 		"types that can be queried if no arguments are given.", NULL}},
    184 	{"kill", command_kill, 1, {
    185 		"usage: /kill <nick> [reason]",
    186 		"Forcefully disconnect a nick from a server.",
    187 		"Uses def.killmessage if no reason provided.", NULL}},
    188 	{"links", command_links, 1, {
    189 		"usage: /links [[server] mask]",
    190 		"Request list of linked servers from the veiwpoint",
    191 		"of the current or specified server, matching the",
    192 		"specified mask.", NULL}},
    193 	{"lusers", command_lusers, 1, {
    194 		"usage: /lusers",
    195 		"Request a list of users from the server.",
    196 		"This is implemented in all servers, but",
    197 		"only some allow its request via a command.", NULL}},
    198 	{"map", command_map, 1, {
    199 		"usage: /map",
    200 		"Similar to /links but prints an ascii diagram.",
    201 		"Nonstandard feature.", NULL}},
    202 	{"invite", command_invite, 1, {
    203 		"usage: /invite <nick> [channel]",
    204 		"Invite a nick to the current or specified channel.", NULL}},
    205 	/* Channel priviledges */
    206 	{"op", command_op, 2, {
    207 		"usage: /op nicks...",
    208 		"Give a nickname +o on the current channel.", NULL}},
    209 	{"voice", command_voice, 2, {
    210 		"usage: /voice nicks...",
    211 		"Give a nickname +v on the current channel.", NULL}},
    212 	{"halfop", command_halfop, 2, {
    213 		"usage: /halfop nicks...",
    214 		"Give a nickname +h on the current channel.", NULL}},
    215 	{"admin", command_admin, 2, {
    216 		"usage: /admin nicks...",
    217 		"Give a nickname +a on the current channel.", NULL}},
    218 	{"owner", command_owner, 2, {
    219 		"usage: /owner nicks...",
    220 		"Give a nickname +q on the current channel.", NULL}},
    221 	{"deop", command_deop, 2, {
    222 		"usage: /deop nicks...",
    223 		"Remove +o for a nick on the current channel.", NULL}},
    224 	{"devoice", command_devoice, 2, {
    225 		"usage: /devoice nicks...",
    226 		"Remove +v for a nick on the current channel.", NULL}},
    227 	{"dehalfop", command_dehalfop, 2, {
    228 		"usage: /dehalfop nicks...",
    229 		"Remove +h for a nick on the current channel.", NULL}},
    230 	{"deadmin", command_deadmin, 2, {
    231 		"usage: /deadmin nicks...",
    232 		"Remove +a for a nick on the current channel.", NULL}},
    233 	{"deowner", command_deowner, 2, {
    234 		"usage: /deowner nicks...",
    235 		"Remove +q for a nick on the current channel.", NULL}},
    236 	{"ban", command_ban, 2, {
    237 		"usage: /ban masks...",
    238 		"Add masks to the +b banlist in the current channel", NULL}},
    239 	{"unban", command_unban, 2, {
    240 		"usage: /unban masks...",
    241 		"Remove masks from the banlist in the current channel", NULL}},
    242 	/* UI commands */
    243 	{"query", command_query, 1, {
    244 		"usage: /query <nick>",
    245 		"Open a buffer for communication with a nick", NULL}},
    246 	{"select", command_select, 0, {
    247 		"usage: /select [-network <name>] [-channel <name>] [buffer id]",
    248 		"Select a buffer", NULL}},
    249 	{"set",	command_set, 0, {
    250 		"usage: /set <variable> [number/range] [end of range]",
    251 		"       /set <variable> string....",
    252 		"Set a configuration variable.",
    253 		"Passing only the name prints content.", NULL}},
    254 	{"toggle", command_toggle, 0, {
    255 		"usage: /toggle <variable>",
    256 		"Toggle a boolean configuration variable on or off.", NULL}},
    257 	{"format", command_format, 0, {
    258 		"usage: /format <format> string...",
    259 		"Set a formatting variable.",
    260 		"This is equivalent to /set format.<format> string...", NULL}},
    261 	{"server", command_server, 0, {
    262 		"usage: /server [-auto] <server> [cmd....]",
    263 		"       /server [-clear] <server>",
    264 		"Evaluate a cooked command with server as target.",
    265 		" -auto  if supplied with a command, run that command",
    266 		"        automatically when the server connects.",
    267 		"        Otherwise, list autocmds that have been set.",
    268 		" -clear clear autocmds from server",
    269 		"To send a raw command to a server, use:",
    270 		" /server <server> /quote ...", NULL}},
    271 	{"bind", command_bind, 0, {
    272 		"usage: /bind [<keybind> [cmd [..]]]",
    273 		"       /bind -delete <keybind>",
    274 		"Bind command to key.",
    275 		"Accepts caret formatted control characters (eg, ^C).",
    276 		"Accepts multiple characters (alt-c = '^[c'), though",
    277 		"these must be inputted faster than wgetch can read.", NULL}},
    278 	{"help", command_help, 0, {
    279 		"usage: /help [command or variable]",
    280 		"Print help information.",
    281 		"`/help commands` and `/help variables` will list respectively", NULL}},
    282 	{"echo", command_echo, 0, {
    283 		"usage: /echo ...",
    284 		"Print temporarily to selected buffer.", NULL}},
    285 	{"grep", command_grep, 0, {
    286 		"usage: /grep [-iE] [regex]",
    287 		"Search selected buffer",
    288 		" -i   case insensitive",
    289 		" -E   posix extended regex",
    290 		" -raw search raw message rather than displayed text",
    291 		"Displays any lines that match the regex in the current buffer,",
    292 		"unless -raw is specified. For convenience, all whitespace is",
    293 		"squeezed down to one space.",
    294 		"If no argument is supplied, clears previous search.",
    295 		"Searches are also cleared after selecting another buffer.",
    296 		"See also variables: regex.extended and regex.icase", NULL}},
    297 	{"clear", command_clear, 0, {
    298 		"usage: /clear [-tmp] [-err] [-serr] [-log]",
    299 		"Clear selected buffer of messages.",
    300 		"By default all messages are cleared.",
    301 		"The following options clear only certain messages:",
    302 		" -tmp:  temporary messages - cleared when switching buffer",
    303 		" -err:  hirc generated errors",
    304 		" -serr: server generated errors",
    305 		" -log:  messages restored from log files", NULL}},
    306 	{"alias", command_alias, 0, {
    307 		"usage: /alias [<alias> [cmd [...]]]",
    308 		"       /alias -delete <alias>",
    309 		"Add or remove an alias that expands to a command.", NULL}},
    310 	{"scroll", command_scroll, 0, {
    311 		"usage: /scroll [-buflist] [-nicklist] [-|+]lines",
    312 		"Scroll a window (main by default).",
    313 		"Positive scrolls up, negative down, 0 resets and tracks",
    314 		"Probably most useful with /bind", NULL}},
    315 	{"source", command_source, 0, {
    316 		"usage: /source <file>",
    317 		"Read a config file. Can be used inside config files.", NULL}},
    318 	{"dump", command_dump, 0, {
    319 		"usage: /dump [-all] [-aliases] [-bindings] [-formats] [-config]",
    320 		"             [-default] [-servers] [-channels] [-queries] [-ignores] <file>",
    321 		"Dumps configuration details into a file.",
    322 		" -autocmds dump commands specified with /server -auto",
    323 		" -aliases  dump /alias commands",
    324 		" -bindings dump /bind commands",
    325 		" -formats  dump /format commands beginning with filter.",
    326 		" -config   dump /format options excluding filters",
    327 		" -servers  dump /server commands",
    328 		" -channels dump /join commands for respective servers",
    329 		" -queries  dump /query commands for respective servers",
    330 		" -ignores  dump /ignore commands",
    331 		" -default  dump default settings (dump non-default otherwise)",
    332 		"If none (excluding -default) of the above are selected, it is",
    333 		"treated as though all are selected.",
    334 		"If -autocmds and -channels are used together, and there exists",
    335 		"an autocmd to join a channel, then only the autocmd will be dumped.", NULL}},
    336 	{"close", command_close, 0, {
    337 		"usage: /close [id]",
    338 		"Forget about selected buffer, or a buffer by id.", NULL}},
    339 	{"ignore", command_ignore, 0, {
    340 		"usage: /ignore [[-server] [-noact] [-format format] regex]",
    341 		"       /ignore -delete id",
    342 		"       /ignore -hide|-show",
    343 		"Hide future messages matching regex.",
    344 		"Regexes should match a raw IRC message.",
    345 		"Display all rules if no argument given.",
    346 		" -show   show ignored messages",
    347 		" -hide   hide ignored messages",
    348 		" -delete delete rule with specified ID",
    349 		" -E      use extended POSIX regex",
    350 		" -i      case insensitive match",
    351 		" -server only ignore for the current server",
    352 		"         or server provided by /server.",
    353 		" -noact  set activity to Activity_ignore,",
    354 		"         but don't hide the message.",
    355 		" -format only ignore messages with >format<",
    356 		"See also: regex.extended, regex.icase", NULL}},
    357 	{NULL, NULL},
    358 };