예제 #1
0
 private void Client_OnWhisperCommandReceived(object sender, OnWhisperCommandReceivedArgs e)
 {
     consoleMessage[1] = "**";
     consoleMessage[3] = e.WhisperMessage.Username;
     consoleMessage[4] = e.WhisperMessage.BotUsername;
     consoleMessage[5] = e.WhisperMessage.Message;
     //string message = $"[Twitch:{DateTime.Now.ToShortTimeString()} | Twitch.!W**>>] {e.WhisperMessage.Username}: {e.WhisperMessage.Message}";
     Program.SendToConsole(consoleMessage);
 }
예제 #2
0
 private void whisperCommandReceived(object sender, OnWhisperCommandReceivedArgs e)
 {
     listBox2.Items.Add(e.WhisperMessage.Username + ": " + e.Command + "; args: " + e.ArgumentsAsString + ";");
     foreach (string arg in e.ArgumentsAsList)
     {
         Console.WriteLine("[whisper] arg: " + arg);
     }
     Console.WriteLine("[whisper] args as string: " + e.ArgumentsAsString);
 }
예제 #3
0
        /// <summary>
        /// Invokes the whisper command received.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="badges">The badges.</param>
        /// <param name="colorHex">The color hexadecimal.</param>
        /// <param name="color">The color.</param>
        /// <param name="username">The username.</param>
        /// <param name="displayName">The display name.</param>
        /// <param name="emoteSet">The emote set.</param>
        /// <param name="threadId">The thread identifier.</param>
        /// <param name="messageId">The message identifier.</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="isTurbo">if set to <c>true</c> [is turbo].</param>
        /// <param name="botUsername">The bot username.</param>
        /// <param name="message">The message.</param>
        /// <param name="userType">Type of the user.</param>
        /// <param name="commandText">The command text.</param>
        /// <param name="argumentsAsString">The arguments as string.</param>
        /// <param name="argumentsAsList">The arguments as list.</param>
        /// <param name="commandIdentifier">The command identifier.</param>
        public static void InvokeWhisperCommandReceived(this TwitchClient client, List <KeyValuePair <string, string> > badges, string colorHex, Color color, string username, string displayName, EmoteSet emoteSet, string threadId, string messageId,
                                                        string userId, bool isTurbo, string botUsername, string message, UserType userType, string commandText, string argumentsAsString, List <string> argumentsAsList, char commandIdentifier)
        {
            WhisperMessage whisperMsg          = new WhisperMessage(badges, colorHex, color, username, displayName, emoteSet, threadId, messageId, userId, isTurbo, botUsername, message, userType);
            OnWhisperCommandReceivedArgs model = new OnWhisperCommandReceivedArgs()
            {
                Command = new WhisperCommand(whisperMsg, commandText, argumentsAsString, argumentsAsList, commandIdentifier)
            };

            client.RaiseEvent("OnWhisperCommandReceived", model);
        }
예제 #4
0
 private void Client_OnWhisperCommandReceived(object sender, OnWhisperCommandReceivedArgs e)
 {
     try
     {
         _whisperCommandHandler.Handle(e.Command);
     }
     catch (Exception ex)
     {
         Logger.Instance.Error($"Failed to handle whisper command: {ex.Info()}");
     }
 }
예제 #5
0
        private void ProcessCommand(object sender, OnWhisperCommandReceivedArgs e)
        {
            var user       = e?.Command?.WhisperMessage?.DisplayName ?? "<unknown>";
            var command    = e?.Command?.CommandText ?? "<none>";
            var args       = e?.Command?.ArgumentsAsString ?? string.Empty;
            var argsList   = e?.Command?.ArgumentsAsList ?? new List <string>();
            var channel    = string.Empty;
            var userId     = e?.Command?.WhisperMessage?.UserId ?? string.Empty;
            var clientType = GetType().ToString();

            OnChatCommandReceived?.Invoke(this, new ChatCommandEventArgs(command, argsList, channel, user, userId, clientType));
        }
        public static void ChangeLangPrivateCommandCallback(object s, OnWhisperCommandReceivedArgs e, CommandCallbackArgs args)
        {
            var commandArgs    = e.Command.ArgumentsAsList;
            var channelBotInfo = args.DbContext.ChannelInfos.SingleOrDefault(c =>
                                                                             EF.Functions.ILike(c.ChannelUsername, commandArgs[1]));

            if (channelBotInfo == null)
            {
                return;
            }

            channelBotInfo.Lang = Enum.TryParse <Lang>(commandArgs[0], out var result) ? result : Lang.ru;
        }
        public static void ToggleTestModePrivateCommandCallback(object s, OnWhisperCommandReceivedArgs e,
                                                                CommandCallbackArgs args)
        {
            var channelBotInfo = args.DbContext.ChannelInfos.SingleOrDefault(c =>
                                                                             EF.Functions.ILike(c.ChannelUsername, e.Command.ArgumentsAsString));

            if (channelBotInfo == null)
            {
                return;
            }

            channelBotInfo.IsTestMode = !channelBotInfo.IsTestMode;
        }
예제 #8
0
        private static void OnWhisperCommandReceived(object sender, OnWhisperCommandReceivedArgs e)
        {
            if (Current.Game == null || !ToolkitCoreSettings.allowWhispers)
            {
                return;
            }

            ToolkitChatCommand chatCommand = ChatCommandController.GetChatCommand(e.Command.CommandText);

            if (chatCommand != null)
            {
                chatCommand.TryExecute(e.Command as ITwitchCommand);
            }
        }
예제 #9
0
        //---Whisper Received---//
        private void On_WhisperCommandReceived(object sender, OnWhisperCommandReceivedArgs e)
        {
            Messages temp = WBF.ValidWhisper(e, ref masterList, ref activeList, ref barracks, ref npc, commandSwitch);

            if (temp.wExists)
            {
                client.SendWhisper(e.Command.WhisperMessage.Username, temp.whisper);
                Console.WriteLine($"! : Sent Whisper to {e.Command.WhisperMessage.Username}.");
            }
            Thread.Sleep(500);
            if (temp.mExists)
            {
                client.SendMessage(Credentials.ChannelName, temp.message);
                Console.WriteLine($"! : Sent Message to Chat about {e.Command.WhisperMessage.Username}.");
            }
        }
예제 #10
0
        private void Client_OnWhisperCommandReceived(object sender, OnWhisperCommandReceivedArgs e)
        {
            if (!Hub.Config.Twitch.AllowCommandsViaWhisper || Hub.Config.Twitch.UserBlacklist.Contains(e.Command.WhisperMessage.Username))
            {
                return;
            }

            var msg      = e.Command.WhisperMessage;
            var c        = e.Command.CommandText.ToLower();
            var args     = e.Command.ArgumentsAsString;
            var response = HandleCommand(msg, c, args, true);

            if (response == null)
            {
                return;
            }

            client.SendWhisper(msg.Username, response);
        }
예제 #11
0
        private void OnTwitchWhisperCommand(object sender, OnWhisperCommandReceivedArgs e)
        {
            if (e.Command.WhisperMessage.Username == _configuration.GetSection("twitch")["username"])
            {
                return;
            }

            _logger.LogInformation("Processing whisper command: {WhisperCommandMessage} from User: {WhisperUserName}", e.Command.WhisperMessage.Message, e.Command.WhisperMessage.Username);

            foreach (var commandHandler in _whisperCommandHandlers)
            {
                if (commandHandler.ProcessCommand(_twitchInteractor, e.Command.WhisperMessage.Username, e.Command.CommandText, e.Command.ArgumentsAsList))
                {
                    _logger.LogInformation(
                        "Processed whisper command: {WhisperCommandMessage} using handler: {WhisperCommandHandlerName} from User {WhisperUsername}", e.Command.WhisperMessage.Message, commandHandler.GetType().Name, e.Command.WhisperMessage.Username);
                    return;
                }
            }

            _logger.LogWarning("Failed to process whisper command: {WhisperCommandMessage} from User: {WhisperUserName}, no whisper command handler available!", e.Command.WhisperMessage.Message, e.Command.WhisperMessage.Username);
        }
    private void ClientOnWhisperCommandReceived(object sender, OnWhisperCommandReceivedArgs e)
    {
        Debug.Log(e.Command + " has been received.");

        List <string> splitWhisper = e.ArgumentsAsList;

        string id       = e.WhisperMessage.UserId;
        string username = e.WhisperMessage.DisplayName;

        // Check they have been added as a developer
        if (!developers.ContainsKey(id))
        {
            client.SendWhisper(username, "You are not a developer yet. Please send a message to chat first.");
            return;
        }

        Debug.Log("Do I make it here?");

        if (string.Compare(e.Command, "money", true) == 0)
        {
            Debug.Log("Can I fix it?");
            client.SendWhisper(username, "You have £" + developers[id].developerMoney + ".");
            Debug.Log("Yes I can.");
        }

        else if (string.Compare(e.Command, "skills", true) == 0)
        {
            Debug.Log("Beep. Boop.");
            client.SendWhisper(username, "Lead: " + developers[id].GetSkillLevel(SkillTypes.LeaderSkills.Leadership) + " | Design: " + developers[id].GetSkillLevel(SkillTypes.DeveloperSkills.Design) + " | Develop: " + developers[id].GetSkillLevel(SkillTypes.DeveloperSkills.Development) + " | Art: " + developers[id].GetSkillLevel(SkillTypes.DeveloperSkills.Art) + " | Marketing: " + developers[id].GetSkillLevel(SkillTypes.DeveloperSkills.Marketing) + ".");
        }

        else if (string.Compare(e.Command, "company", true) == 0)
        {
            //Get the company from the developer data
            string companyName = developers[id].companyName;
            Debug.Log("Got the company name.");

            //Mark as true/false by default to avoid issues
            bool companyFounder = true;
            bool companyOwner   = false;

            //Check if they are part of a company
            if (companyName == string.Empty)
            {
                companyFounder = false;
            }

            else
            {
                //If they are part of company, check if they are the owner
                if (companies[companyName].IsOwner(id))
                {
                    Debug.Log(username + " is the Owner of " + companyName);
                    companyOwner = true;
                }
            }

            Debug.Log($"Length of whisper is: {splitWhisper.Count}");

            //Start a company
            if (string.Compare(splitWhisper[0], "start", true) == 0)
            {
                Debug.Log("Creating a company.");

                //Check if player is already part of a company
                if (!companyFounder)
                {
                    companyName = splitWhisper[1];

                    //Check if a company exists
                    if (!companies.ContainsKey(companyName))
                    {
                        company = new CompanyClass(companyName);
                        company.AddFounder(id);
                        developers[id].JoinCompany(companyName);

                        client.SendWhisper(username, "You are now the proud owner of " + companyName + ".");

                        companies.Add(companyName, company);

                        Debug.Log("Company created.");
                    }

                    else
                    {
                        client.SendWhisper(username, "A company already exists with that name. Please choose another.");
                    }
                }

                else
                {
                    client.SendWhisper(username, "You are already part of a company called " + companyName + ".");
                }
            }

            //Invite upto two more people to join the company
            else if (string.Compare(splitWhisper[0], "invite", true) == 0)
            {
                Debug.Log("Inviting someone to join a company.");

                string invitedUsername = splitWhisper[1];

                //Check they are the owner of a company
                if (companyOwner)
                {
                    Debug.Log(username + " is the owner of a company.");

                    company = companies[companyName];

                    //Check the company has less than 3 founders
                    if (company.FounderCount < 3)
                    {
                        Debug.Log("The company has less than 3 founders.");

                        //Check the player is in the system
                        if (DoesUsernameExist(invitedUsername))
                        {
                            Debug.Log(invitedUsername + " is a developer.");

                            string invitedID = GetID(invitedUsername);

                            //Check the player is not already part of a company
                            if (!developers[invitedID].IsFounder)
                            {
                                Debug.Log(invitedUsername + " is not already part of a company.");

                                //Add the invited user to a list
                                company.AddInvite(invitedID);
                                Debug.Log("Invited user has been added to list.");

                                //Give them 5 minutes to respond
                                EnsureMainThread.executeOnMainThread.Enqueue(() => { StartCoroutine(ClearInvite(companyName)); });
                                Debug.Log("ClearInvite has been started.");

                                //Send the invite via whisper. Keep SendMessage just in case it doesn't work for others.
                                client.SendWhisper(invitedUsername, "You have been invited by " + username + " to join their company, " + companyName + ". Type !company accept " + companyName + " in the next 5 minutes to join.");
                                //client.SendMessage(invitedUsername + ", you have been invited to join " + companyName + ". Type !company accept " + companyName + " in the next 5 minutes to join.");
                                Debug.Log("Invite sent.");

                                //Let the founder know an invite was sent
                                client.SendWhisper(username, "An invite has been sent to " + invitedUsername + ".");
                            }

                            else
                            {
                                client.SendWhisper(username, invitedUsername + " is already part of another company.");
                            }
                        }

                        else
                        {
                            client.SendWhisper(username, invitedUsername + " is not a developer. Wait for them to send a message in chat.");
                        }
                    }

                    else
                    {
                        client.SendWhisper(username, "You are not allowed more than 3 founders in a company.");
                    }
                }

                else
                {
                    client.SendWhisper(username, "You have to be the owner of the company to invite founders.");
                }
            }

            else if (string.Compare(splitWhisper[0], "accept", true) == 0)
            {
                Debug.Log("Accepting invite.");

                if (String.IsNullOrEmpty(companyName))
                {
                    Debug.Log(username + " is not part of a company.");

                    companyName = splitWhisper[1];

                    //Check the company exists
                    if (companies.ContainsKey(companyName))
                    {
                        Debug.Log("Company exists.");

                        //Check the company has less than 3 founders
                        if (companies[companyName].FounderCount < 3)
                        {
                            Debug.Log("Company has less than three founders.");

                            company = companies[companyName];

                            //Add them to the company
                            company.AddFounder(id);

                            //Add company to their details
                            developers[id].JoinCompany(companyName);

                            //Let them now they've joined a company
                            client.SendWhisper(username, "You are now a founder of " + companyName + ". You can add funds with !company deposit 1000, etc. to fund projects, and !project start [NAME] to start projects.");
                            //Doesn't send

                            //Get the company founder
                            string founder = GetUsername(company.GetOwner);

                            //Let the founder know the player has joined the company
                            client.SendWhisper(founder, username + " has become a founder of your company, " + companyName + ".");
                        }

                        else
                        {
                            //There are already 3 people
                            client.SendWhisper(username, companyName + " already has three founders.");
                        }
                    }

                    else
                    {
                        //Company doesn't exist
                        client.SendWhisper(username, companyName + " doesn't exist. Check you typed the name correctly.");
                    }
                }

                else
                {
                    client.SendWhisper(username, "You are already part of another company, " + companyName + ".");
                }
            }

            //Add funds to company from player
            else if (string.Compare(splitWhisper[0], "deposit", true) == 0)
            {
                //Check the player is part of a company
                if (companyFounder)
                {
                    int money;

                    if (int.TryParse(splitWhisper[1], out money))
                    {
                        //Check the player has enough funds
                        if (developers[id].HasEnoughMoney(money))
                        {
                            //Transfer funds - Can probably be a function
                            developers[id].SpendMoney(money);
                            companies[companyName].AddMoney(money);

                            client.SendWhisper(username, "You have deposited " + money + ". Now " + companyName + " has " + companies[companyName].money + ", and you have " + developers[id].developerMoney + " left."); //Can probably write this better, but yeah
                        }

                        else
                        {
                            client.SendWhisper(username, "You only have " + developers[id].developerMoney + ".");
                        }
                    }

                    else
                    {
                        client.SendWhisper(username, "To deposit money, you need to use !command deposit 1000, etc.");
                    }
                }

                else
                {
                    client.SendWhisper(username, "You need to be part of a company to deposit money.");
                }
            }

            //Withdraw funds from a company to player
            else if (string.Compare(splitWhisper[0], "withdraw", true) == 0)
            {
                //Check the player is founder of a company
                if (companyFounder)
                {
                    int money;

                    if (int.TryParse(splitWhisper[1], out money))
                    {
                        //Check the company has enough funds
                        if (companies[companyName].HasEnoughMoney(money))
                        {
                            //Transfer funds
                            companies[companyName].SpendMoney(money);
                            developers[id].AddMoney(money);
                        }

                        else
                        {
                            client.SendWhisper(username, "The company only has " + companies[companyName].money + ".");
                        }
                    }

                    else
                    {
                        client.SendWhisper(username, "To withdraw money, you need to use !command withdraw 1000, etc.");
                    }
                }

                else
                {
                    client.SendWhisper(username, "You need to be part of a company to withdraw money.");
                }
            }

            //Edit company data
            else if (string.Compare(splitWhisper[0], "edit", true) == 0)
            {
                //Check they are the owner of the company
                if (companyOwner)
                {
                    string newName = splitWhisper[1];

                    //Change the company name
                    companies[companyName].ChangeName(newName);

                    //Get all the founders
                    //Change the company name in their developer profiles
                    foreach (string developer in companies[companyName].GetFounders)
                    {
                        developers[developer].UpdateCompany(newName); //Make a function
                    }

                    client.SendWhisper(username, "You have changed the name of the company to " + newName);
                }

                else
                {
                    client.SendWhisper(username, "You have to be the company owner to change the name.");
                }
            }

            //Leave company
            else if (string.Compare(splitWhisper[0], "leave", true) == 0)
            {
                //Check they are in a company
                if (companyFounder)
                {
                    companies[companyName].RemoveFounder(id);
                    developers[id].LeaveCompany();

                    client.SendWhisper(username, "You have left " + companyName + ".");
                }

                else
                {
                    client.SendWhisper(username, "You cannot leave a company if you are not part of a company. FailFish");
                }
            }

            else
            {
                Debug.Log("I can't do my damn job!");
            }
        }

        else
        {
            Debug.Log("Boop!");
        }

        //if (string.Compare(e.Command, "project", true) == 0)
        //{
        //    //List<string> splitWhisper = e.ArgumentsAsList;

        //    if (!startProject)
        //    {
        //        if (string.Compare(splitWhisper[0], "start", true) == 0)
        //        {
        //            //Is the player part of a company?
        //            //If yes continue
        //            //If not, tell them they need to be part of a company

        //            uint projectID = (uint)(projects.Count + 1);
        //            project = new ProjectClass(projectID, splitWhisper[1]);

        //            //Add the player to the project team
        //            //Find the company the player is part of ???
        //            //Add the projectID to the player
        //            //Add the projectID to the company

        //            startProject = true;
        //            applyOpen = true;
        //            Invoke("ApplyClose", 120);
        //        }
        //    }

        //    if (applyOpen)
        //    {
        //        if (string.Compare(splitWhisper[0], "apply", true) == 0)
        //        {

        //        }

        //        if (string.Compare(splitWhisper[0], "accept", true) == 0)
        //        {

        //        }
        //    }
        //}
    }
예제 #13
0
    public Messages ValidWhisper(OnWhisperCommandReceivedArgs e, ref List <User> masterList, ref List <string> activeList, ref List <Soldier> barracks, ref List <NPC> npc, int commandSwitch)
    {
        Messages temp = new Messages();

        temp.wExists = true;
        //---XCOM---//
        if (e.Command.CommandText.Equals("enlist"))
        {
            if (e.Command.ArgumentsAsList.Count == 0)
            {
                temp.whisper = "If you are ready to enlist your soldier then please type in '!enlist [FIRST] [NICK] [LAST]' for your Soldier. " +
                               "For example Wittel's Soldier was input as '!enlist Commander Little Wittel' without the quotes. o7";
            }
            else if (e.Command.ArgumentsAsList.Count == 3)
            {
                Soldier soldier = new Soldier();
                soldier.userName   = e.Command.WhisperMessage.Username.ToLower();
                soldier.firstName  = e.Command.ArgumentsAsList[0];
                soldier.nickName   = e.Command.ArgumentsAsList[1];
                soldier.lastName   = e.Command.ArgumentsAsList[2];
                soldier.barracks   = true;
                soldier.x2Barracks = true;

                temp.mExists = true;
                temp.message = e.Command.WhisperMessage.Username + " ! Your Soldier " + soldier.firstName + " '" + soldier.nickName + "' " + soldier.lastName +
                               " has been enlisted in the XCOM Project! Vigilo Confido! o7";
                if (barracks.Exists(x => x.userName.Contains(soldier.userName)))
                {
                    temp.mExists = false;
                    if (barracks[barracks.FindIndex(x => x.userName.Contains(soldier.userName))].active)
                    {
                        temp.whisper = "Sorry " + e.Command.WhisperMessage.Username + "! Your Soldier is currently in Active Duty, and cannot be renamed at this moment.";
                        return(temp);
                    }
                    else if (barracks[barracks.FindIndex(x => x.userName.Contains(soldier.userName))].kIA)
                    {
                        soldier.barracks = false;
                        soldier.kIA      = true;
                        barracks.RemoveAt(barracks.FindIndex(x => x.userName.Contains(soldier.userName)));
                    }
                    else
                    {
                        barracks.RemoveAt(barracks.FindIndex(x => x.userName.Contains(soldier.userName)));
                    }
                }
                barracks.Add(soldier);
                temp.whisper = "Congrats! Your Soldier " + e.Command.ArgumentsAsList[0] + " '" + e.Command.ArgumentsAsList[1] + "' " + e.Command.ArgumentsAsList[2] +
                               " has been added to the Barracks! o7";
            }
            else
            {
                temp.whisper = "Error! Please double check your Enlistment Form!";
            }
        }
        else if (e.Command.CommandText.Equals("npc"))
        {
            if (e.Command.ArgumentsAsList.Count == 0)
            {
                temp.whisper = "INSTRUCTIONS"; //TODO
            }
            else if (e.Command.ArgumentsAsList.Count >= 4)
            {
            }
            else if (e.Command.ArgumentsAsList[0].ToLower().Equals("random"))
            {
                ; //TODO
            }
            else
            {
                temp.whisper = "Something went wrong! Please review the rules for creating a NPC! ('!npc' to see the rules once more)";
            }
        }
        //---General---//
        else if (false)
        {
        }
        else if (e.Command.CommandText.Equals("commands"))
        {
            temp.whisper = "Here are my available commands -> http://bit.ly/WB_Commands";
        }
        else
        {
            temp.whisper = "Sorry! I don't understand that command! Double check or use '!commands' for a detailed list.";
        }
        return(temp);
    }
예제 #14
0
 private void Client_OnWhisperCommandReceived(object sender, OnWhisperCommandReceivedArgs e)
 {
     var asd = e;
 }
예제 #15
0
 /// <summary>
 /// Called when the Twitch bot has received a command through a whisper.
 /// </summary>
 private static void Client_OnWhisperCommandReceived(object sender, OnWhisperCommandReceivedArgs e)
 {
     Console.WriteLine($"[{Program.Name}] Received Whisper Command: {e.Command.WhisperMessage}");
 }
예제 #16
0
 public static void RefreshChannelInfosPrivateCommandCallback(object s, OnWhisperCommandReceivedArgs e, CommandCallbackArgs args)
 {
     args.ChannelBot.ChannelInfo = BotService.LoadChannelInfos(args.DbContext, args.ChannelBot.ChannelInfo.Id).GetAwaiter().GetResult().Single();
     args.Logger.LogInformation("ChannelInfo was refreshed");
 }
예제 #17
0
 private void _client_OnWhisperCommandReceived(object sender, OnWhisperCommandReceivedArgs e)
 {
 }
예제 #18
0
 private void onCommandReceived(object sender, OnWhisperCommandReceivedArgs e)
 {
 }