aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/chat_input
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui/chat_input')
-rw-r--r--main/src/ui/chat_input/view.vala34
1 files changed, 25 insertions, 9 deletions
diff --git a/main/src/ui/chat_input/view.vala b/main/src/ui/chat_input/view.vala
index d8a31a22..a7c3099c 100644
--- a/main/src/ui/chat_input/view.vala
+++ b/main/src/ui/chat_input/view.vala
@@ -52,30 +52,46 @@ public class View : Box {
private void send_text() {
string text = text_input.buffer.text;
+ text_input.buffer.text = "";
if (text.has_prefix("/")) {
string[] token = text.split(" ", 2);
switch(token[0]) {
- case "/kick":
- stream_interactor.get_module(MucManager.IDENTITY).kick(conversation.account, conversation.counterpart, token[1]);
- break;
case "/me":
- stream_interactor.get_module(MessageProcessor.IDENTITY).send_message(text, conversation);
+ // Just send as is.
+ break;
+ case "/say":
+ if (token.length == 1) return;
+ text = token[1];
break;
+ case "/kick":
+ stream_interactor.get_module(MucManager.IDENTITY).kick(conversation.account, conversation.counterpart, token[1]);
+ return;
case "/nick":
stream_interactor.get_module(MucManager.IDENTITY).change_nick(conversation.account, conversation.counterpart, token[1]);
- break;
+ return;
case "/ping":
Xmpp.Core.XmppStream? stream = stream_interactor.get_stream(conversation.account);
stream.get_module(Xmpp.Xep.Ping.Module.IDENTITY).send_ping(stream, conversation.counterpart.to_string() + "/" + token[1], null);
- break;
+ return;
case "/topic":
stream_interactor.get_module(MucManager.IDENTITY).change_subject(conversation.account, conversation.counterpart, token[1]);
+ return;
+ default:
+ if (token[0].has_prefix("//")) {
+ text = text.substring(1);
+ } else {
+ string cmd_name = token[0].substring(1);
+ Dino.Application app = GLib.Application.get_default() as Dino.Application;
+ if (app != null && app.plugin_registry.text_commands.has_key(cmd_name)) {
+ string? new_text = app.plugin_registry.text_commands[cmd_name].handle_command(token[1], conversation);
+ if (new_text == null) return;
+ text = (!)new_text;
+ }
+ }
break;
}
- } else {
- stream_interactor.get_module(MessageProcessor.IDENTITY).send_message(text, conversation);
}
- text_input.buffer.text = "";
+ stream_interactor.get_module(MessageProcessor.IDENTITY).send_message(text, conversation);
}
private bool on_text_input_key_press(EventKey event) {