예제 #1
0
        public static void ValidateDonationAmount(Message m)
        {
            var input = m.Text.Replace("$", "");
            var amt   = 0;

            if (int.TryParse(input, out amt))
            {
#if DEBUG
                var api = RegHelper.GetRegValue("DebugStripeTestAPI");
#elif BETA
                var api = RegHelper.GetRegValue("BetaStripeProdAPI");
#elif RELEASE
                var api = RegHelper.GetRegValue("MainStripeProdAPI");
#endif
                Bot.Api.SendInvoiceAsync(m.From.Id, "Werewolf Donation", "Make a donation to Werewolf to help keep us online", "somepayloadtest", api,
                                         "startparam", "USD", new[] { new LabeledPrice()
                                                                      {
                                                                          Amount = amt * 100, Label = "Donation"
                                                                      } });
            }
            else
            {
                Bot.Api.SendTextMessageAsync(m.From.Id,
                                             "Invalid input.\n" +
                                             "How much would you like to donate?  Please enter a whole number, in US Dollars (USD), in reply to this message",
                                             replyMarkup: new ForceReply {
                    Force = true
                });
            }
        }
예제 #2
0
        public static Task Initialize(long id)
        {
            Commands.Send("Initializing client", id);
            try
            {
                client = new TelegramClient(int.Parse(RegHelper.GetRegValue("appid")),
                                            RegHelper.GetRegValue("apihash"));
            }
            catch { }

            return(client.ConnectAsync());
        }
예제 #3
0
        private static async Task <bool> AuthUser(long groupId)
        {
            if (client == null || !client.IsUserAuthorized())
            {
                if (client == null)
                {
                    await Initialize(groupId);
                }

                if (client.IsUserAuthorized())
                {
                    return(true);
                }

                await Commands.Send("User is not logged in.", groupId);

                var phone = RegHelper.GetRegValue("paraphone");
                await Commands.Send("Sending code request using Paras phone number", groupId);

                var hash = await client.SendCodeRequestAsync(phone);

                await Bot.Send($"Registering bot with phone {phone}, hash code {hash}", UpdateHelper.Devs[0]);

                await Bot.Send(
                    "Please put your Telegram authorization code in the registry as a string value \"authcode\"",
                    UpdateHelper.Devs[0]);

                var authCode = RegHelper.GetRegValue("authcode");
                while (authCode == "0")
                {
                    await Task.Delay(500);

                    authCode = RegHelper.GetRegValue("authcode");
                }

                try
                {
                    var user = await client.MakeAuthAsync(phone, hash, authCode);

                    await Bot.Send($"Signed in as {user.first_name}", UpdateHelper.Devs[0]);
                }
                catch (Exception e)
                {
                    await Bot.Send(e.Message, UpdateHelper.Devs[0]);

                    AuthCode = null;
                    return(false);
                }
            }

            return(true);
        }
예제 #4
0
        private static async Task <bool> AuthUser()
        {
            if (client == null || !client.IsUserAuthorized())
            {
                if (client == null)
                {
                    await Initialize();
                }

                if (client.IsUserAuthorized())
                {
                    return(true);
                }
                var phone = RegHelper.GetRegValue("paraphone");
                var hash  = await client.SendCodeRequestAsync(phone);

                await Bot.Send($"Registering bot with phone {phone}, hash code {hash}", UpdateHelper.Devs[0]);

                await Bot.Send("Please reply to this message with your Telegram authorization code", UpdateHelper.Devs[0]);

                while (AuthCode == null)
                {
                    await Task.Delay(500);
                }
                try
                {
                    var user = await client.MakeAuthAsync(phone, hash, AuthCode);

                    await Bot.Send($"Signed in as {user.first_name}", UpdateHelper.Devs[0]);
                }
                catch (Exception e)
                {
                    await Bot.Send(e.Message, UpdateHelper.Devs[0]);

                    AuthCode = null;
                    return(false);
                }
            }
            return(true);
        }
예제 #5
0
        public static async Task <string> QueueBuild(string buildDefinitionName)
        {
            try
            {
                var url   = "https://parabola949.VisualStudio.com/DefaultCollection/";
                var build = new BuildHttpClient(new Uri(url),
                                                new VssCredentials(new VssBasicCredential("", RegHelper.GetRegValue("VSTSToken"))));

                // First we get project's GUID and buildDefinition's ID.
                // Get the list of build definitions.
                var definitions = await build.GetDefinitionsAsync(project : "Werewolf");

                // Get the specified name of build definition.
                var target = definitions.First(d => d.Name == buildDefinitionName);

                // Build class has many properties, hoqever we can set only these properties.
                //ref: https://www.visualstudio.com/integrate/api/build/builds#queueabuild
                //In this nuget librari, we should set Project property.
                //It requires project's GUID, so we're compelled to get GUID by API.
                try
                {
                    var res = await build.QueueBuildAsync(new Build
                    {
                        Definition = new DefinitionReference
                        {
                            Id = target.Id
                        },
                        Project = target.Project
                    });

                    return($"Queued build with id: {res.Id}");
                }
                catch (VssServiceException e)
                {
                    return($"{e.Message}");
                }
            }
            catch (Exception e)
            {
                var t = e.GetType();
                while (e.InnerException != null)
                {
                    e = e.InnerException;
                }

                return($"{e.Message}\n{e.StackTrace}");
            }
        }
예제 #6
0
 public static Task Initialize()
 {
     client = new TelegramClient(Int32.Parse(RegHelper.GetRegValue("appid")), RegHelper.GetRegValue("apihash"));
     return(client.ConnectAsync());
 }