summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-09-28 19:17:21 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-09-28 19:46:18 +0200
commit64ac8cc14003a31ae21d28e7f37a7d9c8ed638fe (patch)
tree63bd7b1ff7a7ed106dcc4c1b4810ef84dc48e8ae /src
parent2aeae3f13c82d36bd1b9dae695f43ef3fea44d85 (diff)
downloadcmumble-64ac8cc14003a31ae21d28e7f37a7d9c8ed638fe.tar.gz
cmumble-64ac8cc14003a31ae21d28e7f37a7d9c8ed638fe.tar.bz2
cmumble-64ac8cc14003a31ae21d28e7f37a7d9c8ed638fe.zip
Support sending TextMessages
Diffstat (limited to 'src')
-rw-r--r--src/commands.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/commands.c b/src/commands.c
index 40908b4..fa2fa23 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -64,11 +64,42 @@ help(struct cmumble_context *ctx,
ctx->commands[i].name, ctx->commands[i].description);
}
+static void
+msg(struct cmumble_context *ctx,
+ int argc, char **argv)
+{
+ MumbleProto__TextMessage message;
+
+ mumble_proto__text_message__init(&message);
+ message.actor = ctx->session;
+
+ if (argc < 2) {
+ g_print("usage: msg message\n");
+ return;
+ }
+
+ message.message = argv[argc-1];
+
+ /* FIXME: cache this in general somehow? */
+ if (!ctx->user || !ctx->user->channel) {
+ g_printerr("No information about current CHannel available\n");
+ return;
+ }
+
+ message.n_channel_id = 1;
+ message.channel_id = (uint32_t[]) { ctx->user->channel->id };
+ message.n_session = 0;
+ message.n_tree_id = 0;
+
+ cmumble_send_msg(ctx, &message.base);
+}
+
static const struct cmumble_command commands[] = {
{ "lu", list_users, "list users" },
{ "lc", list_channels, "list channels" },
{ "clear", clear, "clear screen" },
{ "help", help, "show this help" },
+ { "msg", msg, "send a text message" },
{ "quit", quit, "quit " PACKAGE },
{ NULL, NULL , NULL}
};