mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-19 00:26:22 +00:00
Add command command
Initial commit to test commands API
This commit is contained in:
@@ -2298,6 +2298,21 @@ static struct cmd_t command_defs[] =
|
||||
CMD_EXAMPLES(
|
||||
"/export /path/to/output.csv",
|
||||
"/export ~/contacts.csv")
|
||||
},
|
||||
|
||||
{ "/command",
|
||||
parse_args, 1, 1, NULL,
|
||||
CMD_NOSUBFUNCS
|
||||
CMD_MAINFUNC(cmd_command)
|
||||
CMD_NOTAGS
|
||||
CMD_SYN(
|
||||
"/command <cmd>")
|
||||
CMD_DESC(
|
||||
"Execute an ad hoc command")
|
||||
CMD_ARGS(
|
||||
{ "<cmd>", "Command to be executed" })
|
||||
CMD_EXAMPLES(
|
||||
"/command ping")
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -7469,6 +7469,29 @@ cmd_encwarn(ProfWin *window, const char *const command, gchar **args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_command(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
jabber_conn_status_t conn_status = connection_get_status();
|
||||
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You are not currently connected.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (args[0] == NULL && connection_supports(XMPP_FEATURE_COMMANDS) == FALSE) {
|
||||
cons_show("Server does not support ad hoc commands.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
|
||||
iq_send_command(mucwin->roomjid, args[0]);
|
||||
|
||||
cons_show("Execute %s...", args[0]);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_cmd_execute(ProfWin *window, const char *const command, const char *const inp)
|
||||
{
|
||||
|
||||
@@ -158,6 +158,7 @@ gboolean cmd_script(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_export(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_charset(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_console(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_command(ProfWin *window, const char *const command, gchar **args);
|
||||
|
||||
gboolean cmd_plugins(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_plugins_sourcepath(ProfWin *window, const char *const command, gchar **args);
|
||||
|
||||
Reference in New Issue
Block a user