Пример #1
0
        void HandleSpawnIdlerCommand(string msg, SteamID sender)
        {
            string[] args = msg.Split(' ');
            if (args.Length != 2)
            {
                SteamFriends.SendChatMessage(sender, EChatEntryType.ChatMsg,
                                             "Invalid arguments.");
                return;
            }

            int id = 0;

            if (!int.TryParse(args[1], out id))
            {
                SteamFriends.SendChatMessage(sender, EChatEntryType.ChatMsg,
                                             "Invalid idler id.");
                return;
            }

#if DATABASE
            var sql = new PetaPoco.Sql().Select("*").From("account")
                      .Where("id = @0", id);
            var accounts = Database.Query <IdleAccount>(sql);

            foreach (var account in accounts)
            {
                var credentials = new BotCredentials()
                {
                    Username = account.username,
                    Password = account.password,
                    IdlerId  = account.id
                };

                SteamFriends.SendChatMessage(sender, EChatEntryType.ChatMsg,
                                             string.Format("Spawning idler bot: id {0} {1}", account.id,
                                                           account.username));

                var logger = new SteamLogger()
                {
                    Id           = sender,
                    SteamFriends = SteamFriends
                };

                var idlebot = new Bot(logger, ItemsSchema, credentials);

                idlebot.OnWebLoggedOn += (b) =>
                {
                    b.SteamFriends.SetPersonaState(EPersonaState.Online);
                };

                idlebot.Initialize(useUDP: true);
                idlebot.Connect();

                IdlerBots.Add(idlebot);
            }
#endif
        }
Пример #2
0
        static void Main(string[] args)
        {
            var SteamWebClient = new SteamWebClient();

            var bots = new BotCredentials[]
            {
                new BotCredentials()
                {
                    Username = "******", Password = "******"
                }
            };

            var schemaCache = new ItemsSchema(SteamWebClient, STEAM_WEB_KEY);
            var schemas     = schemaCache.LookupSchemas();

            schemaCache.Load(schemas);

            foreach (var botInfo in bots)
            {
                var bot = new Bot(Logger, schemaCache, botInfo);
                bot.Admins.Add(new SteamID(00000000000000000));

                bot.OnWebLoggedOn += (b) =>
                {
                    b.SteamFriends.SetPersonaName("SteamBot");
                    b.SteamFriends.SetPersonaState(EPersonaState.Online);
                };

                bot.Initialize(useUDP: true);
                bot.Connect();

                while (bot.IsRunning)
                {
                    bot.Update();
                    bot.UpdateIdlerBots();
                    Thread.Sleep(1);
                }

                Logger.WriteLine("Bot is shutting down");

                bot.Shutdown();
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            var SteamWebClient = new SteamWebClient();

            var bots = new BotCredentials[]
            {
                new BotCredentials() { Username = "******", Password = "******" }
            };

            var schemaCache = new ItemsSchema(SteamWebClient, STEAM_WEB_KEY);
            var schemas = schemaCache.LookupSchemas();
            schemaCache.Load(schemas);

            foreach(var botInfo in bots)
            {
                var bot = new Bot(Logger, schemaCache, botInfo);
                bot.Admins.Add(new SteamID(00000000000000000));

                bot.OnWebLoggedOn += (b) =>
                {
                    b.SteamFriends.SetPersonaName("SteamBot");
                    b.SteamFriends.SetPersonaState(EPersonaState.Online);
                };

                bot.Initialize(useUDP: true);
                bot.Connect();

                while (bot.IsRunning)
                {
                    bot.Update();
                    bot.UpdateIdlerBots();
                    Thread.Sleep(1);
                }

                Logger.WriteLine("Bot is shutting down");

                bot.Shutdown();
            }
        }