public void RegisterEvents(IJinxBotClient profileClient)
        {
            m_client = profileClient;

            m_client.Client.RegisterWhisperReceivedNotification(Priority.Low, client_WhisperReceived);
            m_client.Client.RegisterWhisperSentNotification(Priority.Low, client_WhisperSent);
        }
Example #2
0
 public JsJinxBotClientObjectInstance(IJinxBotClient client, JsHost js, ScriptEngine engine)
     : base(engine.Object.InstancePrototype)
 {
     this.PopulateFunctions();
     this._client = client;
     _js          = js;
     _engine      = engine;
 }
Example #3
0
 public JsJinxBotClientObjectInstance(IJinxBotClient client, JsHost js, ScriptEngine engine)
     : base(engine.Object.InstancePrototype)
 {
     this.PopulateFunctions();
     this._client = client;
     _js = js;
     _engine = engine;
 }
Example #4
0
        protected virtual void ResetScriptEngine(ScriptSource source, IJinxBotClient client)
        {
            _jsEngine = new ScriptEngine();
            _host = new JsHost(_jsEngine, client);
            _jsEngine.Execute(source);

            __accountCreated = GetFunc("accountCreated");
            __accountCreationFailed = GetFunc("accountCreationFailed");
            __adChanged = GetFunc("adChanged");
            __channelDidNotExist = GetFunc("channelDidNotExist");
            __channelListReceived = GetFunc("channelListReceived");
            __channelWasFull = GetFunc("channelWasFull");
            __channelWasRestricted = GetFunc("channelWasRestricted");
            __clientCheckFailed = GetFunc("clientCheckFailed");
            __clientCheckPassed = GetFunc("clientCheckPassed");
            __commandSent = GetFunc("commandSent");
            __connected = GetFunc("connected");
            __disconnected = GetFunc("disconnected");
            __enteredChat = GetFunc("enteredChat");
            __error = GetFunc("error");
            __friendAdded = GetFunc("friendAdded");
            __friendListReceived = GetFunc("friendListReceived");
            __friendMoved = GetFunc("friendMoved");
            __friendRemoved = GetFunc("friendRemoved");
            __friendUpdated = GetFunc("friendUpdated");
            __information = GetFunc("information");
            __informationReceived = GetFunc("informationReceived");
            __joinedChannel = GetFunc("joinedChannel");
            __loginFailed = GetFunc("loginFailed");
            __loginSucceeded = GetFunc("loginSucceeded");
            __messageSent = GetFunc("messageSent");
            __profileLookupFailed = GetFunc("profileLookupFailed");
            __serverBroadcast = GetFunc("serverBroadcast");
            __serverErrorReceived = GetFunc("serverErrorReceived");
            __serverNews = GetFunc("serverNews");
            __userEmoted = GetFunc("userEmoted");
            __userFlagsChanged = GetFunc("userFlagsChanged");
            __userJoined = GetFunc("userJoined");
            __userLeft = GetFunc("userLeft");
            __userProfileReceived = GetFunc("userProfileReceived");
            __userShown = GetFunc("userShown");
            __userSpoke = GetFunc("userSpoke");
            __warcraftProfileReceived = GetFunc("warcraftProfileReceived");
            __whisperReceived = GetFunc("whisperReceived");
            __whisperSent = GetFunc("whisperSent");
        }
Example #5
0
        protected virtual void ResetScriptEngine(ScriptSource source, IJinxBotClient client)
        {
            _jsEngine = new ScriptEngine();
            _host     = new JsHost(_jsEngine, client);
            _jsEngine.Execute(source);

            __accountCreated        = GetFunc("accountCreated");
            __accountCreationFailed = GetFunc("accountCreationFailed");
            __adChanged             = GetFunc("adChanged");
            __channelDidNotExist    = GetFunc("channelDidNotExist");
            __channelListReceived   = GetFunc("channelListReceived");
            __channelWasFull        = GetFunc("channelWasFull");
            __channelWasRestricted  = GetFunc("channelWasRestricted");
            __clientCheckFailed     = GetFunc("clientCheckFailed");
            __clientCheckPassed     = GetFunc("clientCheckPassed");
            __commandSent           = GetFunc("commandSent");
            __connected             = GetFunc("connected");
            __disconnected          = GetFunc("disconnected");
            __enteredChat           = GetFunc("enteredChat");
            __error                   = GetFunc("error");
            __friendAdded             = GetFunc("friendAdded");
            __friendListReceived      = GetFunc("friendListReceived");
            __friendMoved             = GetFunc("friendMoved");
            __friendRemoved           = GetFunc("friendRemoved");
            __friendUpdated           = GetFunc("friendUpdated");
            __information             = GetFunc("information");
            __informationReceived     = GetFunc("informationReceived");
            __joinedChannel           = GetFunc("joinedChannel");
            __loginFailed             = GetFunc("loginFailed");
            __loginSucceeded          = GetFunc("loginSucceeded");
            __messageSent             = GetFunc("messageSent");
            __profileLookupFailed     = GetFunc("profileLookupFailed");
            __serverBroadcast         = GetFunc("serverBroadcast");
            __serverErrorReceived     = GetFunc("serverErrorReceived");
            __serverNews              = GetFunc("serverNews");
            __userEmoted              = GetFunc("userEmoted");
            __userFlagsChanged        = GetFunc("userFlagsChanged");
            __userJoined              = GetFunc("userJoined");
            __userLeft                = GetFunc("userLeft");
            __userProfileReceived     = GetFunc("userProfileReceived");
            __userShown               = GetFunc("userShown");
            __userSpoke               = GetFunc("userSpoke");
            __warcraftProfileReceived = GetFunc("warcraftProfileReceived");
            __whisperReceived         = GetFunc("whisperReceived");
            __whisperSent             = GetFunc("whisperSent");
        }
Example #6
0
        public void RegisterEvents(IJinxBotClient profileClient)
        {
            _client = profileClient;
            ResetScriptEngine(new StringScriptSource(_scriptSrc), profileClient);

            profileClient.Client.AccountCreated        += Client_AccountCreated;
            profileClient.Client.AccountCreationFailed += Client_AccountCreationFailed;
            profileClient.Client.AdChanged             += Client_AdChanged;
            profileClient.Client.ChannelDidNotExist    += Client_ChannelDidNotExist;
            profileClient.Client.ChannelListReceived   += Client_ChannelListReceived;
            profileClient.Client.ChannelWasFull        += Client_ChannelWasFull;
            profileClient.Client.ChannelWasRestricted  += Client_ChannelWasRestricted;
            profileClient.Client.ClientCheckFailed     += Client_ClientCheckFailed;
            profileClient.Client.ClientCheckPassed     += Client_ClientCheckPassed;
            profileClient.Client.CommandSent           += Client_CommandSent;
            profileClient.Client.Connected             += Client_Connected;
            profileClient.Client.Disconnected          += Client_Disconnected;
            profileClient.Client.EnteredChat           += Client_EnteredChat;
            profileClient.Client.Error                   += Client_Error;
            profileClient.Client.FriendAdded             += Client_FriendAdded;
            profileClient.Client.FriendListReceived      += Client_FriendListReceived;
            profileClient.Client.FriendMoved             += Client_FriendMoved;
            profileClient.Client.FriendRemoved           += Client_FriendRemoved;
            profileClient.Client.FriendUpdated           += Client_FriendUpdated;
            profileClient.Client.Information             += Client_Information;
            profileClient.Client.InformationReceived     += Client_InformationReceived;
            profileClient.Client.JoinedChannel           += Client_JoinedChannel;
            profileClient.Client.LoginFailed             += Client_LoginFailed;
            profileClient.Client.LoginSucceeded          += Client_LoginSucceeded;
            profileClient.Client.MessageSent             += Client_MessageSent;
            profileClient.Client.ProfileLookupFailed     += Client_ProfileLookupFailed;
            profileClient.Client.ServerBroadcast         += Client_ServerBroadcast;
            profileClient.Client.ServerErrorReceived     += Client_ServerErrorReceived;
            profileClient.Client.ServerNews              += Client_ServerNews;
            profileClient.Client.UserEmoted              += Client_UserEmoted;
            profileClient.Client.UserFlagsChanged        += Client_UserFlagsChanged;
            profileClient.Client.UserJoined              += Client_UserJoined;
            profileClient.Client.UserLeft                += Client_UserLeft;
            profileClient.Client.UserProfileReceived     += Client_UserProfileReceived;
            profileClient.Client.UserShown               += Client_UserShown;
            profileClient.Client.UserSpoke               += Client_UserSpoke;
            profileClient.Client.WarcraftProfileReceived += Client_WarcraftProfileReceived;
            profileClient.Client.WhisperReceived         += Client_WhisperReceived;
            profileClient.Client.WhisperSent             += Client_WhisperSent;
        }
Example #7
0
 public void UnregisterEvents(IJinxBotClient profileClient)
 {
     profileClient.Client.AccountCreated        -= Client_AccountCreated;
     profileClient.Client.AccountCreationFailed -= Client_AccountCreationFailed;
     profileClient.Client.AdChanged             -= Client_AdChanged;
     profileClient.Client.ChannelDidNotExist    -= Client_ChannelDidNotExist;
     profileClient.Client.ChannelListReceived   -= Client_ChannelListReceived;
     profileClient.Client.ChannelWasFull        -= Client_ChannelWasFull;
     profileClient.Client.ChannelWasRestricted  -= Client_ChannelWasRestricted;
     profileClient.Client.ClientCheckFailed     -= Client_ClientCheckFailed;
     profileClient.Client.ClientCheckPassed     -= Client_ClientCheckPassed;
     profileClient.Client.CommandSent           -= Client_CommandSent;
     profileClient.Client.Connected             -= Client_Connected;
     profileClient.Client.Disconnected          -= Client_Disconnected;
     profileClient.Client.EnteredChat           -= Client_EnteredChat;
     profileClient.Client.Error                   -= Client_Error;
     profileClient.Client.FriendAdded             -= Client_FriendAdded;
     profileClient.Client.FriendListReceived      -= Client_FriendListReceived;
     profileClient.Client.FriendMoved             -= Client_FriendMoved;
     profileClient.Client.FriendRemoved           -= Client_FriendRemoved;
     profileClient.Client.FriendUpdated           -= Client_FriendUpdated;
     profileClient.Client.Information             -= Client_Information;
     profileClient.Client.InformationReceived     -= Client_InformationReceived;
     profileClient.Client.JoinedChannel           -= Client_JoinedChannel;
     profileClient.Client.LoginFailed             -= Client_LoginFailed;
     profileClient.Client.LoginSucceeded          -= Client_LoginSucceeded;
     profileClient.Client.MessageSent             -= Client_MessageSent;
     profileClient.Client.ProfileLookupFailed     -= Client_ProfileLookupFailed;
     profileClient.Client.ServerBroadcast         -= Client_ServerBroadcast;
     profileClient.Client.ServerErrorReceived     -= Client_ServerErrorReceived;
     profileClient.Client.ServerNews              -= Client_ServerNews;
     profileClient.Client.UserEmoted              -= Client_UserEmoted;
     profileClient.Client.UserFlagsChanged        -= Client_UserFlagsChanged;
     profileClient.Client.UserJoined              -= Client_UserJoined;
     profileClient.Client.UserLeft                -= Client_UserLeft;
     profileClient.Client.UserProfileReceived     -= Client_UserProfileReceived;
     profileClient.Client.UserShown               -= Client_UserShown;
     profileClient.Client.UserSpoke               -= Client_UserSpoke;
     profileClient.Client.WarcraftProfileReceived -= Client_WarcraftProfileReceived;
     profileClient.Client.WhisperReceived         -= Client_WhisperReceived;
     profileClient.Client.WhisperSent             -= Client_WhisperSent;
 }
Example #8
0
        public ClanGnome(string dbPath, IJinxBotClient client)
        {
            m_timer = new Timer(45000) { AutoReset = true };
            m_timer.Elapsed += new ElapsedEventHandler(m_timer_Elapsed);

            Debug.Assert(client != null);
            m_client = client;
            m_dbPath = dbPath;
            client.Client.RegisterUserSpokeNotification(Priority.Low, HandleChat);
            client.Client.RegisterWhisperReceivedNotification(Priority.Low, HandleChat);
            client.Client.RegisterUserShownNotification(Priority.Low, HandleUser);
            client.Client.RegisterUserFlagsChangedNotification(Priority.Low, HandleUser);
            client.Client.RegisterUserJoinedNotification(Priority.Low, HandleUser);
            client.Client.RegisterConnectedNotification(Priority.Low, HandleConnected);
            client.Client.RegisterChannelDidNotExistNotification(Priority.Low, HandleChannelError);
            client.Client.RegisterChannelWasFullNotification(Priority.Low, HandleChannelError);
            client.Client.RegisterChannelWasRestrictedNotification(Priority.Low, HandleChannelError);

            client.Client.RegisterJoinedChannelNotification(Priority.Low, HandleChannelJoined);

            using (ClansDataContext dc = ClansDataContext.Create(m_dbPath))
            {
                var gw = (from g in dc.Gateways
                          where g.Name.ToUpper() == client.Client.Settings.Gateway.Name.ToUpper()
                          select g).FirstOrDefault();
                if (gw != null)
                    m_gatewayID = gw.ID;
                else
                {
                    Gateway newGateway = new Gateway { Name = client.Client.Settings.Gateway.Name };
                    dc.Gateways.InsertOnSubmit(newGateway);
                    dc.SubmitChanges();
                    m_gatewayID = newGateway.ID;
                }
            }

            m_client.MainWindow.AddChat(new ChatNode[] {
                new ChatNode("JinxBot Clan Gnome", Color.DarkRed),
                new ChatNode(" initialized...", Color.White)
            });
        }
Example #9
0
        public JsHost(ScriptEngine engine, IJinxBotClient client)
        {
            Debug.Assert(engine != null);
            Debug.Assert(client != null);

            _engine = engine;
            _client = client;
            _jsClient = new JsJinxBotClientObjectInstance(client, this, engine);

            _engine.SetGlobalValue("Colors", new Colors(engine));
            _engine.SetGlobalValue("CssClasses", new CssClasses(engine));
            _engine.SetGlobalFunction("send", (Action<string>)send);
            _engine.SetGlobalFunction("addChat", (Action<ArrayInstance>)addChat);
            _engine.SetGlobalFunction("format", (Func<string, ArrayInstance, string>)format);
            _engine.SetGlobalFunction("setTimeout", (Func<double, ObjectInstance, int>)setTimeout);
            _engine.SetGlobalFunction("clearTimeout", (Action<int>)clearTimeout);
            _engine.SetGlobalFunction("setInterval", (Func<double, ObjectInstance, int>)setInterval);
            _engine.SetGlobalFunction("clearInterval", (Action<int>)clearInterval);

            FunctionInstance instance = engine.Evaluate(DUMP_FUNC) as FunctionInstance;
            engine.SetGlobalValue("dump", instance);
            engine.SetGlobalValue("client", _jsClient);

        }
Example #10
0
        public JsHost(ScriptEngine engine, IJinxBotClient client)
        {
            Debug.Assert(engine != null);
            Debug.Assert(client != null);

            _engine   = engine;
            _client   = client;
            _jsClient = new JsJinxBotClientObjectInstance(client, this, engine);

            _engine.SetGlobalValue("Colors", new Colors(engine));
            _engine.SetGlobalValue("CssClasses", new CssClasses(engine));
            _engine.SetGlobalFunction("send", (Action <string>)send);
            _engine.SetGlobalFunction("addChat", (Action <ArrayInstance>)addChat);
            _engine.SetGlobalFunction("format", (Func <string, ArrayInstance, string>)format);
            _engine.SetGlobalFunction("setTimeout", (Func <double, ObjectInstance, int>)setTimeout);
            _engine.SetGlobalFunction("clearTimeout", (Action <int>)clearTimeout);
            _engine.SetGlobalFunction("setInterval", (Func <double, ObjectInstance, int>)setInterval);
            _engine.SetGlobalFunction("clearInterval", (Action <int>)clearInterval);

            FunctionInstance instance = engine.Evaluate(DUMP_FUNC) as FunctionInstance;

            engine.SetGlobalValue("dump", instance);
            engine.SetGlobalValue("client", _jsClient);
        }
Example #11
0
 public void UnregisterEvents(IJinxBotClient profileClient)
 {
     profileClient.Client.AccountCreated -= Client_AccountCreated;
     profileClient.Client.AccountCreationFailed -= Client_AccountCreationFailed;
     profileClient.Client.AdChanged -= Client_AdChanged;
     profileClient.Client.ChannelDidNotExist -= Client_ChannelDidNotExist;
     profileClient.Client.ChannelListReceived -= Client_ChannelListReceived;
     profileClient.Client.ChannelWasFull -= Client_ChannelWasFull;
     profileClient.Client.ChannelWasRestricted -= Client_ChannelWasRestricted;
     profileClient.Client.ClientCheckFailed -= Client_ClientCheckFailed;
     profileClient.Client.ClientCheckPassed -= Client_ClientCheckPassed;
     profileClient.Client.CommandSent -= Client_CommandSent;
     profileClient.Client.Connected -= Client_Connected;
     profileClient.Client.Disconnected -= Client_Disconnected;
     profileClient.Client.EnteredChat -= Client_EnteredChat;
     profileClient.Client.Error -= Client_Error;
     profileClient.Client.FriendAdded -= Client_FriendAdded;
     profileClient.Client.FriendListReceived -= Client_FriendListReceived;
     profileClient.Client.FriendMoved -= Client_FriendMoved;
     profileClient.Client.FriendRemoved -= Client_FriendRemoved;
     profileClient.Client.FriendUpdated -= Client_FriendUpdated;
     profileClient.Client.Information -= Client_Information;
     profileClient.Client.InformationReceived -= Client_InformationReceived;
     profileClient.Client.JoinedChannel -= Client_JoinedChannel;
     profileClient.Client.LoginFailed -= Client_LoginFailed;
     profileClient.Client.LoginSucceeded -= Client_LoginSucceeded;
     profileClient.Client.MessageSent -= Client_MessageSent;
     profileClient.Client.ProfileLookupFailed -= Client_ProfileLookupFailed;
     profileClient.Client.ServerBroadcast -= Client_ServerBroadcast;
     profileClient.Client.ServerErrorReceived -= Client_ServerErrorReceived;
     profileClient.Client.ServerNews -= Client_ServerNews;
     profileClient.Client.UserEmoted -= Client_UserEmoted;
     profileClient.Client.UserFlagsChanged -= Client_UserFlagsChanged;
     profileClient.Client.UserJoined -= Client_UserJoined;
     profileClient.Client.UserLeft -= Client_UserLeft;
     profileClient.Client.UserProfileReceived -= Client_UserProfileReceived;
     profileClient.Client.UserShown -= Client_UserShown;
     profileClient.Client.UserSpoke -= Client_UserSpoke;
     profileClient.Client.WarcraftProfileReceived -= Client_WarcraftProfileReceived;
     profileClient.Client.WhisperReceived -= Client_WhisperReceived;
     profileClient.Client.WhisperSent -= Client_WhisperSent;
 }
Example #12
0
        public void RegisterEvents(IJinxBotClient profileClient)
        {
            _client = profileClient;
            ResetScriptEngine(new StringScriptSource(_scriptSrc), profileClient);

            profileClient.Client.AccountCreated += Client_AccountCreated;
            profileClient.Client.AccountCreationFailed += Client_AccountCreationFailed;
            profileClient.Client.AdChanged += Client_AdChanged;
            profileClient.Client.ChannelDidNotExist += Client_ChannelDidNotExist;
            profileClient.Client.ChannelListReceived += Client_ChannelListReceived;
            profileClient.Client.ChannelWasFull += Client_ChannelWasFull;
            profileClient.Client.ChannelWasRestricted += Client_ChannelWasRestricted;
            profileClient.Client.ClientCheckFailed += Client_ClientCheckFailed;
            profileClient.Client.ClientCheckPassed += Client_ClientCheckPassed;
            profileClient.Client.CommandSent += Client_CommandSent;
            profileClient.Client.Connected += Client_Connected;
            profileClient.Client.Disconnected += Client_Disconnected;
            profileClient.Client.EnteredChat += Client_EnteredChat;
            profileClient.Client.Error += Client_Error;
            profileClient.Client.FriendAdded += Client_FriendAdded;
            profileClient.Client.FriendListReceived += Client_FriendListReceived;
            profileClient.Client.FriendMoved += Client_FriendMoved;
            profileClient.Client.FriendRemoved += Client_FriendRemoved;
            profileClient.Client.FriendUpdated += Client_FriendUpdated;
            profileClient.Client.Information += Client_Information;
            profileClient.Client.InformationReceived += Client_InformationReceived;
            profileClient.Client.JoinedChannel += Client_JoinedChannel;
            profileClient.Client.LoginFailed += Client_LoginFailed;
            profileClient.Client.LoginSucceeded += Client_LoginSucceeded;
            profileClient.Client.MessageSent += Client_MessageSent;
            profileClient.Client.ProfileLookupFailed += Client_ProfileLookupFailed;
            profileClient.Client.ServerBroadcast += Client_ServerBroadcast;
            profileClient.Client.ServerErrorReceived += Client_ServerErrorReceived;
            profileClient.Client.ServerNews += Client_ServerNews;
            profileClient.Client.UserEmoted += Client_UserEmoted;
            profileClient.Client.UserFlagsChanged += Client_UserFlagsChanged;
            profileClient.Client.UserJoined += Client_UserJoined;
            profileClient.Client.UserLeft += Client_UserLeft;
            profileClient.Client.UserProfileReceived += Client_UserProfileReceived;
            profileClient.Client.UserShown += Client_UserShown;
            profileClient.Client.UserSpoke += Client_UserSpoke;
            profileClient.Client.WarcraftProfileReceived += Client_WarcraftProfileReceived;
            profileClient.Client.WhisperReceived += Client_WhisperReceived;
            profileClient.Client.WhisperSent += Client_WhisperSent;
        }
Example #13
0
        public void RegisterEvents(IJinxBotClient profileClient)
        {
            m_client = profileClient;
            m_bnet = profileClient.Client;
            m_db = profileClient.Database;

            m_bnet.RegisterUserJoinedNotification(Priority.High, user_Joined);
            m_bnet.RegisterUserShownNotification(Priority.High, user_Joined);
            m_bnet.RegisterUserFlagsChangedNotification(Priority.High, user_Joined);
            m_bnet.RegisterUserLeftNotification(Priority.High, user_Left);
        }
Example #14
0
 public void RegisterEvents(IJinxBotClient profileClient)
 {
     m_cg = new ClanGnome(m_dbPath, profileClient);
 }
Example #15
0
 public WhisperTab(IJinxBotClient client)
     : this()
 {
     this.client = client;
 }
Example #16
0
 public void UnregisterEvents(IJinxBotClient profileClient)
 {
     if (m_cg != null)
     {
         m_cg.Unhook();
         m_cg = null;
     }
 }
Example #17
0
        public void UnregisterEvents(IJinxBotClient profileClient)
        {
            m_bnet.UnregisterUserJoinedNotification(Priority.High, user_Joined);
            m_bnet.UnregisterUserShownNotification(Priority.High, user_Joined);
            m_bnet.UnregisterUserFlagsChangedNotification(Priority.High, user_Joined);
            m_bnet.UnregisterUserLeftNotification(Priority.High, user_Left);

            m_bnet = null;
            m_client = null;
            m_db = null;
        }