Beispiel #1
0
        public async Task RunAsync()
        {
            var json = string.Empty;

            using (var fs = File.OpenRead("config.json"))
                using (var sr = new StreamReader(fs, new UTF8Encoding(false)))
                    json = await sr.ReadToEndAsync().ConfigureAwait(false);

            ConfigJson ConfigJson = JsonConvert.DeserializeObject <ConfigJson>(json);

            DiscordConfiguration config = new DiscordConfiguration
            {
                Token           = ConfigJson.Token,
                TokenType       = TokenType.Bot,
                AutoReconnect   = true,
                MinimumLogLevel = Microsoft.Extensions.Logging.LogLevel.Debug
            };

#pragma warning disable IDE0003
            this.Client = new DiscordClient(config);
#pragma warning restore IDE0003

            Client.Ready += OnClientReady;

            CommandsNextConfiguration commandsConfig = new CommandsNextConfiguration
            {
                StringPrefixes       = new string[] { ConfigJson.Prefix },
                EnableDms            = false,
                EnableMentionPrefix  = true,
                IgnoreExtraArguments = true,
            };

            Commands = Client.UseCommandsNext(commandsConfig);

            Commands.CommandErrored += CmdErroredHandler;
            Commands.SetHelpFormatter <CustomHelpFormatter>();

            // Basic:
            Commands.RegisterCommands <Basic>();
            // Economy:
            Commands.RegisterCommands <Balance>();
            Commands.RegisterCommands <Experience>();
            Commands.RegisterCommands <Leaderboards>();
            Commands.RegisterCommands <Transactions>();

            await Client.ConnectAsync();

            // Deserializes Transactions Hooks
            await Transactions.TransactionStartup(Client);

            // Create transaction hub object
            TransactionHub tHub = new TransactionHub();
            // Hook transaction event to method
            tHub.OnTransaction += async(transaction) => await Transactions.HandleTransactionAsync(transaction);

            await Task.Delay(-1);
        }
        public IHttpActionResult PostNotifyChillpay([FromBody] PaymentStatusRes value)
        {
            string  clientHostname = HttpContext.Current.Request.UserHostName;
            string  url            = HttpContext.Current.Request.Path;
            Payment payment        = new Payment();

            try
            {
                if (value.Code == 200 && value.PaymentStatus == 0)
                {
                    payment.setStatusOrder(Int32.Parse(value.OrderNo), "SUC");
                }
                else if (value.Code == 200 && value.PaymentStatus != 0)
                {
                    if (value.PaymentStatus == 1)
                    {
                        payment.setStatusOrder(Int32.Parse(value.OrderNo), "FAL");
                    }
                    else if (value.PaymentStatus == 2 || value.PaymentStatus == 4)
                    {
                        payment.setStatusOrder(Int32.Parse(value.OrderNo), "CAN");
                    }
                    else if (value.PaymentStatus == 3)
                    {
                        payment.setStatusOrder(Int32.Parse(value.OrderNo), "ERR");
                    }
                }
                else if (value.Code != 200)
                {
                    if (value.Code < 2007)
                    {
                        payment.setStatusOrder(Int32.Parse(value.OrderNo), "CAN");
                    }
                    else
                    {
                        payment.setStatusOrder(Int32.Parse(value.OrderNo), "ERR");
                    }
                }
                payment.updateTransaction(value);

                TransactionHub hub = new TransactionHub();
                hub.NotifyPayment(value);
                monitor.sendMessage(url, clientHostname, value, new { request_status = "SUCCESS" });
            }
            catch (Exception e)
            {
                monitor.sendMessage(url, clientHostname, value, new { Message = e.Message });
            }
            return(Ok());
        }
Beispiel #3
0
        public static async Task Main(string[] args)
        {
            // Define two users with SVIDs
            User spike   = new User("u-2a0057e6-356a-4a49-b825-c37796cb7bd9");
            User brendan = new User("u-02c977bb-0a6c-4eb2-bfca-5e9101025aaf");

            // Print their names and balances
            Console.WriteLine($"{await spike.GetUsernameAsync()} has ¢{await spike.GetBalanceAsync()}");
            Console.WriteLine($"{await brendan.GetUsernameAsync()} has ¢{await brendan.GetBalanceAsync()}");

            // Set the key for spike *can also be done as a second argument during creation*
            spike.SetAuthKey("this-is-a-key");

            // Have spike send a transaction to brendan
            TaskResult result = await spike.SendCreditsAsync(100, brendan, "Friend payment");

            // Log the result of the transaction
            Console.WriteLine(result.Info);

            // Need more data?
            // Use "snapshots" to get a large yet non-updating set of data from a group or user
            UserSnapshot snapShot = await spike.GetSnapshotAsync();

            int messageCount = snapShot.discord_message_count;

            Console.WriteLine($"{await spike.GetUsernameAsync()} sent {messageCount} messages!");

            // Create transaction hub object
            TransactionHub tHub = new TransactionHub();

            // Hook transaction event to method
            tHub.OnTransaction += HandleTransaction;

            // Prevent process death
            while (true)
            {
                //Console.WriteLine("Test");
                //Console.WriteLine(tHub.connection.State);
                Thread.Sleep(1000);
            }
        }