public static void ShowSteamProfile(SteamBot.Bot bot, ulong steamId) { var form = new MetroForm(); form.Text = "Steam Community"; form.Width = 800; form.Height = 600; form.Style = Friends.GlobalStyleManager.Style; form.Theme = Friends.GlobalStyleManager.Theme; form.Icon = MistClient.Properties.Resources.Icon; form.ShadowType = MetroFormShadowType.DropShadow; var webControl = new Awesomium.Windows.Forms.WebControl(); webControl.Dock = System.Windows.Forms.DockStyle.Fill; string cookies = string.Format("steamLogin={0}; sessionid={1}", bot.token, bot.sessionId); webControl.WebSession = Awesomium.Core.WebCore.CreateWebSession(new Awesomium.Core.WebPreferences()); webControl.WebSession.SetCookie(new Uri("http://steamcommunity.com"), cookies, true, true); webControl.Source = new Uri((string.Format("http://steamcommunity.com/profiles/{0}/", steamId))); webControl.DocumentReady += webControl_DocumentReady; webControl.TitleChanged += (s, e) => webControl_TitleChanged(s, e, form); form.Controls.Add(webControl); form.Show(); }
public void Update() { if (_connectStarted.Elapsed.TotalSeconds > 120) { _bot?.Disconnect(); Status = ConnectionStatus.Disconnected; } if (Status != ConnectionStatus.Disconnected) { return; } if (string.IsNullOrWhiteSpace(Program.Settings.Username) || string.IsNullOrWhiteSpace(Program.Settings.Password)) { return; } _hasConnected = false; _connectStarted.Restart(); Program.Logger.Info("Connecting"); _bot = new SteamBot(Program.Settings.Username, Program.Settings.Password, Program.Settings.AuthCode); _bot.OnConnected += BotConnected; _bot.OnDisconnected += BotDisconnected; _bot.OnFriendRequest += BotFriendRequest; _bot.OnPrivateEnter += BotPrivateEnter; _bot.OnChatInvite += BotChatInvite; _bot.Connect(); Status = ConnectionStatus.Connecting; }
private void BotChatInvite(SteamBot sender, SteamPersona by, SteamID chat) { if (chat.IsIndividualAccount) { _bot.Join(chat); } }
public Chat(SteamBot.Bot bot) { InitializeComponent(); this.bot = bot; hasFocus = false; Util.LoadTheme(metroStyleManager1); }
public static double GetSteamMarketPrice(SteamBot.Bot bot, GenericInventory.Inventory.Item item, bool withFee = true) { var url = string.Format("http://steamcommunity.com/market/listings/{0}/{1}/render?currency=1", item.AppId, item.MarketHashName); var response = SteamWeb.Fetch(url, "GET", null, bot.botCookies, false); try { var json = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(response); List<double> prices = new List<double>(); int count = 0; var listings = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(Convert.ToString(json.listinginfo)); foreach (var listingItem in listings.Values) { if (listingItem.price == 0) continue; if (count == 3) break; var basePrice = (double)listingItem.converted_price; var fee = withFee ? (double)listingItem.converted_fee : 0; var price = (double)((basePrice + fee) / 100); prices.Add(price); count++; } var totalPrices = 0.0; foreach (var price in prices) { totalPrices += price; } var averagePrice = prices.Count > 0 ? Math.Round(totalPrices / prices.Count, 2) : 0; return averagePrice; } catch { return 0; } }
private void SiteWatcher_OnAdvAvaiable(object sender, EventArgs e) { foreach (var receiver in AdvReceivers) { SteamBot.SendMessage(receiver, $"Reklama dostępna! {Config.WatchedSite}"); } }
private void StartSteamBot() { SteamBot = new SteamBot(Config.Login, Config.Password); SteamBot.AddBasicCommands(Config.BasicCommands); SteamBot.SetWelcomeMessage(Config.WelcomeMessage); SteamBot.SetCommandNotFoundMessage(Config.CommandNotFoundMessage); Console.WriteLine("SteamBot working"); }
public Client(SteamBot bot) { this.Bot = bot; this.Active = new Dictionary<int, ulong>(); this.Channels = new Dictionary<string, ulong>(); this.Objects = new Dictionary<ulong, Dictionary<int, object>>(); this.AuthSequence = 1; }
public static string GetSteamIDInfo(SteamBot.Bot bot, SteamKit2.SteamID steamId) { string output = ""; output += "| steamname: " + bot.SteamFriends.GetFriendPersonaName(steamId); output += "\r\n| steamID32: " + steamId.ToString(); output += "\r\n| steamID64: http://steamcommunity.com/profiles/" + steamId.ConvertToUInt64(); output += "\r\n| steamrep: http://steamrep.com/profiles/" + steamId.ConvertToUInt64(); return output; }
public ShowTrade_Web(SteamBot.Bot bot) { InitializeComponent(); this.Icon = MistClient.Properties.Resources.Icon; this.bot = bot; trade_url = string.Format("http://steamcommunity.com/trade/{0}/", bot.SteamUser.SteamID.ConvertToUInt64()); this.Text = "Trading with " + bot.SteamFriends.GetFriendPersonaName(bot.CurrentTrade.OtherSID); this.baseWidth = webControl1.Width; this.baseZoom = (int)Math.Round((double)baseWidth / 5.43); }
private void BotConnected(SteamBot sender) { _hasConnected = true; _connectStarted.Stop(); _bot.DisplayName = Program.Settings.PersonaName; _bot.PersonaState = EPersonaState.Online; Status = ConnectionStatus.Connected; Program.Logger.Info("Connected"); }
static void Main(string[] args) { SteamBot bot = new SteamBot("botname", "password"); while (true) { if (bot.isReady) { bot.WaitForCallbacks(); } } }
public Friends(SteamBot.Bot bot, string username) { InitializeComponent(); this.MouseWheel += Friends_MouseWheel; webControl1.MouseWheel += Friends_MouseWheel; webControl1.Source = ("file://" + Application.StartupPath + "/Resources/Friends.html").ToUri(); webControl1.DocumentReady += webControl1_DocumentReady; webControl1.ShowContextMenu += webControl1_ShowContextMenu; this.StyleManager = Friends.GlobalStyleManager; this.StyleManager.OnThemeChanged += StyleManager_OnThemeChanged; Util.LoadTheme(this, this.Controls); this.shareUsageStatsToolStripMenuItem.Checked = Properties.Settings.Default.ShareUsageStats; if (Properties.Settings.Default.ShareUsageStats) { Util.SendUsageStats(bot.SteamUser.SteamID); statsSent = true; } this.Text = "Friends"; this.steam_name.Text = username; this.bot = bot; this.steam_name.ContextMenuStrip = menu_status; this.steam_status.ContextMenuStrip = menu_status; this.label_settings.ContextMenuStrip = menu_status; this.text_search.Text = ""; this.steam_status.TextChanged += steam_status_TextChanged; this.minimizeToTrayToolStripMenuItem.Checked = Properties.Settings.Default.MinimizeToTray; this.showOnlineFriendsOnlyToolStripMenuItem.Checked = Properties.Settings.Default.OnlineOnly; logConversationsToolStripMenuItem.Checked = Properties.Settings.Default.KeepLog; keepLog = logConversationsToolStripMenuItem.Checked; // Set colors var onlineColor = ColorTranslator.FromHtml("#5db2ff"); steam_name.ForeColor = onlineColor; steam_status.ForeColor = onlineColor; // Create a simple tray menu with only one item. trayMenu = new ContextMenu(); trayMenu.MenuItems.Add("Show", OnTrayIconDoubleClick); trayMenu.MenuItems.Add("Exit", OnExit); // Create a tray icon. In this example we use a // standard system icon for simplicity, but you // can of course use your own custom icon too. trayIcon = new NotifyIcon(); trayIcon.Text = "Mist"; Bitmap bmp = Properties.Resources.mist_icon; trayIcon.Icon = Icon.FromHandle(bmp.GetHicon()); // Add menu to tray icon and show it. trayIcon.ContextMenu = trayMenu; trayIcon.Visible = false; trayIcon.DoubleClick += new System.EventHandler(this.OnTrayIconDoubleClick); }
public static System.Drawing.Color GetColorFromPersonaState(SteamBot.Bot bot, SteamKit2.SteamID steamId) { var state = bot.SteamFriends.GetFriendPersonaState(steamId); if (state != SteamKit2.EPersonaState.Offline) { var isPlayingGame = !string.IsNullOrEmpty(bot.SteamFriends.GetFriendGamePlayedName(steamId)); if (isPlayingGame) return (System.Drawing.Color)System.Drawing.ColorTranslator.FromHtml("#81b900"); else return (System.Drawing.Color)System.Drawing.ColorTranslator.FromHtml("#5db2ff"); } return System.Drawing.ColorTranslator.FromHtml("#8a8a8a"); }
private void BotDisconnected(SteamBot sender, SteamBotDisconnectReason reason) { if (reason == SteamBotDisconnectReason.SteamGuard) { Thread.Sleep(TimeSpan.FromMinutes(2)); // TODO: need a better way of entering steamguard auth } if (_hasConnected) { Program.Logger.InfoFormat("Disconnected {0}", reason); _hasConnected = false; } Status = ConnectionStatus.Disconnected; }
async Task AsyncMain() { m_isRunning = true; Database = new Database(); DiscordBot = new DiscordBot(); await DiscordBot.StartBot(); SteamWebManager = new SteamWebManager(); SteamBot = new SteamBot(); SteamBot.StartSteam(); while (m_isRunning) { await Task.Delay(100); } }
private void Execute() { var bot = SteamBot.Create("username", "password"); var client = new Client(bot); var machine = MakeMachine(bot, client); var coordinator = new Coordinator <State>(machine, client, bot); machine.Trigger(Event.OPEN_REQUEST); while (machine.State != State.DEAD && bot.State != SteamBot.BotState.Failed) { while (machine.Available) { machine.Consume(); } Thread.Sleep(100); } }
public Friends(SteamBot.Bot bot, string username) { InitializeComponent(); Util.LoadTheme(metroStyleManager1); this.Text = "Friends - Mist v" + mist_ver; this.steam_name.Text = username; this.bot = bot; this.steam_name.ContextMenuStrip = menu_status; this.steam_status.ContextMenuStrip = menu_status; this.label1.ContextMenuStrip = menu_status; this.minimizeToTrayToolStripMenuItem.Checked = Properties.Settings.Default.MinimizeToTray; this.showOnlineFriendsOnlyToolStripMenuItem.Checked = Properties.Settings.Default.OnlineOnly; logConversationsToolStripMenuItem.Checked = Properties.Settings.Default.KeepLog; keepLog = logConversationsToolStripMenuItem.Checked; ListFriends.friends = this; form_friendsHeight = friends_list.Height; form_friendreqHeight = list_friendreq.Height; refreshTimer.Interval = TimerInterval; refreshTimer.Elapsed += (sender, e) => OnTimerElapsed(sender, e); refreshTimer.Start(); // Create a simple tray menu with only one item. trayMenu = new ContextMenu(); trayMenu.MenuItems.Add("Show", OnTrayIconDoubleClick); trayMenu.MenuItems.Add("Exit", OnExit); // Create a tray icon. In this example we use a // standard system icon for simplicity, but you // can of course use your own custom icon too. trayIcon = new NotifyIcon(); trayIcon.Text = "Mist"; Bitmap bmp = Properties.Resources.mist_icon; trayIcon.Icon = Icon.FromHandle(bmp.GetHicon()); // Add menu to tray icon and show it. trayIcon.ContextMenu = trayMenu; trayIcon.Visible = false; trayIcon.DoubleClick += new System.EventHandler(this.OnTrayIconDoubleClick); }
public AddFriend(SteamBot.Bot bot) { InitializeComponent(); this.bot = bot; }
public void Update() { if (_connectStarted.Elapsed.TotalSeconds > 120) { if (_bot != null) { _bot.Disconnect(); } Status = ConnectionStatus.Disconnected; } if (Status != ConnectionStatus.Disconnected) { return; } if (string.IsNullOrWhiteSpace(Program.Settings.Username) || string.IsNullOrWhiteSpace(Program.Settings.Password)) { return; } _hasConnected = false; _connectStarted.Restart(); Program.Logger.Info("Connecting"); _bot = new SteamBot(Program.Settings.Username, Program.Settings.Password, Program.Settings.AuthCode); _bot.OnConnected += sender => { _hasConnected = true; _connectStarted.Stop(); _bot.DisplayName = Program.Settings.PersonaName; _bot.PersonaState = EPersonaState.Online; Status = ConnectionStatus.Connected; Program.Logger.Info("Connected"); }; _bot.OnDisconnected += (sender, reason) => { if (reason == SteamBotDisconnectReason.SteamGuard) { Thread.Sleep(TimeSpan.FromMinutes(2)); // TODO: need a better way of entering steamguard auth } if (_hasConnected) { Program.Logger.InfoFormat("Disconnected {0}", reason); _hasConnected = false; } Status = ConnectionStatus.Disconnected; }; _bot.OnFriendRequest += (sender, user) => _bot.AddFriend(user.Id); _bot.OnPrivateEnter += (sender, chat) => { chat.OnMessage += (chatSender, messageSender, message) => Command.Handle(new CommandTarget(chatSender, messageSender), message, ""); }; _bot.OnChatInvite += (sender, chat, @by) => { if (chat.Id.IsIndividualAccount) { _bot.Join(chat.Id); } }; _bot.Connect(); Status = ConnectionStatus.Connecting; }
private static BufferedMachine <Event, State> MakeMachine( SteamBot bot, Client client) { Machines.Call connect = () => { bot.Connect(); }; Machines.Call open = () => { bot.SetFriendsOnline(bot.Logon.Username); client.Launch(Games.DotaGameId); }; Machines.Call sayHello = () => { client.SayHello(); }; Machines.Call leaveLobby = () => { if (client.Lobby.connect == null) { client.LeaveLobby(); } else { client.AbandonCurrentGame(); } }; Machines.Call getTicket = () => { client.GetAppTicket(); }; Machines.Call createLobby = () => { client.CreateLobby("cow"); }; Machines.Call joinRadiant = () => { client.JoinLobbySlot( SteamKit2.GC.Dota.Internal.DOTA_GC_TEAM.DOTA_GC_TEAM_GOOD_GUYS); }; Machines.Call startLobby = () => { client.LaunchLobby(); }; Machines.Call getAuth = () => { client.CreateAuthTicket(); client.Auth(); }; Machines.Call beginSession = () => { client.BeginGameServerSession(); }; Machines.Call join = () => { string[] split = client.Lobby.connect.Split(':'); var endpoint = new IPEndPoint(IPAddress.Parse(split[0]), Int16.Parse(split[1])); Lara.Join(new ConnectionDetails() { Endpoint = endpoint, SteamId = bot.Client.SteamID.ConvertToUInt64(), Nickname = bot.Logon.Username, SteamworksSessionId = client.SteamworksSessionId, Ticket = client.TicketForServer, Secret = client.Lobby.pass_key }, new AshlyController()); }; Func <State, Machines.MachineBinding <Event, State> > Start = Machines.Start <Event, State>; Func <State, Machines.MachineStateBinding <Event, State> > In = Machines.In <Event, State>; Func <Event, Machines.MachineTransitionBinding <Event, State> > On = Machines.On <Event, State>; var unbuffered = Start(State.CONCEIVED) .Add(In(State.CONCEIVED) .Add(On(Event.OPEN_REQUEST).Transit(State.CONNECTING_TO_STEAM))) .Add(In(State.CONNECTING_TO_STEAM) .Entry(connect) .Add(On(Event.CONNECTED_TO_STEAM).Transit(State.OPENING)) .Add(On(Event.DISCONNECTED_FROM_STEAM).Call(connect).Transit(State.CONNECTING_TO_STEAM))) .Add(In(State.OPENING) .Entry(open) .Add(On(Event.PLAYING_STATE_OPENED).Transit(State.CONNECTING))) .Add(In(State.CONNECTING) .Entry(sayHello) .Add(On(Event.WELCOMED).Transit(State.GETTING_TICKET)) .Add(On(Event.WELCOMED_STALE_LOBBY).Transit(State.IN_STALE_LOBBY))) .Add(In(State.IN_STALE_LOBBY) .Entry(leaveLobby) .Add(On(Event.LEFT_LOBBY).Transit(State.GETTING_TICKET))) .Add(In(State.GETTING_TICKET) .Entry(getTicket) .Add(On(Event.GOT_APP_TICKET).Transit(State.DOTA_HOME))) .Add(In(State.DOTA_HOME) .Entry(createLobby) .Add(On(Event.CREATED_LOBBY).Transit(State.IN_LOBBY))) .Add(In(State.IN_LOBBY) .Entry(joinRadiant) .Add(On(Event.LOBBY_READY).Transit(State.LOBBY_STARTING))) .Add(In(State.LOBBY_STARTING) .Entry(startLobby) .Add(On(Event.SERVER_RUNNING).Transit(State.GETTING_AUTH))) .Add(In(State.GETTING_AUTH) .Entry(getAuth) .Add(On(Event.GOT_AUTH).Transit(State.GETTING_SESSION))) .Add(In(State.GETTING_SESSION) .Entry(beginSession) .Add(On(Event.GOT_SESSION).Transit(State.JOINING_GAME))) .Add(In(State.JOINING_GAME) .Entry(join)) .Build(); return(new BufferedMachine <Event, State>(unbuffered)); }
public ProfileName(SteamBot.Bot bot) { InitializeComponent(); this.bot = bot; }
public void ShowSteamInfo(SteamBot.Bot bot, ulong steamId) { var steamInfo = new MetroForm(); var steamInfoTextBox = new MetroFramework.Controls.MetroTextBox(); steamInfoTextBox.Multiline = true; steamInfoTextBox.Dock = DockStyle.Fill; steamInfoTextBox.Text = Util.GetSteamIDInfo(bot, steamId); steamInfoTextBox.Theme = this.StyleManager.Theme; steamInfoTextBox.Style = this.StyleManager.Style; steamInfo.Icon = MistClient.Properties.Resources.Icon; steamInfo.Width = 435; steamInfo.Height = 155; steamInfo.MaximizeBox = false; steamInfo.MinimizeBox = false; steamInfo.Resizable = false; steamInfo.Text = "Steam Info"; steamInfo.Theme = this.StyleManager.Theme; steamInfo.Style = this.StyleManager.Style; steamInfo.ShadowType = MetroFormShadowType.DropShadow; steamInfo.Controls.Add(steamInfoTextBox); steamInfo.ShowDialog(); }
public AddFriend(SteamBot.Bot bot) { InitializeComponent(); this.bot = bot; Util.LoadTheme(this, this.Controls); }
public Chat(SteamBot.Bot bot) { InitializeComponent(); this.bot = bot; hasFocus = false; }
public Steam() { Status = ConnectionStatus.Disconnected; _bot = null; }
public AddFriend(SteamBot.Bot bot) { InitializeComponent(); this.bot = bot; Util.LoadTheme(metroStyleManager1); }
public ProfileName(SteamBot.Bot bot) { InitializeComponent(); this.bot = bot; Util.LoadTheme(metroStyleManager1); }
private void BotPrivateEnter(SteamBot sender, SteamChat chat) { chat.OnMessage += (chatSender, messageSender, message) => Command.Handle(new CommandTarget(chatSender, messageSender), message, ""); }
private void BotFriendRequest(SteamBot sender, SteamPersona user) { _bot.AddFriend(user.Id); }
public ProfileName(SteamBot.Bot bot) { InitializeComponent(); this.bot = bot; Util.LoadTheme(this, this.Controls); }