示例#1
0
        private async void SendUsage()
        {
            var arch    = Option.Archs().JoinWithComma(ParseMode.Markdown);
            var android = Option.AndroidVerions().JoinWithComma(ParseMode.Markdown);
            var variant = Option.Variants().JoinWithComma(ParseMode.Markdown);

            await BotClient.SendTextAsync(_message,
                                          $"*OpenGapps*\n" +
                                          $"—— Opsi ——\n" +
                                          $"Platform : {arch}\n" +
                                          $"Android : {android}\n" +
                                          $"Variant : {variant}\n" +
                                          $"—— Penggunaan ——\n" +
                                          $"`/gapps platform android`\n" +
                                          $"`/gapps platform android variant`\n" +
                                          $"—— Contoh ——\n" +
                                          $"`/gapps arm 7.1`\n" +
                                          $"`/gapps arm64 9.0 pico`", parse : ParseMode.Markdown);
        }
示例#2
0
        private async Task <Value> GetOption(string data)
        {
            var value = new Value()
            {
                Error = true
            };

            if (string.IsNullOrWhiteSpace(data))
            {
                SendUsage();
                return(value);
            }

            var regex = Regex.Match(data.ToLower(), @"([armx864_]+) ?([0-9]{1,2}.[0-9])? ?([a-zA-Z]+)?", RegexOptions.IgnoreCase);

            if (!regex.Success)
            {
                SendUsage();
                return(value);
            }

            value.Arch    = regex.Groups[1].Value;
            value.Android = regex.Groups[2].Value;
            value.Variant = regex.Groups[3].Value;

            if (string.IsNullOrWhiteSpace(value.Arch) || string.IsNullOrWhiteSpace(value.Android))
            {
                await BotClient.SendTextAsync(_message,
                                              "Definisikan `platform` dan `android` terlebih dahulu!\nGunakan /gapps untuk lebih jelasnya.",
                                              true, parse : ParseMode.Markdown);

                return(value);
            }

            var arch = Option.Archs();

            if (!arch.IsContain(value.Arch))
            {
                var opsi = arch.JoinWithComma(ParseMode.Markdown);
                await BotClient.SendTextAsync(_message,
                                              $"Platform `{value.Arch}` tidak ada dalam data!\nOpsi : {opsi}",
                                              true, parse : ParseMode.Markdown);

                return(value);
            }

            var android = Option.AndroidVerions();

            if (!android.IsContain(value.Android))
            {
                var opsi = android.JoinWithComma(ParseMode.Markdown);
                await BotClient.SendTextAsync(_message,
                                              $"Android `{value.Android}` tidak ada dalam data!\nOpsi : {opsi}",
                                              true, parse : ParseMode.Markdown);

                return(value);
            }

            if (string.IsNullOrWhiteSpace(value.Variant))
            {
                value.Error = false;
                return(value);
            }

            var variant = Option.Variants();

            if (!variant.IsContain(value.Variant))
            {
                var opsi = variant.JoinWithComma(ParseMode.Markdown);
                await BotClient.SendTextAsync(_message,
                                              $"Variant `{value.Variant}` tidak ada dalam data!\nOpsi : {opsi}",
                                              true, parse : ParseMode.Markdown);

                return(value);
            }

            value.Error = false;
            return(value);
        }