public CommandHandler(DiscordSocketClient client, CommandService commands, Microsoft.Extensions.DependencyInjection.ServiceProvider services, OpenDotaApi openDota)
 {
     _commandService = commands;
     _client         = client;
     _openDota       = openDota;
     _services       = services;
 }
Beispiel #2
0
        public async Task MainAsync(string token)
        {
            using (CommandService commandService = new CommandService())
            {
                _client  = new DiscordSocketClient();
                openDota = OpenDotaApi.GetInstance();

                _client.Log += Log;

                await _client.LoginAsync(TokenType.Bot, token);

                await _client.StartAsync();

                var services = new ServiceCollection()
                               .AddSingleton(_client)
                               .AddSingleton <InteractiveService>()
                               .BuildServiceProvider();

                CommandHandler handler = new CommandHandler(_client, commandService, services, openDota);
                await handler.InstallCommandsAsync();

                // Block this task until the program is closed.
                await Task.Delay(-1);
            }
        }
        public async Task <IActionResult> AccountSummary()
        {
            var user = await this.userManager.GetUserAsync(this.User);

            var login = await this.userManager.GetLoginsAsync(user);

            var provKey   = login[0].ProviderKey;
            var steamId64 = this.steamInfoService.GetSteamId64(provKey);
            var steamId32 = this.steamInfoService.Steam64ToSteam32(steamId64);

            var webInterfaceFactory = new SteamWebInterfaceFactory(GlobalConstants.SteamApiKey);

            var steamInterface = webInterfaceFactory.CreateSteamWebInterface <SteamUser>(new HttpClient());

            var playerSummaryResponse = await steamInterface.GetPlayerSummaryAsync((ulong)steamId64);

            var openDota      = new OpenDotaApi();
            var recentMatches = await openDota.Players.GetPlayerRecentMatchesAsync(steamId32);

            var lastMatch = recentMatches.FirstOrDefault();

            var matchDetails = openDota.Matches.GetMatchByIdAsync(lastMatch.MatchId);

            var viewModel = new DotaAccountsViewModel
            {
                Nickname = playerSummaryResponse.Data.Nickname,
                Avatar   = playerSummaryResponse.Data.AvatarMediumUrl,
            };

            return(this.View(viewModel));
        }
        public IEnumerable <Hero> GetAllHeroes()
        {
            var openDota = new OpenDotaApi();

            var heroes = openDota.Heroes.GetHeroesAsync().Result;

            return(heroes);
        }
        public async Task <IActionResult> SteamInfo()
        {
            string sourceTree = "Tenyo";


            var user = await this.userManager.GetUserAsync(this.User);

            var login = await this.userManager.GetLoginsAsync(user);

            var provKey = login[0].ProviderKey;

            var steamId64 = this.steamInfoService.GetSteamId64(provKey);

            var steamId32 = this.steamInfoService.Steam64ToSteam32(steamId64);

            var steamId32ToString = steamId32.ToString();


            var openDota = new OpenDotaApi();

            var player = await openDota.Players.GetPlayerByIdAsync(steamId32);

            ;
            var webInterfaceFactory = new SteamWebInterfaceFactory(GlobalConstants.SteamApiKey);

            ;

            var authserver = (steamId64 - 76561197960265728) & 1;
            var authid     = (steamId64 - 76561197960265728 - authserver) / 2;
            var test       = $"STEAM_0:{authserver}:{authid}";

            ;

            //var player = await openDota.Players.GetPlayerByIdAsync();

            var steamInterface = webInterfaceFactory.CreateSteamWebInterface <SteamUser>(new HttpClient());

            var playerSummaryResponse = await steamInterface.GetPlayerSummaryAsync(76561198053563088);


            var userInfo = new SteamInfoViewModel
            {
                SteamId  = user.Id.ToString(),
                Username = steamId32ToString,
                Login    = login[0].ProviderKey,
            };


            return(this.View(userInfo));
        }
Beispiel #6
0
        public static async Task Main(string[] args)
        {
            //var Steam64ID = 76561198244177142;
            //var d = GetPlayer2(76561198059574062);//99308334


            var openDotaApi = new OpenDotaApi();

            //b00m - Денис API = 3823, Dota2 = NO
            var result = openDotaApi.GetPlayer(long.Parse("76561198244177142"));
            var mmr    = result.MmrEstimate.Estimate;

            //Я рюкзак. - чел у которого есть рейтинг API = 3492, Dota2 = 3560
            var result2 = openDotaApi.GetPlayer(long.Parse("76561198059574062"));
            var mmr2    = result2.MmrEstimate.Estimate;

            Console.WriteLine();



            #region RATING CALCULATION

            //var AElo = 100;
            //var BElo = 100;
            //var AplayedGames = 10;
            //var BplayedGames = 10;



            //var newRatingAWIN = Elo.GetNewEloForA(AElo, BElo, AplayedGames, GameResult.WIN);
            //Console.WriteLine($"A win old={AElo}; new={newRatingAWIN}");

            //var newRatingBLOSE = Elo.GetNewEloForA(BElo, AElo, BplayedGames, GameResult.LOSE);
            //Console.WriteLine($"B lose old={AElo}; new={newRatingBLOSE}");


            //var newRatingADRAW = Elo.GetNewEloForA(AElo, BElo, AplayedGames, GameResult.DRAW);
            //Console.WriteLine($"B DRAW old={AElo}; new={newRatingADRAW}");

            //var newRatingBDRAW = Elo.GetNewEloForA(BElo, AElo, BplayedGames, GameResult.DRAW);
            //Console.WriteLine($"B DRAW old={AElo}; new={newRatingBDRAW}");

            #endregion
        }
 public DistributionsEndpointTests(ITestOutputHelper testOutputHelper)
 {
     this.testOutputHelper = testOutputHelper;
     this.openDotaApi      = new OpenDotaApi();
 }
Beispiel #8
0
 public Dota2(OpenDotaApi openDotaApi, Users users, ScreenshotService screenshotService)
 {
     _openDotaApi       = openDotaApi;
     _users             = users;
     _screenshotService = screenshotService;
 }
 public FindMatchesEndpointTests(ITestOutputHelper testOutputHelper)
 {
     this.testOutputHelper = testOutputHelper;
     this.openDotaApi      = new OpenDotaApi();
 }
Beispiel #10
0
 public SearchEndpointTests(ITestOutputHelper testOutputHelper)
 {
     this.testOutputHelper = testOutputHelper;
     this.openDotaApi      = new OpenDotaApi();
 }
 public HeroStatsEndpointTests(ITestOutputHelper testOutputHelper)
 {
     this.testOutputHelper = testOutputHelper;
     this.openDotaApi      = new OpenDotaApi();
 }
Beispiel #12
0
 public ProPlayersEndpointTests(ITestOutputHelper testOutputHelper)
 {
     this.testOutputHelper = testOutputHelper;
     this.openDotaApi      = new OpenDotaApi();
 }
Beispiel #13
0
 public BenchmarksEndpointTests(ITestOutputHelper testOutputHelper)
 {
     this.testOutputHelper = testOutputHelper;
     this.openDotaApi      = new OpenDotaApi();
 }
 public MetadataEndpointTests(ITestOutputHelper testOutputHelper)
 {
     this.testOutputHelper = testOutputHelper;
     this.openDotaApi      = new OpenDotaApi();
 }
 public RankingsEndpointTests(ITestOutputHelper testOutputHelper)
 {
     this.testOutputHelper = testOutputHelper;
     this.openDotaApi      = new OpenDotaApi();
 }