X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Fsilc%2Flocal_command.c;h=2f18ae0344ff747b12bb170a2dcb5c03c7130f2b;hb=f9a39597892c325e87a15255f346bf126760c486;hp=b32f07f4da9aa802ec673a0b4353bb20a5b11a6e;hpb=63a7856091eaaaa598a7dd1ad32aba8b219c591b;p=silc.git diff --git a/apps/silc/local_command.c b/apps/silc/local_command.c index b32f07f4..2f18ae03 100644 --- a/apps/silc/local_command.c +++ b/apps/silc/local_command.c @@ -33,6 +33,7 @@ SilcClientCommand silc_local_command_list[] = SILC_CLIENT_LCMD(away, AWAY, "AWAY", 0, 2), SILC_CLIENT_LCMD(key, KEY, "KEY", 0, 7), SILC_CLIENT_LCMD(me, ME, "ME", 0, 3), + SILC_CLIENT_LCMD(notice, NOTICE, "NOTICE", 0, 3), { NULL, 0, NULL, 0, 0 }, }; @@ -741,3 +742,51 @@ SILC_CLIENT_LCMD_FUNC(me) out: silc_client_command_free(cmd); } + +/* Sends an notice to the channel. */ + +SILC_CLIENT_LCMD_FUNC(notice) +{ + SilcClientCommandContext cmd = (SilcClientCommandContext)context; + SilcClientConnection conn = cmd->conn; + SilcClient client = cmd->client; + SilcChannelEntry channel_entry; + char *name; + + if (!cmd->conn) { + silc_say(client, conn, + "You are not connected to a server, use /SERVER to connect"); + goto out; + } + + if (cmd->argc < 3) { + silc_say(client, conn, "Usage: /ME "); + goto out; + } + + if (cmd->argv[1][0] == '*') { + if (!conn->current_channel) { + cmd->client->ops->say(cmd->client, conn, "You are not on any channel"); + goto out; + } + name = conn->current_channel->channel_name; + } else { + name = cmd->argv[1]; + } + + channel_entry = silc_client_get_channel(client, conn, name); + if (!channel_entry) { + silc_say(client, conn, "You are not on that channel"); + goto out; + } + + /* Send the action message */ + silc_client_send_channel_message(client, conn, channel_entry, NULL, + SILC_MESSAGE_FLAG_NOTICE, + cmd->argv[2], cmd->argv_lens[2], TRUE); + + silc_print(client, "- %s %s", conn->nickname, cmd->argv[2]); + + out: + silc_client_command_free(cmd); +}