예제 #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            RequestWindowFeature(WindowFeatures.NoTitle);

            SetContentView(Resource.Layout.Main);

            Button buttonConnect = FindViewById <Button>(Resource.Id.ButtonConnect);

            buttonConnect.Click += ClickConnect;

            Button buttonFriends = FindViewById <Button>(Resource.Id.ButtonFriends);

            buttonFriends.Click += ClickFriends;

            SteamAlerts.Initialize(this);

            if (!SteamService.IsRunning())
            {
                Intent steamService = new Intent(this, typeof(SteamService));
                StartService(steamService);
            }

            UpdateButtons();

            SteamService.GetClient().AddHandler(this);
        }
예제 #2
0
        //private readonly Logger _log;

        public GameListBZCCService(/*IBotCredentials creds, DbService db,*/ DiscordSocketClient client, SteamService steam)
        {
            //_creds = creds;
            //_db = db;
            _client = client;

            //_log = LogManager.GetCurrentClassLogger();
            //_log.Info("GameListBZCCService");

            /*var sw = Stopwatch.StartNew();
             * using (var uow = _db.UnitOfWork)
             * {
             *  var items = uow.BZCCGameProperties.GetAll();
             *  BZCCGameProperties = new ConcurrentDictionary<string, ConcurrentDictionary<string, BZCCGameProperty>>();
             *  items.ForEach(BZCCProperty =>
             *  {
             *      lock (BZCCGameProperties)
             *      {
             *          if (!BZCCGameProperties.ContainsKey(BZCCProperty.TermType))
             *              BZCCGameProperties[BZCCProperty.TermType] = new ConcurrentDictionary<string, BZCCGameProperty>();
             *
             *          BZCCGameProperties[BZCCProperty.TermType][BZCCProperty.Term] = BZCCProperty;
             *      }
             *  });
             * }
             * sw.Stop();
             * _log.Debug($"Loaded in {sw.Elapsed.TotalSeconds:F2}s");*/

            _steam = steam;
        }
예제 #3
0
 public void GetSteamProfile()
 {
     Assert.IsNotNull(SteamService.GetSteamProfileAsync("criticalflaw").Result);
     Assert.IsNotNull(SteamService.GetSteamSummaryAsync("criticalflaw").Result);
     Assert.IsNull(SteamService.GetSteamProfileAsync("99999999999999999").Result);
     Assert.IsNull(SteamService.GetSteamSummaryAsync("99999999999999999").Result);
 }
        public SettingsWindow(IServiceProvider serviceProvider)
        {
            InitializeComponent();
            _steamService = serviceProvider.GetService <SteamService>();

            AppsCachedNumber.Content = $"({_steamService.Cache.SourceGames.Count} apps cached)";
        }
예제 #5
0
        /// <summary>
        /// The main.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        static int Main(string[] args)
        {
            try
            {
                configService = new ConfigurationService();
                userService   = new UserService(configService);
                steamService  = new SteamService(configService, userService);

                return(Parser.Default.ParseArguments <AddParams, RunParams, ListParams, DeleteParams, ConfigParams>(args).MapResult(
                           (AddParams opts) => ExecutAddParams(opts),
                           (RunParams opts) => ExecuteRunParams(opts),
                           (ListParams opts) => ExecuteListParams(opts),
                           (DeleteParams opts) => ExecuteDeleteParams(opts),
                           (ConfigParams opts) => ExecuteConfigParams(opts),
                           errs => ExitCodes.GeneralError));
            }
            catch (ApplicationException exception)
            {
                Console.WriteLine(exception.Message);
                ExitWithWait(ExitCodes.ApplicationError);
            }
            catch (FileNotFoundException exception)
            {
                Console.WriteLine(exception.Message);
                ExitWithWait(ExitCodes.ConfigurationError);
            }

            return(0);
        }
예제 #6
0
 public void GetSteamProfile()
 {
     Assert.IsNotNull(SteamService.GetSteamProfileAsync(TestSetup.Tokens.SteamToken, "criticalflaw")
                      .Result);
     Assert.IsNull(SteamService.GetSteamProfileAsync(TestSetup.Tokens.SteamToken, "99999999999999999")
                   .Result);
 }
예제 #7
0
        public void Setup()
        {
            _steamRepositoryMock = new Mock <ISteamRepository>();

            var steamClientMock = new Mock <ISteamClient>();

            steamClientMock.Setup(x => x.GetUserAchievementsForGame(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new PlayerStatsForGame
            {
                Achievements = new List <PlayerAchievement>
                {
                    new PlayerAchievement
                    {
                        Achieved          = 1,
                        Name              = _achievementName1,
                        AchievedTimestamp = "1483002574"
                    },
                    new PlayerAchievement
                    {
                        Achieved          = 1,
                        Name              = _achievementName2,
                        AchievedTimestamp = "1483002574"
                    }
                },
                GameInfo = new GameInfo
                {
                    Name = "Witcher 3"
                }
            });

            var subject = new SteamService(steamClientMock.Object, _steamRepositoryMock.Object);

            var result = subject.UpdateSteamAchievementsFor("211420", "flave_229");
        }
예제 #8
0
        public async Task ProfileAsync()
        {
            var id          = Context.User.Id;
            var color       = Color.Red;
            var description = "You are not registered!";
            var embed       = new LocalEmbedBuilder()
                              .WithTitle("User profile");
            var player = ContrackerService.Contracker
                         .GetPlayer(discordId: id.ToString());

            if (player != null)
            {
                description = "You are gamer.";
                color       = Color.Green;
                var steamname = SteamService.GetSteamName(player.Steam);
                embed.AddField("Discord", Discord.MentionUser(Context.User))
                .AddField("Steam", $"[{steamname}](https://steamcommunity.com/profiles/{player.Steam})")
                .AddField("Total CP", player.Cp)
                .AddField("Stars", player.Stars);
            }

            await ReplyAsync(embed : embed
                             .WithDescription(description)
                             .WithColor(color)
                             .Build()).ConfigureAwait(true);
        }
예제 #9
0
        public async Task SteamGame(CommandContext ctx,
                                    [Description("Game to find on Steam")][RemainingText] string query = "Team Fortress 2")
        {
            try
            {
                var app    = SteamService.GetSteamAppAsync(query).Result;
                var output = new DiscordEmbedBuilder()
                             .WithTitle(app.Name)
                             .WithDescription((Regex.Replace(app.DetailedDescription.Length <= 500 ? app.DetailedDescription : app.DetailedDescription.Substring(0, 250) + "...", "<[^>]*>", "")) ?? "Unknown")
                             .AddField("Release Date", app.ReleaseDate.Date ?? "Unknown", true)
                             .AddField("Developers", app.Developers[0] ?? "Unknown", true)
                             .AddField("Publisher", app.Publishers[0] ?? "Unknown", true)
                             .AddField("Price", (app.IsFree ? "Free" : (app.PriceOverview.FinalFormatted ?? "Unknown")), true)
                             .AddField("Metacritic", app.Metacritic.Score.ToString() ?? "Unknown", true)
                             .WithThumbnailUrl(app.HeaderImage)
                             .WithUrl("http://store.steampowered.com/app/" + app.SteamAppId.ToString())
                             .WithFooter("App ID: " + app.SteamAppId.ToString())
                             .WithColor(new DiscordColor("#1B2838"));

                var genres = new StringBuilder();
                foreach (var genre in app.Genres.Take(3))
                {
                    genres.Append(genre.Description).Append(!genre.Equals(app.Genres.Last()) ? ", " : string.Empty);
                }
                output.AddField("Genres", genres.ToString() ?? "Unknown", true);

                await ctx.RespondAsync(embed : output.Build()).ConfigureAwait(false);
            }
            catch
            {
                await ctx.RespondAsync("Unable to retrieve game information from the Steam API.").ConfigureAwait(false);
            }
        }
예제 #10
0
        public FriendsAdapter(Context context)
        {
            this.context = context;
            friends      = new List <Friend>();
            inflater     = LayoutInflater.FromContext(context);

            SteamService.GetClient().AddHandler(this);
        }
예제 #11
0
        protected override void OnListItemClick(ListView l, View v, int position, long id)
        {
            base.OnListItemClick(l, v, position, id);

            EPersonaState state = stateAdapter.GetItem(position);

            SteamService.GetClient().Friends.SetPersonaState(state);
        }
예제 #12
0
 public SteamServiceTests()
 {
     services = new ServicesBuilder();
     _mocker  = new AutoMocker();
     services.Build(_mocker);
     _steamService = _mocker.CreateInstance <SteamService>();
     _mapsService  = _mocker.CreateInstance <MapsService>();
 }
예제 #13
0
 public APIController(
     DdbService dbdService,
     SteamService steamService
     )
 {
     _dbdService   = dbdService;
     _steamService = steamService;
 }
예제 #14
0
        public override bool OnPrepareOptionsMenu(IMenu menu)
        {
            bool connected = (SteamService.GetClient() != null && SteamService.GetClient().LoggedIn);

            menu.GetItem(0).SetEnabled(connected);
            menu.GetItem(1).SetEnabled(connected);

            return(base.OnPrepareOptionsMenu(menu));
        }
예제 #15
0
        //private readonly Logger _log;

        public GameListBZ98Service(IBotCredentials creds, /*DbService db,*/ DiscordSocketClient client, SteamService steam)
        {
            //_log = LogManager.GetCurrentClassLogger();
            //_log.Info("GameListBZ98Service");
            _creds = creds;
            //_db = db;
            _client = client;

            _steam = steam;
        }
예제 #16
0
        public Friend(SteamID steamId)
        {
            this.steamId = steamId;
            this.name    = Unknown;
            this.avatar  = Unknown;

            adapter = new ChatAdapter(this, SteamAlerts.GetContext());

            SteamService.GetClient().AddHandler(this);
        }
예제 #17
0
        /// <summary>
        /// Sends the message.
        /// </summary>
        /// <param name='message'>
        /// Message.
        /// </param>
        public virtual void SendMessage(String message)
        {
            ChatMessage chatMessage = new ChatMessage(Friend.Me, message);

            adapter.Add(chatMessage);

            SteamService.GetClient().Friends.SendChatMessage(steamId, EChatEntryType.ChatMsg, message);

            adapter.NotifyDataSetChanged();
        }
예제 #18
0
        private async Task RunAsync()
        {
            socketClient = new DiscordSocketClient(new DiscordSocketConfig
            {
                LogLevel            = LogSeverity.Verbose,
                AlwaysDownloadUsers = true
            });
            socketClient.Log += Log;

            restClient = new DiscordRestClient(new DiscordRestConfig
            {
                LogLevel = LogSeverity.Verbose
            });
            restClient.Log += Log;

            if (File.Exists("./update"))
            {
                var temp = File.ReadAllText("./update");
                ulong.TryParse(temp, out updateChannel);
                File.Delete("./update");
                Console.WriteLine($"Found an update file! It contained [{temp}] and we got [{updateChannel}] from it!");
            }

            config = await Config.Load();

            steam = new SteamService();

            map = new ServiceCollection().AddSingleton(socketClient).AddSingleton(config).AddSingleton(steam).BuildServiceProvider();


            await socketClient.LoginAsync(TokenType.Bot, config.Token);

            await socketClient.StartAsync();

            await restClient.LoginAsync(TokenType.Bot, config.Token);

            if (File.Exists("./deadlock"))
            {
                Console.WriteLine("We're recovering from a deadlock.");
                File.Delete("./deadlock");
                (await restClient.GetUserAsync(config.OwnerId))?.SendMessageAsync($"I recovered from a deadlock.\n`{DateTime.Now.ToShortDateString()}` `{DateTime.Now.ToLongTimeString()}`");
            }

            socketClient.GuildAvailable += Client_GuildAvailable;
            socketClient.Disconnected   += SocketClient_Disconnected;

            await steam.Install(map);

            handler = new CommandHandler();
            await handler.Install(map);

            Console.WriteLine("test");

            await Task.Delay(-1);
        }
예제 #19
0
        private void UpdateButtons()
        {
            bool connected = SteamService.GetClient() != null && SteamService.GetClient().LoggedIn;

            Button buttonConnect = FindViewById <Button>(Resource.Id.ButtonConnect);

            buttonConnect.Enabled = !connected;

            Button buttonFriends = FindViewById <Button>(Resource.Id.ButtonFriends);

            buttonFriends.Enabled = connected;
        }
예제 #20
0
                public async Task <RuntimeResult> SetSteamAsync([Remainder] string username)
                {
                    ulong id = await SteamService.GetIdFromVanityAsync(username).ConfigureAwait(false);

                    var record = await UserRepository.GetOrCreateGameAsync(Context.User).ConfigureAwait(false);

                    record.SteamId = id;
                    await UserRepository.SaveRepositoryAsync().ConfigureAwait(false);

                    return(CommandRuntimeResult.FromSuccess(
                               $"Successfully set steam to {Format.Bold((await SteamService.GetProfileAsync(id).ConfigureAwait(false))?.CustomURL ?? id.ToString())}"));
                }
예제 #21
0
        public async Task Update(CommandContext ctx)
        {
            var message = await ctx.RespondAsync("Starting update...").ConfigureAwait(false);

            await SteamService.UpdateSteamListAsync().ConfigureAwait(false);

            await TeamFortressService.UpdateTF2SchemaAsync().ConfigureAwait(false);

            await PokemonService.UpdatePokemonListAsync().ConfigureAwait(false);

            await message.ModifyAsync("Starting update...done!").ConfigureAwait(false);
        }
예제 #22
0
        public override void Init()
        {
            Log.Info("Initializing Torch Client");
            base.Init();

            if (!File.Exists("steam_appid.txt"))
            {
                Directory.SetCurrentDirectory(Path.GetDirectoryName(typeof(VRage.FastResourceLock).Assembly.Location) + "\\..");
            }

            SpaceEngineersGame.SetupBasicGameInfo();
            _startup = new MyCommonProgramStartup(RunArgs);
            if (_startup.PerformReporting())
            {
                return;
            }

            _startup.PerformAutoconnect();
            if (!_startup.CheckSingleInstance())
            {
                return;
            }

            var appDataPath = _startup.GetAppDataPath();

            MyInitializer.InvokeBeforeRun(APP_ID, MyPerGameSettings.BasicGameInfo.ApplicationName, appDataPath);
            MyInitializer.InitCheckSum();
            if (!_startup.Check64Bit())
            {
                return;
            }

            _startup.DetectSharpDxLeaksBeforeRun();
            using (var mySteamService = new SteamService(Game.IsDedicated, APP_ID))
            {
                _renderer = null;
                SpaceEngineersGame.SetupPerGameSettings();

                OverrideMenus();

                InitializeRender();

                _services = new VRageGameServices(mySteamService);
                if (!Game.IsDedicated)
                {
                    MyFileSystem.InitUserSpecific(mySteamService.UserId.ToString());
                }
            }

            _startup.DetectSharpDxLeaksAfterRun();
            MyInitializer.InvokeAfterRun();
        }
예제 #23
0
        public WorkspaceSettingsWindow(IServiceProvider serviceProvider, PoshConsole shellHost, Workspace workspace)
        {
            _shellHost = shellHost;
            _workspace = workspace;
            workspace.UnappliedChanges = false;

            _perforce = serviceProvider.GetService <PerforceService>();
            _steam    = serviceProvider.GetService <SteamService>();

            InitializeComponent();
            MainGrid.DataContext       = workspace;
            BranchSelector.ItemsSource = _steam.Cache.SourceGames;
        }
예제 #24
0
        public override void Init()
        {
            Directory.SetCurrentDirectory(Program.SpaceEngineersInstallAlias);
            MyFileSystem.ExePath = Path.Combine(Program.SpaceEngineersInstallAlias, Program.SpaceEngineersBinaries);
            Log.Info("Initializing Torch Client");
            base.Init();

            SpaceEngineersGame.SetupBasicGameInfo();
            _startup = new MyCommonProgramStartup(RunArgs);
            if (_startup.PerformReporting())
            {
                throw new InvalidOperationException("Torch client won't launch when started in error reporting mode");
            }

            _startup.PerformAutoconnect();
            if (!_startup.CheckSingleInstance())
            {
                throw new InvalidOperationException("Only one instance of Space Engineers can be running at a time.");
            }

            var appDataPath = _startup.GetAppDataPath();

            MyInitializer.InvokeBeforeRun(APP_ID, MyPerGameSettings.BasicGameInfo.ApplicationName, appDataPath);
            MyInitializer.InitCheckSum();
            _startup.InitSplashScreen();
            if (!_startup.Check64Bit())
            {
                throw new InvalidOperationException("Torch requires a 64bit operating system");
            }

            _startup.DetectSharpDxLeaksBeforeRun();
            var steamService = new SteamService(Game.IsDedicated, APP_ID);

            MyServiceManager.Instance.AddService <IMyGameService>(steamService);
            _renderer = null;
            SpaceEngineersGame.SetupPerGameSettings();
            // I'm sorry, but it's what Keen does in SpaceEngineers.MyProgram
#pragma warning disable 612
            SpaceEngineersGame.SetupRender();
#pragma warning restore 612
            InitializeRender();
            if (!_startup.CheckSteamRunning())
            {
                throw new InvalidOperationException("Space Engineers requires steam to be running");
            }

            if (!Game.IsDedicated)
            {
                MyFileSystem.InitUserSpecific(MyGameService.UserId.ToString());
            }
        }
예제 #25
0
        public async Task SteamUser(CommandContext ctx,
                                    [Description("User to find on Steam")][RemainingText] string query)
        {
            if (!BotServices.CheckUserInput(query))
            {
                return;
            }
            var profile = SteamService.GetSteamProfileAsync(query).Result;
            var summary = SteamService.GetSteamSummaryAsync(query).Result;

            if (profile is null && summary is null)
            {
                await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Missing).ConfigureAwait(false);
            }
예제 #26
0
            protected override void OnPostExecute(CallbackMsg result)
            {
                base.OnPostExecute(result);

                SteamClient client = SteamService.GetClient().Client;

                if (result != null)
                {
                    client.FreeLastCallback();

                    SteamService.GetClient().ProcessCallback(result);
                }

                new SteamCallback().Execute();
            }
예제 #27
0
        public async Task Install(IServiceProvider _services)
        {
            // Create Command Service, inject it into Dependency Map
            client   = _services.GetService <DiscordSocketClient>();
            commands = new CommandService();
            //_map.Add(commands);
            services = _services;
            config   = _services.GetService <Config>();
            steam    = _services.GetService <SteamService>();

            await commands.AddModulesAsync(Assembly.GetEntryAssembly(), services);

            //await HelpModule.Install(commands);

            client.MessageReceived += HandleCommand;
        }
        public SteamServiceTests()
        {
            _registryProviderMock = new Mock <IRegistryProvider>();

            _registryProviderMock.Setup(registryProvider => registryProvider.GetValueFromKey <string>(Constants.Steam.Win32RegistryKey, Constants.Steam.InstallPathValue))
            .Returns(() => _win32KeyContents);

            _registryProviderMock.Setup(registryProvider => registryProvider.GetValueFromKey <string>(Constants.Steam.Win64RegistryKey, Constants.Steam.InstallPathValue))
            .Returns(() => _win64KeyContents);

            _fileSystemProviderMock = new Mock <IFileSystemProvider>();

            _libraryFoldersParserMock = new Mock <ILibraryFoldersParser>();

            _steamService = new SteamService(_registryProviderMock.Object, _fileSystemProviderMock.Object, _libraryFoldersParserMock.Object);
        }
예제 #29
0
        private void Connect(String authCode)
        {
            ISharedPreferences pref = PreferenceManager.GetDefaultSharedPreferences(this);

            String username = pref.GetString("prefUsername", "");
            String password = pref.GetString("prefPassword", "");

            if (username.Length > 0 && password.Length > 0)
            {
                SteamService.GetClient().Connect(username, password, authCode);
                SteamAlerts.ShowProgressDialog("Connecting", "Connecting to the Steam servers...", this);
            }
            else
            {
                SteamAlerts.ShowAlertDialog("Warning", "No valid username or password entered", this);
            }
        }
예제 #30
0
        public MainWindow()
        {
            InitializeComponent();

            IServiceCollection services      = new ServiceCollection();
            ILoggerFactory     loggerFactory = new LoggerFactory();

            //loggerFactory.AddEventLog();
            loggerFactory.AddDebug();

            // Init IPC server
            var ipcServer = new IpcServer();

            ipcServer.Start(App.IpcPort);

            // Register the services to the container
            services.AddSingleton(loggerFactory);
            services.AddSingleton(ipcServer);
            services.AddSingleton(typeof(SteamService));
            services.AddSingleton(typeof(PerforceService));
            _serviceProvider = services.BuildServiceProvider();

            // Prepare services for use by the main window
            _steamService    = _serviceProvider.GetService <SteamService>();
            _perforceService = _serviceProvider.GetService <PerforceService>();
            var ipcServerTmp = _serviceProvider.GetService <IpcServer>();

            // Register event handlers
            ipcServerTmp.ReceivedRequest += IpcServer_ReceivedRequest;
            FileSelector.FileOpened      += FileSelector_FileOpened;

            if (_perforceService.P4Exists)
            {
                P4V.IsEnabled     = true;
                P4Merge.IsEnabled = true;
                P4Admin.IsEnabled = true;
            }

            // Handle command line arguments
            HandleArguments(Environment.GetCommandLineArgs().Skip(1));
        }