protected virtual void OnStart() { OnChatEvent.Register(OnChat, Priority.Low); OnChatSysEvent.Register(OnChatSys, Priority.Low); OnChatFromEvent.Register(OnChatFrom, Priority.Low); OnShuttingDownEvent.Register(OnShutdown, Priority.Low); }
protected virtual void OnStop() { OnChatEvent.Unregister(OnChat); OnChatSysEvent.Unregister(OnChatSys); OnChatFromEvent.Unregister(OnChatFrom); OnShuttingDownEvent.Unregister(OnShutdown); }
public static void MessageFrom(ChatScope scope, Player source, string msg, object arg, ChatMessageFilter filter, bool irc = false) { Player[] players = PlayerInfo.Online.Items; ChatMessageFilter scopeFilter = scopeFilters[(int)scope]; OnChatFromEvent.Call(scope, source, msg, arg, ref filter, irc); foreach (Player pl in players) { if (!scopeFilter(pl, arg)) { continue; } if (filter != null && !filter(pl, arg)) { continue; } if (Ignoring(pl, source)) { continue; } pl.Message(UnescapeMessage(pl, source, msg)); } }
/// <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; }
/// <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; }
protected void UnhookEvents() { OnChatEvent.Unregister(HandleChat); OnChatSysEvent.Unregister(HandleChatSys); OnChatFromEvent.Unregister(HandleChatFrom); OnShuttingDownEvent.Unregister(HandleShutdown); }
protected void HookEvents() { OnChatEvent.Register(HandleChat, Priority.Low); OnChatSysEvent.Register(HandleChatSys, Priority.Low); OnChatFromEvent.Register(HandleChatFrom, Priority.Low); OnShuttingDownEvent.Register(HandleShutdown, Priority.Low); }