Ejemplo n.º 1
0
        /// <summary> Hooks IRC events so they are handled. </summary>
        public void Hook()
        {
            if (hookedEvents)
            {
                return;
            }
            hookedEvents = true;

            OnPlayerActionEvent.Register(HandlePlayerAction, Priority.Low);
            OnShuttingDownEvent.Register(HandleShutdown, Priority.Low);
            OnGroupLoadEvent.Register(HandleGroupLoad, Priority.Low);

            OnChatEvent.Register(HandleChat, Priority.Low);
            OnChatSysEvent.Register(HandleChatSys, Priority.Low);
            OnChatFromEvent.Register(HandleChatFrom, Priority.Low);

            // Regster events for incoming
            bot.connection.Listener.OnNick              += Listener_OnNick;
            bot.connection.Listener.OnRegistered        += Listener_OnRegistered;
            bot.connection.Listener.OnAction            += Listener_OnAction;
            bot.connection.Listener.OnPublic            += Listener_OnPublic;
            bot.connection.Listener.OnPrivate           += Listener_OnPrivate;
            bot.connection.Listener.OnError             += Listener_OnError;
            bot.connection.Listener.OnQuit              += Listener_OnQuit;
            bot.connection.Listener.OnJoin              += Listener_OnJoin;
            bot.connection.Listener.OnPart              += Listener_OnPart;
            bot.connection.Listener.OnDisconnected      += Listener_OnDisconnected;
            bot.connection.Listener.OnChannelModeChange += Listener_OnChannelModeChange;
            bot.connection.Listener.OnNames             += Listener_OnNames;
            bot.connection.Listener.OnKick              += Listener_OnKick;
            bot.connection.Listener.OnKill              += Listener_OnKill;
            bot.connection.Listener.OnPrivateNotice     += Listener_OnPrivateNotice;
        }
Ejemplo n.º 2
0
        /// <summary> Unhooks IRC events so they are no longer handled. </summary>
        public void Unhook()
        {
            if (!hookedEvents)
            {
                return;
            }
            hookedEvents = false;
            userMap.Clear();

            OnPlayerActionEvent.Unregister(HandlePlayerAction);
            OnShuttingDownEvent.Unregister(HandleShutdown);
            OnGroupLoadEvent.Unregister(HandleGroupLoad);

            OnChatEvent.Unregister(HandleChat);
            OnChatSysEvent.Unregister(HandleChatSys);
            OnChatFromEvent.Unregister(HandleChatFrom);

            // Regster events for incoming
            bot.connection.Listener.OnNick              -= Listener_OnNick;
            bot.connection.Listener.OnRegistered        -= Listener_OnRegistered;
            bot.connection.Listener.OnAction            -= Listener_OnAction;
            bot.connection.Listener.OnPublic            -= Listener_OnPublic;
            bot.connection.Listener.OnPrivate           -= Listener_OnPrivate;
            bot.connection.Listener.OnError             -= Listener_OnError;
            bot.connection.Listener.OnQuit              -= Listener_OnQuit;
            bot.connection.Listener.OnJoin              -= Listener_OnJoin;
            bot.connection.Listener.OnPart              -= Listener_OnPart;
            bot.connection.Listener.OnDisconnected      -= Listener_OnDisconnected;
            bot.connection.Listener.OnChannelModeChange -= Listener_OnChannelModeChange;
            bot.connection.Listener.OnNames             -= Listener_OnNames;
            bot.connection.Listener.OnKick              -= Listener_OnKick;
            bot.connection.Listener.OnKill              -= Listener_OnKill;
            bot.connection.Listener.OnPrivateNotice     -= Listener_OnPrivateNotice;
        }
Ejemplo n.º 3
0
 protected virtual void OnStop()
 {
     OnChatEvent.Unregister(OnChat);
     OnChatSysEvent.Unregister(OnChatSys);
     OnChatFromEvent.Unregister(OnChatFrom);
     OnShuttingDownEvent.Unregister(OnShutdown);
 }
Ejemplo n.º 4
0
 protected virtual void OnStart()
 {
     OnChatEvent.Register(OnChat, Priority.Low);
     OnChatSysEvent.Register(OnChatSys, Priority.Low);
     OnChatFromEvent.Register(OnChatFrom, Priority.Low);
     OnShuttingDownEvent.Register(OnShutdown, Priority.Low);
 }
Ejemplo n.º 5
0
 protected void UnhookEvents()
 {
     OnChatEvent.Unregister(HandleChat);
     OnChatSysEvent.Unregister(HandleChatSys);
     OnChatFromEvent.Unregister(HandleChatFrom);
     OnShuttingDownEvent.Unregister(HandleShutdown);
 }
Ejemplo n.º 6
0
 protected void HookEvents()
 {
     OnChatEvent.Register(HandleChat, Priority.Low);
     OnChatSysEvent.Register(HandleChatSys, Priority.Low);
     OnChatFromEvent.Register(HandleChatFrom, Priority.Low);
     OnShuttingDownEvent.Register(HandleShutdown, Priority.Low);
 }
Ejemplo n.º 7
0
        public static void Message(ChatScope scope, string msg, object arg,
                                   ChatMessageFilter filter, bool irc = false)
        {
            Player[]          players     = PlayerInfo.Online.Items;
            ChatMessageFilter scopeFilter = scopeFilters[(int)scope];

            OnChatSysEvent.Call(scope, msg, arg, ref filter, irc);
            foreach (Player pl in players)
            {
                if (!scopeFilter(pl, arg))
                {
                    continue;
                }
                if (filter != null && !filter(pl, arg))
                {
                    continue;
                }
                pl.Message(msg);
            }
        }