public override void Unload(bool shutdown) { if (dc != null) { dc.Dispose(); } if (!registered) { return; } OnPlayerConnectEvent.Unregister(PlayerConnect); OnPlayerDisconnectEvent.Unregister(PlayerDisconnect); OnPlayerChatEvent.Unregister(PlayerChat); OnPlayerCommandEvent.Unregister(PlayerCommand); OnMessageReceivedEvent.Unregister(DiscordMessage); Command.Unregister(Command.Find("DiscordBot")); }
public override void Load(bool startup) { config.LoadConfig(); if (config.Token == "" || config.ChannelID == "") { Logger.Log(LogType.Warning, "Invalid config! Please setup the Discord bot in discord.properties! (plugin reload required)"); return; } dc = new Discord.Discord(config.Token, config.ChannelID); OnPlayerConnectEvent.Register(PlayerConnect, Priority.Low); OnPlayerDisconnectEvent.Register(PlayerDisconnect, Priority.Low); OnPlayerChatEvent.Register(PlayerChat, Priority.Low); OnPlayerCommandEvent.Register(PlayerCommand, Priority.Low); OnModActionEvent.Register(ModAction, Priority.Low); OnMessageReceivedEvent.Register(DiscordMessage, Priority.Low); Command.Register(new CmdDiscordBot()); registered = true; }
void HandleChat(byte[] buffer, int offset) { if (!loggedIn) { return; } byte continued = buffer[offset + 1]; string text = NetUtils.ReadString(buffer, offset + 2); LastAction = DateTime.UtcNow; if (FilterChat(ref text, continued)) { return; } if (text != "/afk" && IsAfk) { CmdAfk.ToggleAfk(this, ""); } // Typing //Command appears in chat as /command // Suggested by McMrCat if (text.StartsWith("//")) { text = text.Remove(0, 1); } else if (DoCommand(text)) { return; } // People who are muted can't speak or vote if (muted) { SendMessage("You are muted."); return; } //Muted: Only allow commands // Lava Survival map vote recorder if (Server.lava.HasPlayer(this) && Server.lava.HasVote(text.ToLower())) { if (Server.lava.AddVote(this, text.ToLower())) { SendMessage("Your vote for &5" + text.ToLower().Capitalize() + " %Shas been placed. Thanks!"); Server.lava.map.ChatLevelOps(name + " voted for &5" + text.ToLower().Capitalize() + "%S."); return; } else { SendMessage("&cYou already voted!"); return; } } // Filter out bad words if (ServerConfig.ProfanityFiltering) { text = ProfanityFilter.Parse(text); } if (IsHandledMessage(text)) { return; } // Put this after vote collection so that people can vote even when chat is moderated if (Server.chatmod && !voice) { SendMessage("Chat moderation is on, you cannot speak."); return; } if (ChatModes.Handle(this, text)) { return; } if (text[0] == ':' && PlayingTntWars) { string newtext = text.Remove(0, 1).Trim(); TntWarsGame it = TntWarsGame.GameIn(this); if (it.GameMode == TntWarsGame.TntWarsGameMode.TDM) { TntWarsGame.player pl = it.FindPlayer(this); foreach (TntWarsGame.player p in it.Players) { if (pl.Red && p.Red) { SendMessage(p.p, "To Team " + Colors.red + "-" + color + name + Colors.red + "- %S" + newtext); } if (pl.Blue && p.Blue) { SendMessage(p.p, "To Team " + Colors.blue + "-" + color + name + Colors.blue + "- %S" + newtext); } } Logger.Log(LogType.GameActivity, "[TNT Wars] [TeamChat (" + (pl.Red ? "Red" : "Blue") + ") " + name + " " + newtext); return; } } text = HandleJoker(text); if (Chatroom != null) { Chat.MessageChatRoom(this, text, true, Chatroom); return; } bool levelOnly = !level.SeesServerWideChat; string format = levelOnly ? "<{0}>[level] {1}" : "<{0}> {1}"; Logger.Log(LogType.PlayerChat, format, name, text); OnPlayerChatEvent.Call(this, text); if (cancelchat) { cancelchat = false; return; } if (levelOnly) { Chat.MessageLevel(this, text, true, level); } else { SendChatFrom(this, text); } CheckForMessageSpam(); }
void HandleChat(byte[] buffer, int offset) { if (!loggedIn) { return; } byte continued = buffer[offset + 1]; string text = NetUtils.ReadString(buffer, offset + 2); LastAction = DateTime.UtcNow; if (FilterChat(ref text, continued)) { return; } if (text != "/afk" && IsAfk) { CmdAfk.ToggleAfk(this, ""); } // Typing //Command appears in chat as /command // Suggested by McMrCat if (text.StartsWith("//")) { text = text.Remove(0, 1); } else if (DoCommand(text)) { return; } // People who are muted can't speak or vote if (muted) { Message("You are muted."); return; } //Muted: Only allow commands if (Server.voting) { if (CheckVote(text, this, "y", "yes", ref Server.YesVotes) || CheckVote(text, this, "n", "no", ref Server.NoVotes)) { return; } } if (LSGame.Instance.HandlesChatMessage(this, text)) { return; } if (ZSGame.Instance.HandlesChatMessage(this, text)) { return; } // Put this after vote collection so that people can vote even when chat is moderated if (Server.chatmod && !voice) { Message("Chat moderation is on, you cannot speak."); return; } // Filter out bad words if (ServerConfig.ProfanityFiltering) { text = ProfanityFilter.Parse(text); } if (ChatModes.Handle(this, text)) { return; } text = HandleJoker(text); OnPlayerChatEvent.Call(this, text); if (cancelchat) { cancelchat = false; return; } if (Chatroom != null) { string roomPrefix = "<ChatRoom: " + Chatroom + "> λNICK: &f"; Chat.MessageChat(ChatScope.Chatroom, this, roomPrefix + text, Chatroom, null); } else { Chat.MessageChat(this, "λFULL: &f" + text, null, true); } }
internal void ProcessChat(string text, bool continued) { LastAction = DateTime.UtcNow; if (FilterChat(ref text, continued)) { return; } if (text != "/afk" && IsAfk) { CmdAfk.ToggleAfk(this, ""); } bool isCommand; text = Chat.ParseInput(text, out isCommand); if (isCommand) { DoCommand(text); return; } // People who are muted can't speak or vote if (muted) { Message("You are muted."); return; } //Muted: Only allow commands if (Server.voting) { if (CheckVote(text, this, "y", "yes", ref Server.YesVotes) || CheckVote(text, this, "n", "no", ref Server.NoVotes)) { return; } } IGame game = IGame.GameOn(level); if (game != null && game.HandlesChatMessage(this, text)) { return; } // Put this after vote collection so that people can vote even when chat is moderated if (!CheckCanSpeak("speak")) { return; } if (ChatModes.Handle(this, text)) { return; } text = HandleJoker(text); OnPlayerChatEvent.Call(this, text); if (cancelchat) { cancelchat = false; return; } Chat.MessageChat(this, "λFULL: &f" + text, null, true); }
public override void Unload(bool shutdown) { OnPlayerChatEvent.Unregister(DoTeamChat); }
public override void Load(bool startup) { OnPlayerChatEvent.Register(DoTeamChat, Priority.Low); }
void HandleChat(byte[] buffer, int offset) { if (!loggedIn) { return; } byte continued = buffer[offset + 1]; string text = NetUtils.ReadString(buffer, offset + 2); LastAction = DateTime.UtcNow; if (FilterChat(ref text, continued)) { return; } if (text != "/afk" && IsAfk) { CmdAfk.ToggleAfk(this, ""); } bool isCommand; text = Chat.ParseInput(text, out isCommand); if (isCommand) { DoCommand(text); return; } // People who are muted can't speak or vote if (muted) { Message("You are muted."); return; } //Muted: Only allow commands if (Server.voting) { if (CheckVote(text, this, "y", "yes", ref Server.YesVotes) || CheckVote(text, this, "n", "no", ref Server.NoVotes)) { return; } } if (LSGame.Instance.HandlesChatMessage(this, text)) { return; } if (ZSGame.Instance.HandlesChatMessage(this, text)) { return; } // Put this after vote collection so that people can vote even when chat is moderated if (!CheckCanSpeak("speak")) { return; } // Filter out bad words if (Server.Config.ProfanityFiltering) { text = ProfanityFilter.Parse(text); } if (ChatModes.Handle(this, text)) { return; } text = HandleJoker(text); OnPlayerChatEvent.Call(this, text); if (cancelchat) { cancelchat = false; return; } Chat.MessageChat(this, "λFULL: &f" + text, null, true); }