degesch: implement /ctcp, stubplement /me
This commit is contained in:
parent
a66bf15e67
commit
54262e2d20
50
degesch.c
50
degesch.c
|
@ -112,6 +112,12 @@ isdigit_ascii (int c)
|
||||||
return c >= '0' && c <= '9';
|
return c >= '0' && c <= '9';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
toupper_ascii (int c)
|
||||||
|
{
|
||||||
|
return c >= 'A' && c <= 'Z' ? c : c - ('a' - 'A');
|
||||||
|
}
|
||||||
|
|
||||||
/// Shorthand to set an error and return failure from the function
|
/// Shorthand to set an error and return failure from the function
|
||||||
#define FAIL(...) \
|
#define FAIL(...) \
|
||||||
BLOCK_START \
|
BLOCK_START \
|
||||||
|
@ -3312,6 +3318,42 @@ handle_command_notice (struct app_context *ctx, char *arguments)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
handle_command_ctcp (struct app_context *ctx, char *arguments)
|
||||||
|
{
|
||||||
|
if (!server_command_check (ctx, "send messages"))
|
||||||
|
return true;
|
||||||
|
if (!*arguments)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char *target = cut_word (&arguments);
|
||||||
|
if (!*arguments)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char *tag = cut_word (&arguments);
|
||||||
|
for (char *p = tag; *p; p++)
|
||||||
|
*p = toupper_ascii (*p);
|
||||||
|
|
||||||
|
if (*arguments)
|
||||||
|
irc_send (ctx, "PRIVMSG %s :\x01%s %s\x01", target, tag, arguments);
|
||||||
|
else
|
||||||
|
irc_send (ctx, "PRIVMSG %s :\x01%s\x01", target, tag);
|
||||||
|
|
||||||
|
buffer_send_status (ctx, ctx->server_buffer,
|
||||||
|
"CTCP query to %s: %s", target, tag);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
handle_command_me (struct app_context *ctx, char *arguments)
|
||||||
|
{
|
||||||
|
if (!server_command_check (ctx, "send messages"))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
handle_command_quit (struct app_context *ctx, char *arguments)
|
handle_command_quit (struct app_context *ctx, char *arguments)
|
||||||
{
|
{
|
||||||
|
@ -3412,10 +3454,10 @@ g_command_handlers[] =
|
||||||
"<nick> <message>" },
|
"<nick> <message>" },
|
||||||
{ "notice", handle_command_notice, "Send notice to a nick or channel",
|
{ "notice", handle_command_notice, "Send notice to a nick or channel",
|
||||||
"<target> <message>" },
|
"<target> <message>" },
|
||||||
#if 0
|
{ "ctcp", handle_command_ctcp, "Send a CTCP query",
|
||||||
{ "ctcp", NULL, "", "" },
|
"<target> <tag>" },
|
||||||
{ "me", NULL, "", "" },
|
{ "me", handle_command_me, "Send a CTCP action",
|
||||||
#endif
|
"<message>" },
|
||||||
|
|
||||||
{ "join", handle_command_join, "Join channels",
|
{ "join", handle_command_join, "Join channels",
|
||||||
"[channel...]" },
|
"[channel...]" },
|
||||||
|
|
Loading…
Reference in New Issue