[smuxi] Engine: implemented engine command hooks (closes: #453)



commit f7d4c0742f3933158fb1499ac9be113186965a61
Author: Mirco Bauer <meebey meebey net>
Date:   Mon May 12 01:01:02 2014 +0200

    Engine: implemented engine command hooks (closes: #453)

 src/Engine/Session.cs |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/Engine/Session.cs b/src/Engine/Session.cs
index 158206d..57c325e 100644
--- a/src/Engine/Session.cs
+++ b/src/Engine/Session.cs
@@ -453,6 +453,30 @@ namespace Smuxi.Engine
                         CommandEcho(cd);
                         handled = true;
                         break;
+                    default:
+                        var filteredCmd = IOSecurity.GetFilteredPath(cd.Command);
+                        var hooks = new HookRunner("engine", "session",
+                                                   "command-" + filteredCmd);
+                        var pm = cd.Chat.ProtocolManager;
+                        hooks.Environments.Add(new CommandHookEnvironment(cd));
+                        hooks.Environments.Add(new ChatHookEnvironment(cd.Chat));
+                        if (pm != null) {
+                            hooks.Environments.Add(new ProtocolManagerHookEnvironment(pm));
+                        }
+
+                        var cmdChar = (string) UserConfig["Interface/Entry/CommandCharacter"];
+                        hooks.Commands.Add(new SessionHookCommand(this, cd.Chat, cmdChar));
+                        if (pm != null) {
+                            hooks.Commands.Add(new ProtocolManagerHookCommand(pm, cd.Chat, cmdChar));
+                        }
+
+                        // show time
+                        hooks.Init();
+                        if (hooks.HasHooks) {
+                            hooks.Run();
+                            handled = true;
+                        }
+                        break;
                 }
             } else {
                 // normal text


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]