void xfer_command_init () { dogechat_hook_command ( "me", N_("send a CTCP action to remote host"), N_("<message>"), N_("message: message to send"), NULL, &xfer_command_me, NULL); dogechat_hook_command ( "xfer", N_("xfer control"), "[list|listfull]", N_(" list: list xfer\n" "listfull: list xfer (verbose)\n" "\n" "Without argument, this command opens buffer with xfer list."), "list|listfull", &xfer_command_xfer, NULL); }
void alias_hook_command (struct t_alias *alias) { char *str_priority_name, *str_completion; int length; /* * build string with priority and name: the alias priority is 2000, which * is higher than default one (1000), so the alias is executed before a * command (if a command with same name exists in core or in another plugin) */ length = strlen (alias->name) + 16 + 1; str_priority_name = malloc (length); if (str_priority_name) snprintf (str_priority_name, length, "2000|%s", alias->name); /* * if alias has no custom completion, then default is to complete with * completion template of target command, for example if alias is * "/alias add test /buffer", then str_completion will be "%%buffer" */ str_completion = NULL; if (!alias->completion) { length = 2 + strlen (alias->command) + 1; str_completion = malloc (length); if (str_completion) { snprintf (str_completion, length, "%%%%%s", (dogechat_string_is_command_char (alias->command)) ? dogechat_utf8_next_char (alias->command) : alias->command); } } alias->hook = dogechat_hook_command ((str_priority_name) ? str_priority_name : alias->name, alias->command, NULL, NULL, (str_completion) ? str_completion : alias->completion, &alias_cb, alias); if (str_priority_name) free (str_priority_name); if (str_completion) free (str_completion); }
void exec_command_init () { dogechat_hook_command ( "exec", N_("execute external commands"), N_("-list" " || [-sh|-nosh] [-bg|-nobg] [-stdin|-nostdin] [-buffer <name>] " "[-l|-o|-n|-nf] [-cl|-nocl] [-sw|-nosw] [-ln|-noln] " "[-flush|-noflush] [-color ansi|auto|irc|dogechat|strip] [-rc|-norc] " "[-timeout <timeout>] [-name <name>] [-pipe <command>] " "[-hsignal <name>] <command>" " || -in <id> <text>" " || -inclose <id> [<text>]" " || -signal <id> <signal>" " || -kill <id>" " || -killall" " || -set <id> <property> <value>" " || -del <id>|-all [<id>...]"), N_(" -list: list commands\n" " -sh: use the shell to execute the command (WARNING: use this " "option ONLY if all arguments are safe, see option -nosh)\n" " -nosh: do not use the shell to execute the command (required if " "the command has some unsafe data, for example the content of a " "message from another user) (default)\n" " -bg: run process in background: do not display process output " "neither return code (not compatible with options -o/-n)\n" " -nobg: catch process output and display return code (default)\n" " -stdin: create a pipe for sending data to the process (with " "/exec -in/-inclose)\n" "-nostdin: do not create a pipe for stdin (default)\n" " -buffer: display/send output of command on this buffer (if the " "buffer is not found, a new buffer with name \"exec.exec.xxx\" is " "created)\n" " -l: display locally output of command on buffer (default)\n" " -o: send output of command to the buffer " "(not compatible with option -bg)\n" " -n: display output of command in a new buffer (not compatible " "with option -bg)\n" " -nf: display output of command in a new buffer with free " "content (no word-wrap, no limit on number of lines) (not compatible " "with option -bg)\n" " -cl: clear the new buffer before displaying output\n" " -nocl: append to the new buffer without clear (default)\n" " -sw: switch to the output buffer (default)\n" " -nosw: don't switch to the output buffer\n" " -ln: display line numbers (default in new buffer only)\n" " -noln: don't display line numbers\n" " -flush: display output of command in real time (default)\n" "-noflush: display output of command after its end\n" " -color: action on ANSI colors in output:\n" " ansi: keep ANSI codes as-is\n" " auto: convert ANSI colors to DogeChat/IRC (default)\n" " irc: convert ANSI colors to IRC colors\n" " dogechat: convert ANSI colors to DogeChat colors\n" " strip: remove ANSI colors\n" " -rc: display return code (default)\n" " -norc: don't display return code\n" "-timeout: set a timeout for the command (in seconds)\n" " -name: set a name for the command (to name it later with /exec)\n" " -pipe: send the output to a DogeChat/plugin command (line by " "line); if there are spaces in command/arguments, enclose them with " "double quotes; variable $line is replaced by the line (by default " "the line is added after the command, separated by a space) " "(not compatible with options -bg/-o/-n)\n" "-hsignal: send the output as a hsignal (to be used for example in " "a trigger) (not compatible with options -bg/-o/-n)\n" " command: the command to execute; if beginning with \"url:\", the " "shell is disabled and the content of URL is downloaded and sent as " "output\n" " id: command identifier: either its number or name (if set " "with \"-name xxx\")\n" " -in: send text on standard input of process\n" "-inclose: same as -in, but stdin is closed after (and text is " "optional: without text, the stdin is just closed)\n" " -signal: send a signal to the process; the signal can be an integer " "or one of these names: hup, int, quit, kill, term, usr1, usr2\n" " -kill: alias of \"-signal <id> kill\"\n" "-killall: kill all running processes\n" " -set: set a hook property (see function hook_set in plugin API " "reference)\n" "property: hook property\n" " value: new value for hook property\n" " -del: delete a terminated command\n" " -all: delete all terminated commands\n" "\n" "Default options can be set in the option " "exec.command.default_options.\n" "\n" "Examples:\n" " /exec -n ls -l /tmp\n" " /exec -n ps xu | grep dogechat\n" " /exec -n -norc url:http://pastebin.com/raw.php?i=xxxxxxxx\n" " /exec -nf -noln links -dump " "https://dogechat.org/files/doc/devel/dogechat_user.en.html\n" " /exec -o uptime\n" " /exec -pipe \"/print Machine uptime:\" uptime\n" " /exec -n tail -f /var/log/messages\n" " /exec -kill 0"), "-list" " || -sh|-nosh|-bg|-nobg|-stdin|-nostdin|-buffer|-l|-o|-n|-nf|" "-cl|-nocl|-sw|-nosw|-ln|-noln|-flush|-noflush|-color|-timeout|-name|" "-pipe|-hsignal|%*" " || -in|-inclose|-signal|-kill %(exec_commands_ids)" " || -killall" " || -set %(exec_commands_ids) stdin|stdin_close|signal" " || -del %(exec_commands_ids)|-all %(exec_commands_ids)|%*", &exec_command_exec, NULL); }