Example #1
0
        private bool HandleCommand(OutgoingText message)
        {
            if (message.Text.StartsWith("/countusers"))
            {
                Context.Sender.Tell(new IncomingText($"Currently there are {ActiveUsers} active users in {Region}", $"{Region} Master", Region));
                return(true);
            }

            if (message.Text.StartsWith("/addmany"))
            {
                var command = message.Text.Split(" ");
                int howMany = 0;

                if (command.Length >= 2)
                {
                    int.TryParse(command[1], out howMany);
                }

                for (int i = 0; i < howMany; i++)
                {
                    Context.Self.Tell(new NewRegionUser($"OneOfMany{i.ToString()}", true));
                }

                return(true);
            }

            return(false);
        }
Example #2
0
        public async Task SendMessage(string text, string userName, string region)
        {
            var message   = new OutgoingText(text);
            var selection = ActorSystem.ActorSelection($"/user/RegionMaster:{region}/User:{userName}");

            selection.Tell(message);
        }
Example #3
0
        private bool HandleOutgoingText(OutgoingText message)
        {
            if (HandleCommand(message))
            {
                return(true);
            }

            foreach (var user in Context.GetChildren())
            {
                user.Tell(new IncomingText(message.Text, Context.Sender.Path.Name.Split(':').Last(), Region));
            }

            return(true);
        }
Example #4
0
/*
 *      private static double StringCompare(string a, string b)
 *      {
 *          if (a == b)
 *          {
 *              return 100;
 *          }
 *          if ((a.Length == 0) || (b.Length == 0))
 *          {
 *              return 0;
 *          }
 *          double maxLen = a.Length > b.Length ? a.Length : b.Length;
 *          var minLen = a.Length < b.Length ? a.Length : b.Length;
 *          var sameCharAtIndex = 0;
 *          for (var i = 0; i < minLen; i++)
 *          {
 *              if (a[i] == b[i])
 *              {
 *                  sameCharAtIndex++;
 *              }
 *          }
 *          return sameCharAtIndex/maxLen*100;
 *      }
 */

        private static void CreateMenu()
        {
            Config         = MainMenu.AddMenu("Chat Translator", "Config");
            TranslatorMenu = Config.AddSubMenu("Translator", "Translator");
            IncomingText   = Config.AddSubMenu("IncomingText", "IncomingText");
            OutgoingText   = Config.AddSubMenu("OutgoingText", "OutgoingText");
            Position       = Config.AddSubMenu("Position", "Position");
            Logger         = Config.AddSubMenu("Logger", "Logger");
            CopyPaste      = Config.AddSubMenu("Paste", "Paste");

            #region Translator Menu

            TranslatorMenu.Add("Check", new KeyBind("Check", true, KeyBind.BindTypes.HoldActive, 32));

            #endregion

            #region Incoming Text Menu

            IncomingText.AddLabel("From: ");
            var incomingFrom = IncomingText.Add("From", new Slider("From: ", 0, 0, 63));
            incomingFrom.DisplayName    = FromArrayMenu[incomingFrom.CurrentValue];
            incomingFrom.OnValueChange += delegate(ValueBase <int> sender, ValueBase <int> .ValueChangeArgs changeArgs)
            {
                sender.DisplayName = FromArrayMenu[changeArgs.NewValue];
            };

            IncomingText.AddLabel("To: ");
            var incomingTo = IncomingText.Add("To", new Slider("To: ", 0, 0, 62));
            incomingTo.DisplayName    = ToArrayMenu[incomingFrom.CurrentValue];
            incomingTo.OnValueChange += delegate(ValueBase <int> sender, ValueBase <int> .ValueChangeArgs changeArgs)
            {
                sender.DisplayName = ToArrayMenu[changeArgs.NewValue];
            };
            IncomingText.Add("ShowInChat", new CheckBox("Show in chat", false));
            IncomingText.Add("Enabled", new CheckBox("Enabled"));

            #endregion

            #region Outgoing Text Menu

            OutgoingText.AddLabel("From: ");
            var outgoingFrom = OutgoingText.Add("OutFrom", new Slider("From: ", 0, 0, 63));
            outgoingFrom.DisplayName    = FromArrayMenu[outgoingFrom.CurrentValue];
            outgoingFrom.OnValueChange += delegate(ValueBase <int> sender, ValueBase <int> .ValueChangeArgs changeArgs)
            {
                sender.DisplayName = FromArrayMenu[changeArgs.NewValue];
            };

            OutgoingText.AddLabel("To: ");
            var outgoingTo = OutgoingText.Add("OutTo", new Slider("To: ", 0, 0, 62));
            outgoingTo.DisplayName    = ToArrayMenu[outgoingTo.CurrentValue];
            outgoingTo.OnValueChange += delegate(ValueBase <int> sender, ValueBase <int> .ValueChangeArgs changeArgs)
            {
                sender.DisplayName = ToArrayMenu[changeArgs.NewValue];
            };
            OutgoingText.Add("EnabledOut", new CheckBox("Enabled", false));

            #endregion

            #region Position

            Position.Add("Horizontal", new Slider("Horizontal", 15, 1, 2000));
            Position.Add("Vertical", new Slider("Vertical", 500, 1, 2000));
            Position.Add("AutoShow", new CheckBox("Show on message"));
            Position.Add("Duration", new Slider("Duration", 3000, 1000, 8000));

            #endregion

            #region Logger

            Logger.Add("EnabledLog", new CheckBox("Enable"));

            #endregion

            #region Copy Paste

            CopyPaste.Add("Paste", new KeyBind("Paste", false, KeyBind.BindTypes.PressToggle, 'P'));
            CopyPaste.Add("PasteForAll", new KeyBind("Paste for all", false, KeyBind.BindTypes.PressToggle, 'O'));
            CopyPaste.Add("Delay", new Slider("Spam delay", 2000, 0, 2000));
            CopyPaste.Add("DisablePaste", new CheckBox("Disable this section"));
            Config.AddLabel("You can use your own API key");
            Config.AddLabel(
                "AppData\\Roaming\\EloBuddy\\yandexApiKey.txt, copy into the first line \"trnsl.1.1.201...\"");

            #endregion
        }
Example #5
0
 private bool HandleOutgoingText(OutgoingText message)
 {
     Context.Parent.Tell(message);
     return(true);
 }