private void ChatMessageHook(object sender, ChatMessageArgs e) { SocketGuild server = e.Server; if (server != null && _bot.Settings.DadTalkServers.Contains(server.Id)) { int messageStart = 0; if (e.Message.IndexOf("i'm ", StringComparison.OrdinalIgnoreCase) == 0 || e.Message.IndexOf("i’m ", StringComparison.OrdinalIgnoreCase) == 0) { messageStart = 4; } else if (e.Message.IndexOf("im ", StringComparison.OrdinalIgnoreCase) == 0) { messageStart = 3; } if (messageStart != 0) { _bot.Chat.SendMessage(e.Channel, "Hi " + e.Message.Substring(messageStart) + ", I'm " + _bot.Settings.DadTalkName + "!"); } } return; }
public override void Execute(ChatMessageArgs message, String args) { if (!Service.Accounts.CheckAccess(message.User.Id, "AccountsManageRole")) { Service.Chat.SendDirectMessage(message.User, "You do not have permission to remove access roles."); return; } UserRole role = Service.Accounts.GetRole(args); if (role == null) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " That role does not exist!"); return; } Service.Accounts.Roles.Remove(role.Name); foreach (UserAccount account in Service.Accounts.Accounts.Values) { account.Roles.Remove(role); } Service.Accounts.SaveChanges(); Service.Chat.SendMessage(message.Channel, message.User.Mention + " I have successfully removed the role \"" + role.Name + "\"."); return; }
//chat message event fires whenever we receive an actual message private static void OnChatMessage(object sender, ChatMessageArgs e) { switch (e.ChatMessage.Text.ToLower()) { case "!utc": ChatHandler.Message(IdConversions.AccountIdToUlong(e.ChatMessage.AccountIdFrom), "saytext", "The current UTC timestamp is: " + e.ChatMessage.UtcTimestamp); return; case "!timestamp": ChatHandler.Message(IdConversions.AccountIdToUlong(e.ChatMessage.AccountIdFrom), "saytext", "The current timestamp is: " + e.ChatMessage.Timestamp); return; case "!myfriendcount": List <Friend> friends = SteamUserHandler.GetFriendList(IdConversions.AccountIdToUlong(e.ChatMessage.AccountIdFrom), "friend"); if (friends == null) { throw new ArgumentNullException(nameof(friends)); } ChatHandler.Message(IdConversions.AccountIdToUlong(e.ChatMessage.AccountIdFrom), "saytext", "You have " + friends.Count + " friends."); return; case "!logoff": ChatEventsManager.EndMessageLoop(); ChatHandler.Logoff(); return; //more commands... } //actual messages etc... ChatHandler.Message(IdConversions.AccountIdToUlong(e.ChatMessage.AccountIdFrom), "saytext", "Hello!"); }
public override void Execute(ChatMessageArgs message, string args) { if (!Service.Accounts.CheckAccess(message.User.Id, AccessFlag)) { Service.Chat.SendDirectMessage(message.User, "You do not have permission to add servers to the highlights whitelist!"); return; } var server = message.Server; if (server == null) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " This is not a valid server!"); return; } if (!Service.Highlights.Servers.ContainsKey(server.Id)) { HighlightServer highlightServer = new HighlightServer(); Service.Highlights.Servers.Add(server.Id, highlightServer); Service.Highlights.SaveChanges(); Service.Chat.SendMessage(message.Channel, message.User.Mention + " This server has been added to the highlights whitelist!"); } else { Service.Chat.SendMessage(message.Channel, message.User.Mention + " This server was already in the highlights whitelist!"); } return; }
public override void Execute(ChatMessageArgs message, string args) { if (!Service.Accounts.CheckAccess(message.User.Id, AccessFlag)) { Service.Chat.SendDirectMessage(message.User, "You do not have permission to remove servers from the Dad Mode whitelist!"); return; } var server = message.Server; if (server == null) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " This is not a valid server!"); return; } if (Service.Settings.DadTalkServers.Remove(server.Id)) { Service.SaveChanges(); Service.Chat.SendMessage(message.Channel, message.User.Mention + " This server has been removed from the Dad Mode whitelist!"); } else { Service.Chat.SendMessage(message.Channel, message.User.Mention + " This server was not found in the Dad Mode whitelist!"); } return; }
public override void Execute(ChatMessageArgs message, string arguments) { if (!Service.Accounts.CheckAccess(message.User.Id, "AccountSay")) { Service.Chat.SendDirectMessage(message.User, "You do not have permission to speak through me."); return; } List <String> args = ParseArgs(arguments); if (args.Count < 2) { Service.Chat.SendMessage(message.Channel, "Usage: " + Service.Settings.ChatCommandPrefix + "say <MESSAGE> <CHANNEL> [SERVER]"); return; } SocketTextChannel targetChannel = null; bool selectServer = args.Count > 2; foreach (SocketGuild guild in Service.Client.Guilds) { if (selectServer && !guild.Name.Contains(args[2])) { continue; } foreach (SocketTextChannel channel in guild.TextChannels) { if (channel.Name.Contains(args[1])) { if (targetChannel == null) { targetChannel = channel; } else { Service.Chat.SendMessage(message.Channel, message.User.Mention + " The channel descriptor that you supplied is too ambiguous."); return; } } } } if (targetChannel == null) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " I couldn't find a channel that fit the description!"); return; } Service.Chat.SendMessage(targetChannel, args[0]); return; }
void client_OnChatMessage(object sender, ChatMessageArgs e) { GSTask t = new GSTask(); t.Type = (int)GSTask.GSTType.ChatMessage; t.Client = (GameClient)sender; t.Args = e; TaskProcessor.AddTask(t); }
void OnChatMessage(object sender, ChatMessageArgs e) { ChatControl control = FindMatchingChatControl(IdConversions.AccountIdToUlong(e.ChatMessage.AccountIdFrom)); if (control == null) { return; } InvokeHandleMessage(control, e.ChatMessage.Text); }
private async Task _onchatmessageevent_(RequestResponseModel msg) { ulong user = Convert.ToUInt64(msg.Payload["user_id"]); string message = (string)msg.Payload["message"]; string type = (string)msg.Payload["type"]; ChatMessageArgs args = new ChatMessageArgs(user, message, type); Task t = Task.Run(() => OnChatMessage?.Invoke(this, args)); Debug.WriteLine($"[EVENT]Chat message [{type}] from UID {user}: {message}"); await t; }
public override void Execute(ChatMessageArgs message, string args) { String output = message.User.Mention + " Here are all of the access roles:\n```"; foreach (UserRole role in Service.Accounts.Roles.Values) { output += role.Name + "\n"; } Service.Chat.SendMessage(message.Channel, output + "```"); return; }
public void SendChatMessage(WorldObject sender, ChatMessageArgs chatMessage) { // only players receive this List <Player> players = null; lock (objectCacheLocker) { players = worldObjects.Values.OfType <Player>().ToList(); } BroadcastEventArgs args = BroadcastEventArgs.CreateChatAction(sender, chatMessage); Broadcast(args, true, Quadrant.All); }
public override void Execute(ChatMessageArgs message, string arguments) { UserAccount account = Service.Accounts.InitReg(message.User.Id, arguments); if (account != null) { Service.Chat.SendDirectMessage(message.User, "You have successfully registered as a root user!"); } else { System.Console.WriteLine("[Accounting] WARNING: A user has attempted to initreg, password \"" + arguments + "\""); } return; }
public override void Execute(ChatMessageArgs message, string args) { int page; if (Int32.TryParse(args, out page)) { if (page < 1) { page = 1; } } else { page = 1; } List <KeyValuePair <String, ChatCommand> > cmds = Service.Chat.GetHelpListing(message.User.Id, page); String output; if (cmds.Count > 0) { output = message.User.Mention + "\nHere is your command listing (page " + page + "):\n```"; foreach (KeyValuePair <String, ChatCommand> cmd in cmds) { output += cmd.Key + " - " + cmd.Value.Description + "\n"; } if (cmds.Count == 10) { output += "```\nPlease use \"" + Service.Settings.ChatCommandPrefix + "help " + (page + 1) + "\" to view the next page."; } else { output += "```"; } } else { output = message.User.Mention + "\nSorry, I couldn't find any commands!"; } Service.Chat.SendMessage(message.Channel, output); return; }
public override void Execute(ChatMessageArgs message, string arguments) { if (!Service.Accounts.CheckAccess(message.User.Id, "AccountsManageRole")) { Service.Chat.SendDirectMessage(message.User, "You do not have permission to remove roles from user accounts."); return; } List <String> args = ParseArgs(arguments); if (args.Count < 2 || message.Data.MentionedUsers.Count < 1) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " Usage: " + Service.Settings.ChatCommandPrefix + "takerole <ROLE> [MENTIONED USERS]"); return; } UserRole role = Service.Accounts.GetRole(args[0]); if (role == null) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " \"" + args[0] + "\" is an invalid role!"); return; } String resultMessage = message.User.Mention + " You have successfully taken the role \"" + args[0] + "\" from"; foreach (SocketUser user in message.Data.MentionedUsers) { UserAccount account = Service.Accounts.CreateAccount(user.Id); if (!account.Roles.Contains(role)) { account.Roles.Remove(role); resultMessage += " " + user.Mention; } } Service.Chat.SendMessage(message.Channel, resultMessage + "!"); Service.Accounts.SaveChanges(); return; }
public override void Execute(ChatMessageArgs message, String arguments) { if (Service.Accounts.CheckAccess(message.User.Id, "AccountSetNickname")) { ChangeName(arguments); Service.Chat.SendDirectMessage(message.User, "I have changed my global nickname to \"" + arguments + "\"."); } else { Service.Chat.SendDirectMessage(message.User, "You currently lack the access to change my global nickname."); // TODO: log } return; }
public override void Execute(ChatMessageArgs message, string args) { if (!Service.Accounts.CheckAccess(message.User.Id, AccessFlag)) { Service.Chat.SendDirectMessage(message.User, "You do not have permission to add highlight reacts to this server!"); return; } var server = message.Server; if (server == null) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " This is not a valid server!"); return; } String emoji = args.Trim(); if (emoji.Length < 1) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " Usage: " + Service.Settings.ChatCommandPrefix + "addhighlightreact <EMOJI>"); return; } if (!Service.Highlights.Servers.ContainsKey(server.Id)) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " This server is not setup for the highlight system!"); return; } HighlightServer highlightServer = Service.Highlights.Servers[server.Id]; highlightServer.ReactsAllowed.Add(emoji); Service.Highlights.SaveChanges(); Service.Chat.SendMessage(message.Channel, message.User.Mention + " " + emoji + " has been added to this server's highlight reacts list!"); return; }
public override void Execute(ChatMessageArgs message, string args) { if (!Service.Accounts.CheckAccess(message.User.Id, AccessFlag)) { Service.Chat.SendDirectMessage(message.User, "You do not have permission to configure the highlights channel!"); return; } var server = message.Server; if (server == null) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " This is not a valid server!"); return; } SocketGuildChannel channel = message.Data.MentionedChannels.FirstOrDefault(); if (channel != null) { if (!Service.Highlights.Servers.ContainsKey(server.Id)) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " Please explicitly designate this server for the highlights system!"); return; } Service.Highlights.Servers[server.Id].HighlightChannel = channel.Id; Service.Highlights.SaveChanges(); Service.Chat.SendMessage(message.Channel, message.User.Mention + " The highlights channel in this server has been set to #" + channel.Name + "!"); return; } else { Service.Chat.SendMessage(message.Channel, message.User.Mention + " Please specify a valid channel!"); } return; }
public override void Execute(ChatMessageArgs message, String args) { if (!Service.Accounts.CheckAccess(message.User.Id, AccessFlag)) { Service.Chat.SendDirectMessage(message.User, "You do not have permission to change my status."); return; } Service.Client.SetGameAsync(args); Service.Settings.PlayStatus = args; Service.SaveChanges(); Service.Chat.SendMessage(message.Channel, message.User.Mention + " My status has been changed to \"" + args + "\"."); return; }
public override void Execute(ChatMessageArgs message, string arguments) { if (!Service.Accounts.CheckAccess(message.User.Id, "AccountsManageRole")) { Service.Chat.SendDirectMessage(message.User, "You do not have permission to remove access flags."); return; } List <String> args = ParseArgs(arguments); if (args.Count < 2) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " Usage: " + Service.Settings.ChatCommandPrefix + "removeflag <ROLE> <FLAG>"); return; } UserRole role = Service.Accounts.GetRole(args[0]); if (role == null) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " \"" + args[0] + "\" does not currently exist as a role!"); return; } if (args[1].Length < 1) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " The flag supplied is invalid!"); return; } role.RemoveFlag(args[1]); Service.Chat.SendMessage(message.Channel, message.User.Mention + " Flag \"" + args[1] + "\" has been removed from role \"" + args[0] + "\"!"); Service.Accounts.SaveChanges(); return; }
void OnMessage(object sender, ChatMessageArgs e) { CheckCreateChatWindow(); PlayerSummary summary = FriendSummaries.FirstOrDefault( x => x.SteamId == IdConversions.AccountIdToUlong(e.ChatMessage.AccountIdFrom)); if (summary == null) { MessageBox.Show("I was lazy and I don't poll for new friends. They attempted to send you a message."); return; } List <FriendControl> friendControls = new List <FriendControl>(); ChatUser friend = null; friendsStackPanel.Dispatcher.Invoke(() => { friendControls = friendsStackPanel.Children.Cast <FriendControl>().ToList(); }); foreach (FriendControl control in friendControls) { ulong steamId = 0; control.Dispatcher.Invoke(() => { steamId = control.Friend.Summary.SteamId; }); if (steamId != summary.SteamId) { continue; } control.Dispatcher.Invoke(() => { friend = control.Friend; }); break; } if (friend == null) { throw new Exception("Could not locate friend, please report this!"); } ChatWindow.AddChatWindow(friend, e.ChatMessage.Text); }
public override void Execute(ChatMessageArgs message, string args) { if (!Service.Accounts.CheckAccess(message.User.Id, AccessFlag)) { Service.Chat.SendDirectMessage(message.User, "You do not have permission to enable Dad Mode!"); return; } if (Service.Dad.EnableTalk()) { Service.SaveChanges(); Service.Chat.SendMessage(message.Channel, message.User.Mention + " Dad Mode has been enabled!"); } else { Service.Chat.SendMessage(message.Channel, message.User.Mention + " Dad Mode is already enabled!"); } return; }
public override void Execute(ChatMessageArgs message, string arguments) { if (!Service.Accounts.CheckAccess(message.User.Id, "ScpAddObject")) { Service.Chat.SendDirectMessage(message.User, "You do not have permission to add SCP objects."); return; } int id = 0; if (!Int32.TryParse(arguments, out id)) { Service.Chat.SendMessage(message.Channel, "Usage: " + Service.Settings.ChatCommandPrefix + "addscp <ID>"); return; } if (Service.Scp.Scps.ContainsKey(id)) { Service.Chat.SendMessage(message.Channel, "SCP-" + ScpObject.GetViewId(id) + " already exists!"); } else { ScpObject scp = new ScpObject(); scp.Id = id; Service.Scp.Scps.Add(id, scp); Service.Scp.SaveChanges(); Service.Chat.SendMessage(message.Channel, "SCP-" + ScpObject.GetViewId(id) + " has been created!"); } return; }
public override void Execute(ChatMessageArgs message, string args) { if (!Service.Accounts.CheckAccess(message.User.Id, "AccountsManageRole")) { Service.Chat.SendDirectMessage(message.User, "You do not have permission to create access roles."); return; } if (Service.Accounts.GetRole(args) != null) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " Role \"" + args + "\" already exists!"); } else { Service.Accounts.CreateRole(args); Service.Chat.SendMessage(message.Channel, message.User.Mention + " Role \"" + args + "\" has been created!"); } Service.Accounts.SaveChanges(); return; }
public override void Execute(ChatMessageArgs message, string args) { if (!Service.Accounts.CheckAccess(message.User.Id, AccessFlag)) { Service.Chat.SendDirectMessage(message.User, "You do not have permission to change the name used for Dad Mode!"); return; } if (args.Length < 1) { Service.Chat.SendMessage(message.Channel, message.User.Mention + " Usage: " + Service.Settings.ChatCommandPrefix + "setdadname <NAME>"); } else { Service.Settings.DadTalkName = args; Service.SaveChanges(); Service.Chat.SendMessage(message.Channel, message.User.Mention + " The name used for Dad Mode has been set to \"" + args + "\"!"); } return; }
public override void Execute(ChatMessageArgs message, string args) { Service.Chat.SendMessage(message.Channel, "LanDiscordBot " + BotService.Version + "\n---\nGitHub: https://github.com/Minimum/LanDiscordBot"); return; }
public override void Execute(ChatMessageArgs message, string arguments) { String output = ""; long uptime = Service.Uptime; bool firstValue = true; long value = uptime % 60; // Seconds if (value != 0) { output = (value == 1) ? " second" + output : " seconds" + output; output = " " + value + output; firstValue = false; } // Minutes value = (uptime % 3600) / 60; if (value != 0) { if (firstValue) { firstValue = false; } else { output = "," + output; } output = (value == 1) ? " minute" + output : " minutes" + output; output = " " + value + output; } // Hours value = (uptime % 86400) / 3600; if (value != 0) { if (firstValue) { firstValue = false; } else { output = "," + output; } output = (value == 1) ? " hour" + output : " hours" + output; output = " " + value + output; } // Days value = (uptime % 604800) / 86400; if (value != 0) { if (firstValue) { firstValue = false; } else { output = "," + output; } output = (value == 1) ? " day" + output : " days" + output; output = " " + value + output; } // Weeks value = (uptime % 31449600) / 604800; if (value != 0) { if (firstValue) { firstValue = false; } else { output = "," + output; } output = (value == 1) ? " week" + output : " weeks" + output; output = " " + value + output; } // Years value = uptime / 31449600; if (value != 0) { if (firstValue) { firstValue = false; } else { output = "," + output; } output = (value == 1) ? " year" + output : " years" + output; output = " " + value + output; } Service.Chat.SendMessage(message.Channel, message.User.Mention + " I have been online for" + output + "."); return; }
private void _evaluteEvent(string parEvent, object[] parArgs) { if (OnEvent != null) { var args = new OnEventArgs(parEvent, parArgs); OnEvent.Invoke(this, args); } //Console.WriteLine(parEvent); //OUTPUTAssist.PrintEvent(parEvent, parArgs); if (parEvent == "PLAYER_TARGET_CHANGED") { OnTargetChange?.Invoke(this, new EventArgs()); } else if (parEvent == "QUEST_FINISHED") { if (QuestFrame.IsOpen) { QuestFrame.Destroy(); } if (QuestGreetingFrame.IsOpen) { QuestGreetingFrame.Destroy(); } } else if (parEvent == "QUEST_PROGRESS" || parEvent == "QUEST_COMPLETE" || parEvent == "QUEST_DETAIL") { DirectX.Instance.Execute(QuestFrame.Create, 100); } else if (parEvent == "QUEST_GREETING") { DirectX.Instance.Execute(QuestGreetingFrame.Create, 100); } else if (parEvent == "UNIT_LEVEL") { if ((string)parArgs[0] != "player") { return; } LevelUp?.Invoke(this, new EventArgs()); } else if (parEvent == "PLAYER_MONEY") { OnMoneyChange?.Invoke(this, new EventArgs()); } else if (parEvent == "CHAT_MSG_LOOT") { // You receive loot: |cff9d9d9d|Hitem:7098:0:0:0|h[Splintered Tusk]|h|rx2. if (OnLoot == null) { return; } var arg1 = (string)parArgs[0]; var argArr = arg1.Split('|'); var itemId = Convert.ToInt32(argArr[2].Split(':')[1]); var itemName = argArr[3].Substring(2, argArr[3].Length - 3); var itemCount = 1; if (argArr[5].Length != 2) { itemCount = Convert.ToInt32(argArr[5].Substring(2, argArr[5].Length - 3)); } OnLoot.Invoke(this, new OnLootArgs(itemId, itemName, itemCount)); } else if (parEvent == "OPEN_STATUS_DIALOG") { if (OnWrongLogin == null) { return; } if (parArgs.Length != 2) { return; } if ((string)parArgs[0] != "OKAY") { return; } if ((string)parArgs[1] != "The information you have entered is not valid.") { return; } OnWrongLogin.Invoke(this, new EventArgs()); } else if (parEvent == "UPDATE_SELECTED_CHARACTER") { OnCharacterListLoaded?.Invoke(this, new EventArgs()); } else if (parEvent == "UPDATE_STATUS_DIALOG") { if (InServerQueue == null) { return; } if (parArgs.Length != 2) { return; } if (!((string)parArgs[0]).Contains("Position in queue:")) { return; } if ((string)parArgs[1] != "Change Realm") { return; } InServerQueue.Invoke(this, new EventArgs()); } else if (parEvent == "GET_PREFERRED_REALM_INFO") { OnChooseRealm?.Invoke(this, new EventArgs()); } else if (parEvent == "DISCONNECTED_FROM_SERVER") { OnDisconnect?.Invoke(this, new EventArgs()); } else if (parEvent == "UI_ERROR_MESSAGE") { OnErrorMessage?.Invoke(this, new OnUiMessageArgs((string)parArgs[0])); } else if (parEvent == "UI_INFO_MESSAGE") { OnUiMessage?.Invoke(this, new OnUiMessageArgs((string)parArgs[0])); } else if (parEvent == "CHAT_MSG_SYSTEM") { OnSystemMessage?.Invoke(this, new OnUiMessageArgs((string)parArgs[0])); } else if (parEvent == "PLAYER_REGEN_ENABLED") { OnFightStop?.Invoke(this, new EventArgs()); } else if (parEvent == "PLAYER_REGEN_DISABLED") { OnFightStart?.Invoke(this, new EventArgs()); } else if (parEvent == "CHAT_MSG_COMBAT_HOSTILE_DEATH") { if (OnUnitKilled == null) { return; } if (!((string)parArgs[0]).Contains("You have")) { return; } OnUnitKilled.Invoke(this, new EventArgs()); } else if (parEvent == "CHAT_MSG_SAY") { if (OnChatMessage == null) { return; } var unitName = (string)parArgs[1]; var chatType = "Say"; var chatTag = (string)parArgs[5]; var chatMessage = (string)parArgs[0]; var args = new ChatMessageArgs(Enums.ChatSenderType.Player, chatTag, unitName, chatType, chatMessage); OnChatMessage.Invoke(this, args); } else if (parEvent == "CHAT_MSG_MONSTER_SAY") { if (OnChatMessage == null) { return; } var unitName = (string)parArgs[1]; var chatType = "Say"; var chatTag = (string)parArgs[5]; var chatMessage = (string)parArgs[0]; var args = new ChatMessageArgs(Enums.ChatSenderType.Npc, chatTag, unitName, chatType, chatMessage); OnChatMessage.Invoke(this, args); } else if (parEvent == "CHAT_MSG_MONSTER_YELL") { if (OnChatMessage == null) { return; } var unitName = (string)parArgs[1]; var chatType = "Yell"; var chatTag = (string)parArgs[5]; var chatMessage = (string)parArgs[0]; var args = new ChatMessageArgs(Enums.ChatSenderType.Npc, chatTag, unitName, chatType, chatMessage); OnChatMessage.Invoke(this, args); } else if (parEvent == "CHAT_MSG_YELL") { if (OnChatMessage == null) { return; } var unitName = (string)parArgs[1]; var chatType = "Yell"; var chatTag = (string)parArgs[5]; var chatMessage = (string)parArgs[0]; var args = new ChatMessageArgs(Enums.ChatSenderType.Player, chatTag, unitName, chatType, chatMessage); OnChatMessage.Invoke(this, args); } else if (parEvent == "CHAT_MSG_CHANNEL") { if (OnChatMessage == null) { return; } var unitName = (string)parArgs[1]; var chatType = "Channel " + (int)parArgs[7]; var chatTag = (string)parArgs[5]; var chatMessage = (string)parArgs[0]; var args = new ChatMessageArgs(Enums.ChatSenderType.Player, chatTag, unitName, chatType, chatMessage); OnChatMessage.Invoke(this, args); } else if (parEvent == "CHAT_MSG_RAID") { if (OnChatMessage == null) { return; } var unitName = (string)parArgs[1]; var chatType = "Raid"; var chatTag = (string)parArgs[5]; var chatMessage = (string)parArgs[0]; var args = new ChatMessageArgs(Enums.ChatSenderType.Player, chatTag, unitName, chatType, chatMessage); OnChatMessage.Invoke(this, args); } else if (parEvent == "CHAT_MSG_GUILD") { if (OnChatMessage == null) { return; } var unitName = (string)parArgs[1]; var chatTag = (string)parArgs[5]; var chatMessage = (string)parArgs[0]; var args = new ChatMessageArgs(Enums.ChatSenderType.Player, chatTag, unitName, "Guild", chatMessage); OnChatMessage.Invoke(this, args); } else if (parEvent == "CHAT_MSG_PARTY") { if (OnChatMessage == null) { return; } var unitName = (string)parArgs[1]; var chatType = "Party"; var chatTag = (string)parArgs[5]; var chatMessage = (string)parArgs[0]; var args = new ChatMessageArgs(Enums.ChatSenderType.Player, chatTag, unitName, chatType, chatMessage); OnChatMessage.Invoke(this, args); } else if (parEvent == "CHAT_MSG_WHISPER") { if (OnChatMessage == null) { return; } var unitName = (string)parArgs[1]; var chatType = "Whisper"; var chatTag = (string)parArgs[5]; var chatMessage = (string)parArgs[0]; var args = new ChatMessageArgs(Enums.ChatSenderType.Player, chatTag, unitName, chatType, chatMessage); OnChatMessage.Invoke(this, args); } else if (parEvent == "DUEL_REQUESTED") { OnDuelRequest?.Invoke(this, new OnRequestArgs((string)parArgs[0])); } else if (parEvent == "GUILD_INVITE_REQUEST") { if (OnGuildInvite == null) { return; } var player = (string)parArgs[0]; var guild = (string)parArgs[1]; OnGuildInvite.Invoke(this, new GuildInviteArgs(player, guild)); } else if (parEvent == "TRADE_SHOW") { OnTradeShow?.Invoke(this, new EventArgs()); } else if (parEvent == "PARTY_INVITE_REQUEST") { OnPartyInvite?.Invoke(this, new OnRequestArgs((string)parArgs[0])); } else if (parEvent == "PLAYER_DEAD") { OnDeath?.Invoke(this, new EventArgs()); } else if (parEvent == "PLAYER_UNGHOST") { OnResurrect?.Invoke(this, new EventArgs()); } else if (parEvent == "CORPSE_IN_RANGE") { OnCorpseInRange?.Invoke(this, new EventArgs()); } else if (parEvent == "CORPSE_OUT_OF_RANGE") { OnCorpseOutOfRange?.Invoke(this, new EventArgs()); } else if (parEvent == "LOOT_OPENED") { LOOT_HANDLE(LootState.SHOW); } else if (parEvent == "LOOT_CLOSED") { LOOT_HANDLE(LootState.CLOSE); } else if (parEvent == "UNIT_AURA") { AuraChanged?.Invoke(this, new AuraChangedArgs((string)parArgs[0])); } else if (parEvent == "CHAT_MSG_SKILL") { OnSkillMessage?.Invoke(this, new OnUiMessageArgs((string)parArgs[0])); } else if (parEvent == "CHAT_MSG_COMBAT_XP_GAIN") { if (OnXpGain == null) { return; } var str = (string)parArgs[0]; var regex = new Regex("(?i)you gain [0-9]+"); var match = regex.Match(str); regex = new Regex("[0-9]+"); str = regex.Match(match.Value).Value; OnXpGain?.Invoke(this, new OnXpGainArgs(Convert.ToInt32(str))); } else if (parEvent == "UNIT_MODEL_CHANGED") { } else if (parEvent == "GOSSIP_SHOW") { GOSSIP_SHOW(); } else if (parEvent == "GOSSIP_CLOSED") { GOSSIP_CLOSED(); } else if (parEvent == "MERCHANT_SHOW") { Console.WriteLine("MERCHANT_SHOW occured"); MERCHANT_HANDLE(MerchantState.SHOW); } else if (parEvent == "MERCHANT_CLOSED") { MERCHANT_HANDLE(MerchantState.CLOSE); } else if (parEvent == "TAXIMAP_OPENED") { TAXIMAP_OPENED(); } else if (parEvent == "TAXIMAP_CLOSED") { TAXIMAP_CLOSED(); } else if (parEvent == "TRAINER_SHOW") { TRAINER_SHOW(); } else if (parEvent == "TRAINER_CLOSED") { TRAINER_CLOSED(); } else if (parEvent == "BANKFRAME_OPENED") { OnBankFrameOpen?.Invoke(this, new EventArgs()); } else if (parEvent == "BANKFRAME_CLOSED") { OnBankFrameClosed?.Invoke(this, new EventArgs()); } else if (parEvent == "MAIL_SHOW") { OnMailboxOpen?.Invoke(this, new EventArgs()); } else if (parEvent == "MAIL_CLOSED") { OnMailboxClosed?.Invoke(this, new EventArgs()); } }
public void ReceiveChat(WorldObject sender, ChatMessageArgs e) { // TODO: Implement }
private void ChatMessageHook(object sender, ChatMessageArgs e) { String[] words = e.Message.Split(' ', '.', ',', '?', '!', ';', ':', '\'', '"'); int argPos = 0; bool marvinFound = e.Data.HasMentionPrefix(_bot.Client.CurrentUser, ref argPos); // Find Marv or Marvin in message if (!marvinFound) { foreach (String word in words) { if (word.Length == 4 && (word[0] == 'M' || word[0] == 'm') && (word[1] == 'A' || word[1] == 'a') && (word[2] == 'R' || word[2] == 'r') && (word[3] == 'V' || word[3] == 'v') || word.Length == 6 && (word[0] == 'M' || word[0] == 'm') && (word[1] == 'A' || word[1] == 'a') && (word[2] == 'R' || word[2] == 'r') && (word[3] == 'V' || word[3] == 'v') && (word[4] == 'I' || word[4] == 'i') && (word[5] == 'N' || word[5] == 'n')) { marvinFound = true; break; } } } if (marvinFound) { int num = 0; bool numFound = false; // Find a number in message foreach (String word in words) { int length = word.Length; if (word.IndexOf("SCP", StringComparison.OrdinalIgnoreCase) == 0) { if (length > 3 && word[3] == '-' && Int32.TryParse(word.Substring(4), out num)) { numFound = true; break; } if (Int32.TryParse(word.Substring(3), out num)) { numFound = true; break; } } else if(Int32.TryParse(word, out num)) { numFound = true; break; } } if (numFound) { ScpObject scp = null; if (Scps.ContainsKey(num)) { scp = Scps[num]; SendMessage(e, scp); } else { try { scp = GrabOnlineVersion(num); } catch (Exception exception) { _bot.WriteConsole("[SCP] Attempt to pull SCP-" + num + " from website has failed!\nDisplaying error info:\n" + exception); } if (scp != null) { Scps.Add(num, scp); SaveChanges(); SendMessage(e, scp); } else { Random rand = new Random(); String response = UnknownResponses[rand.Next(UnknownResponses.Count)].Replace("%s", ScpObject.GetViewId(num)).Replace("%u", e.User.Mention); _bot.Chat.SendMessage(e.Channel, response); } } } } return; }
public override void Execute(ChatMessageArgs message, string arguments) { if (!Service.Accounts.CheckAccess(message.User.Id, "ScpEditObject")) { Service.Chat.SendDirectMessage(message.User, "You do not have permission to edit SCP objects."); return; } List <String> args = ParseArgs(arguments); if (args.Count < 3) { Service.Chat.SendMessage(message.Channel, "Usage: " + Service.Settings.ChatCommandPrefix + "editscp <ID> <FIELD> <INFO>"); return; } int id = 0; if (!Int32.TryParse(args[0], out id)) { Service.Chat.SendMessage(message.Channel, "Usage: " + Service.Settings.ChatCommandPrefix + "editscp <ID> <FIELD> <INFO>"); return; } if (!Service.Scp.Scps.ContainsKey(id)) { Service.Chat.SendMessage(message.Channel, "SCP-" + ScpObject.GetViewId(id) + " does not exist!"); return; } ScpObject scp = Service.Scp.Scps[id]; if (args[1].Equals("name", StringComparison.OrdinalIgnoreCase)) { scp.Name = args[2]; Service.Chat.SendMessage(message.Channel, "Successfully changed SCP-" + ScpObject.GetViewId(id) + "'s name to \"" + args[2] + "\"!"); } else if (args[1].Equals("class", StringComparison.OrdinalIgnoreCase)) { String classChangeStatus = scp.SetObjectClass(args[2]); Service.Chat.SendMessage(message.Channel, "Successfully changed SCP-" + ScpObject.GetViewId(id) + "'s class to \"" + classChangeStatus + "\"!"); } else if (args[1].Equals("description", StringComparison.OrdinalIgnoreCase)) { scp.Description = args[2]; Service.Chat.SendMessage(message.Channel, "Successfully changed SCP-" + ScpObject.GetViewId(id) + "'s description to \n```" + args[2] + "```"); } else if (args[1].Equals("image", StringComparison.OrdinalIgnoreCase)) { scp.Image = args[2]; Service.Chat.SendMessage(message.Channel, "Successfully changed SCP-" + ScpObject.GetViewId(id) + "'s image URL to \n```" + args[2] + "```"); } else if (args[1].Equals("video", StringComparison.OrdinalIgnoreCase)) { scp.Video = args[2]; Service.Chat.SendMessage(message.Channel, "Successfully changed SCP-" + ScpObject.GetViewId(id) + "'s video URL to \n```" + args[2] + "```"); } else { Service.Chat.SendMessage(message.Channel, "Valid field types: \"Name\", \"Class\", or \"Description\"."); return; } scp.EditTime = DateTime.Now; scp.Curated = true; scp.EditorName = message.User.Username + "#" + message.User.Discriminator; Service.Scp.SaveChanges(); return; }
private async void SendMessage(ChatMessageArgs e, ScpObject scp) { Color scpColor; switch (scp.ObjectClass) { case ScpObjectClass.Safe: { scpColor = new Color(0, 255, 0); break; } case ScpObjectClass.Euclid: { scpColor = new Color(255, 255, 0); break; } case ScpObjectClass.Keter: { scpColor = new Color(255, 0, 0); break; } default: { scpColor = new Color(255, 255, 255); break; } } EmbedBuilder embed = new EmbedBuilder { Title = "SCP-" + scp.ViewId + " - " + scp.Name, Color = scpColor, Description = scp.Description, Url = "http://www.scp-wiki.net/scp-" + scp.ViewId, Timestamp = scp.EditTime }; // Object Class EmbedFieldBuilder classField = new EmbedFieldBuilder { Name = "Object Class", Value = scp.ObjectClassName }; embed.Fields.Add(classField); if (!String.IsNullOrWhiteSpace(scp.Video)) { EmbedFieldBuilder videoField = new EmbedFieldBuilder { Name = "Video (O5 ACCESS REQUIRED)", Value = scp.Video }; embed.Fields.Add(videoField); } // Footer EmbedFooterBuilder embedFooter = new EmbedFooterBuilder(); if (scp.Generated && !scp.Curated) { embedFooter.Text = "This info was automatically pulled from wiki via the bot."; } else { embedFooter.Text = "This info was altered by " + scp.EditorName + "."; } embed.Footer = embedFooter; if (!String.IsNullOrWhiteSpace(scp.Image)) { embed.ImageUrl = scp.Image; } await e.Channel.SendMessageAsync("", false, embed.Build()); return; }