Пример #1
0
        internal async Task <string> Response(string message)
        {
            if (string.IsNullOrEmpty(message))
            {
                return(null);
            }
            string Ret = string.Empty;

            if (needAuthCode && message.Length == 5)  // if we must handle auth code
            {
                needAuthCode = false;
                authCode     = message;
                steamClient.Connect();
                return(null);
            }
            if (needTwoFactorAuthCode && message.Length == 5)  // if we must handle two factor auth code
            {
                needTwoFactorAuthCode = false;
                twoFactorAuthCode     = message;
                steamClient.Connect();
                return(null);
            }
            if (message.Contains('-'))                                                              // Check if request can be key
            {
                string[] keys = message.Split((char[])null, StringSplitOptions.RemoveEmptyEntries); // Split keys
                if (isKey(keys.First()))                                                            //if first element is key, then lets think all elements are keys
                {
                    var res = await KeyActivate(keys).ConfigureAwait(false);

                    InitializerForm.Invoke(new MethodInvoker(delegate { KeyManager keyManager = new KeyManager(res); keyManager.Show(); }));
                    Ret = "Keys accepted";
                }
            }

            // TODO: Ingame idling function
            // TODO: Play dota like bot
            // TODO: Creating account if cant login
            // TODO: Game adding
            // TODO: Game purchasing - CHECK
            // TODO: Loot trading
            if (string.IsNullOrEmpty(Ret))                                                          // if we dont do something with request already
            {                                                                                       // then lets think its a command
                string[] args = message.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
                if (!args.Any())
                {
                    return(null);
                }

                if (!Commands.ContainsKey(args[0]))
                {
                    Ret = "Invalid command";
                }
                else
                {
                    if (args.Length > 1)
                    {
                        string[] _args = new string[args.Length - 1];
                        for (int i = 0; i < args.Length - 1; i++)
                        {
                            _args[i] = args[i + 1];
                        }

                        Ret = await Commands[args[0]](_args).ConfigureAwait(false);
                    }
                    else
                    {
                        Ret = await Commands[args[0]](null).ConfigureAwait(false);
                    }
                }
            }

            if (!string.IsNullOrEmpty(Ret))
            {
                Log(Ret, LogType.Info);
            }

            return(Ret);
        }