Пример #1
0
        static void Main(string[] args)
        {
            IWebclient client = new Webclient("http://pti409368core.venus.fhict.nl/api/");

            var data = new FilterDTO()
            {
                Fields = new List <KeyValuePair <string, string> >()
                {
                    // new KeyValuePair<string, string>("email", "*****@*****.**"),
                    // new KeyValuePair<string, string>("wachtwoord", "asdf123"),
                    // voor inloggen met code:
                    new KeyValuePair <string, string>("code", "55827"),
                    // 55827
                }
            };

            var json = JsonConvert.SerializeObject(data);

            ResultDTO <User> login = client.Send <ResultDTO <User> >(
                data,
                HttpRequestType.POST,
                "user/login"
                );

            foreach (User u in login.Result)
            {
                var cards = client.Send <ResultDTO <Balance> >(null, HttpRequestType.GET, "api/user/" + u.ID + "/cards");
            }
        }
Пример #2
0
 /// <summary>
 /// Load the URI into a string buffer. Use async call in case data is large!
 /// </summary>
 /// <param name="uri">URI of the text file to load</param>
 /// <returns></returns>
 public void GetContents(Uri uri)
 {
     try
     {
         Console.WriteLine($"Loading data from URL:{uri.AbsolutePath}");
         DataContent = Webclient.DownloadString(uri);
     }
     catch (Exception) { }
 }
Пример #3
0
 /// <summary>
 /// Load the URI into a string buffer. Use async call in case data is large!
 /// </summary>
 /// <param name="uri">URI of the text file to load</param>
 /// <returns></returns>
 public async Task <string> GetContentsAsync(Uri uri)
 {
     try
     {
         Console.WriteLine($"Loading data asynchronously from URL:{uri.AbsolutePath}");
         DataContent = await Webclient.DownloadStringTaskAsync(uri);
     }
     catch (Exception) { }
     return(DataContent);
 }
Пример #4
0
        public static async void Checkforupdates()
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Running on " + System.Environment.OSVersion.VersionString);
            Console.ResetColor();
            HttpClient          client = Webclient.Get();
            HttpResponseMessage rm     = await client.GetAsync("https://silverdimond.tk/silvercraftbot/version-info.txt");

            string _content = await rm.Content.ReadAsStringAsync();

            string[] strings  = _content.Split("\n", StringSplitOptions.RemoveEmptyEntries);
            bool     uptodate = true;

            if (strings.Length != 3)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Oh oh someone made an oopsie making the strings not 3. they are curently " + strings.Length);
                Console.ResetColor();
            }
            if (strings[0] != vnumber)
            {
                Console.ForegroundColor = ConsoleColor.DarkBlue;
                Console.WriteLine("You are currently running {0} while the latest version is {1}", vnumber, strings[0]);
                Console.ResetColor();
                uptodate = false;
            }
            if (uptodate)
            {
                Console.ForegroundColor = ConsoleColor.DarkBlue;
                Console.WriteLine("You are currently running {0} which is the latest version according to silverdimond.tk", vnumber);
                Console.ResetColor();
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("You should go to {0} to download a new version of SilverCraftBot", strings[2]);
                Console.ResetColor();
            }
#if DEBUG
            if (!uptodate && (Environment.UserDomainName == null || Environment.UserDomainName == "DESKTOP-QK1H9BG"))
            {
                Console.WriteLine(Environment.UserDomainName);
                using (StreamWriter sw = new StreamWriter("version-info.txt"))
                {
                    sw.WriteLine(vnumber);
                    sw.WriteLine("codname here");
                    sw.WriteLine(ThisAssembly.Git.RepositoryUrl);
                }
                Process.Start("notepad", "version-info.txt");
            }
#endif
        }
Пример #5
0
        public async Task Useragent()
        {
            if (Context.Guild.Id == 699361201586438235 && Commands.Is_at_silvercraft(Context.User) && Commands.Is_bot_admin(Context.User))
            {
                EmbedBuilder b = new EmbedBuilder();

                b.WithTitle("Useragent");
                b.WithDescription(Webclient.Get().DefaultRequestHeaders.UserAgent.ToString());
                await ReplyAsync(embed : b.Build());

                await Webclient.Get().GetAsync("https://silvercraftbotversion.glitch.me/");
            }
        }
Пример #6
0
        public async Task Rdomain(string ee)
        {
            EmbedBuilder b = new EmbedBuilder();

            b.WithFooter(Commands.GetLanguage(Context.Guild.Id).Requested_by + Context.User.Username, Commands.GetUserAvatarUrl(Context.User));
            b.WithTitle("Random tld");
            HttpClient          client = Webclient.Get();
            HttpResponseMessage rm     = await client.GetAsync("https://data.iana.org/TLD/tlds-alpha-by-domain.txt");

            string[]        vs = (await rm.Content.ReadAsStringAsync()).Split('\n');
            RandomGenerator randomGenerator = new RandomGenerator();

            try
            {
                b.WithDescription(ee + "." + vs[randomGenerator.Next(1, vs.Length)]);
            }
            catch (ArgumentOutOfRangeException e)
            {
                b.WithDescription(e.Message);
            }
            await ReplyAsync(embed : b.Build());
        }
Пример #7
0
        public async Task Kindsffeefdfdfergergrgfdfdsgfdfg()
        {
            EmbedBuilder        b      = new EmbedBuilder();
            HttpClient          client = Webclient.Get();
            HttpResponseMessage rm     = await client.GetAsync("https://meme-api.herokuapp.com/gimme");

            if (rm.StatusCode == HttpStatusCode.OK)
            {
                meme asdf = System.Text.Json.JsonSerializer.Deserialize <meme>(await rm.Content.ReadAsStringAsync());
                if (!asdf.nsfw)
                {
                    SilverCraftBot.Modules.Language lang = Commands.GetLanguage(Context.Guild.Id);
                    b.WithTitle("meme: " + asdf.title);
                    b.WithUrl(asdf.postLink);
                    b.WithAuthor("👍 " + asdf.ups + " | r/" + asdf.subreddit);
                    b.WithFooter(lang.Requested_by + Context.User.Username, Commands.GetUserAvatarUrl(Context.User));
                    b.AddField("NSFW", asdf.nsfw, true);
                    b.AddField("Spoiler", asdf.spoiler, true);
                    b.AddField("Author", asdf.author, true);
                    b.WithImageUrl(asdf.url);
                    await ReplyAsync(embed : b.Build());
                }
                else
                {
                    SilverCraftBot.Modules.Language lang = Commands.GetLanguage(Context.Guild.Id);
                    b.WithTitle(lang.Meme_is_nsfw);

                    await ReplyAsync(embed : b.Build());
                }
            }
            else
            {
                b.WithDescription(rm.StatusCode.ToString());
                await ReplyAsync(embed : b.Build());
            }
        }
Пример #8
0
        public async Task GetDJIAForNextWeek()
        {
            var djia = await Webclient.GetDjia(DateTime.Today.AddDays(5), false, false, false);

            Assert.False(djia.Success || !string.IsNullOrWhiteSpace(djia.Data));
        }