private void PostSteamGroupAnnoucement(Bot bot, GameServerRequest gsr) { GameServer gs = bot.Manager.GetServerByID(gsr.ServerID); string[] groupIDHeadlineBody = gsr.Arguments.Split(new char[] { '/' }, 3); var data = new NameValueCollection(); data.Add("sessionID", bot.SteamWeb.SessionId); data.Add("action", "post"); data.Add("languages[0][headline]", groupIDHeadlineBody[1]); data.Add("languages[0][body]", groupIDHeadlineBody[2]); for (int i = 1; i <= 28; i++) { data.Add("languages[" + i + "][body]", ""); data.Add("languages[" + i + "][headline]", ""); data.Add("languages[" + i + "][updated]", "0"); } data.Add("headline", groupIDHeadlineBody[1]); data.Add("body", groupIDHeadlineBody[2]); data.Add("youtubeurl", ""); data.Add("body", "leftthumb"); string link = "https://steamcommunity.com/gid/" + groupIDHeadlineBody[0] + "/announcements"; bot.SteamWeb.Fetch(link, "POST", data); if (gs != null) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.SGAnnoucement, groupIDHeadlineBody[1]); } }
private void HandleMessage(Socket handler, string content) { if (Program.DEBUG) { Console.WriteLine("Received message from server :\n" + content + "\n\n"); } if (!content.StartsWith(password)) { return; } content = content.Replace(password, ""); string[] codeargsdata = content.Split(new char[] { '&' }, 2); string[] idmsgtype = codeargsdata[0].Split(new char[] { '|' }, 2); codeargsdata[1] = codeargsdata[1].Replace("\0", string.Empty); GameServerRequest gsr = new GameServerRequest(handler, idmsgtype[0], idmsgtype[1], codeargsdata[1]); EventArgGameServer arg = new EventArgGameServer(gsr); OnMessageReceived(arg); }
private void HandleMessage(Socket handler, string content) { Console.WriteLine(content); if (!content.StartsWith(password)) { return; } content = content.Replace(password, ""); string[] codeargsdata = content.Split(new char[] { '&' }, 2); string[] idmsgtype = codeargsdata[0].Split(new char[] { '|' }, 2); codeargsdata[1] = codeargsdata[1].Replace("\0", string.Empty); //Must be always true : if (codeargsdata[1].EndsWith("<EOF>")) { codeargsdata[1] = codeargsdata[1].Substring(0, codeargsdata[1].Length - 5); } GameServerRequest gsr = new GameServerRequest(handler, idmsgtype[0], idmsgtype[1], codeargsdata[1]); EventArgGameServer arg = new EventArgGameServer(gsr); OnMessageReceived(arg); }
private void RegisterBot(Bot bot, GameServerRequest gsr) { IPEndPoint ipendpoint = ((IPEndPoint)gsr.Socket.RemoteEndPoint); int index = bot.Manager.Servers.FindIndex(f => f.IP == ipendpoint.Address); if (index >= 0) { return; } SINGLE_SERVER_ID++; GameServer gameserver = new GameServer(gsr.Socket, bot.Manager.Config.TCPPassword, SINGLE_SERVER_ID, gsr.Arguments); GameServer gs = bot.Manager.Servers.Find(srv => srv.SteamID == gameserver.SteamID); if (gs == null) { bot.Manager.Servers.Add(gameserver); } else { gs.Update(gameserver); } }
private void SendChatMessage(Bot bot, GameServerRequest gsr) { string[] steamID_msg = gsr.Arguments.Split(new char[] { '/' }, 2); SteamID steamID = GetSteamIDFromString(steamID_msg[0]); if (steamID == null) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.Simple, "Invalid steam ID (STEAM_X:Y:ZZZZ) !"); } else if (!bot.Friends.Contains(steamID.ConvertToUInt64())) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.NotFriends, steamID.ConvertToUInt64().ToString()); } else { new Thread(() => { Thread.CurrentThread.IsBackground = true; foreach (string line in steamID_msg[1].Split(new[] { "\n" }, StringSplitOptions.None)) { bot.SteamFriends.SendChatMessage(steamID, EChatEntryType.ChatMsg, line); Thread.Sleep(1300); } }).Start(); } }
private void SendFriendInvitation(Bot bot, GameServerRequest gsr) { SteamID steamID = GetSteamIDFromString(gsr.Arguments); if (steamID.IsValid) { bot.SteamFriends.AddFriend(steamID.ConvertToUInt64()); } }
private void SendFriendInvitation(Bot bot, GameServerRequest gsr) { SteamID steamID = new SteamID(gsr.Arguments); if (steamID.IsValid) { bot.SteamFriends.AddFriend(steamID); } }
private void SendTradeOfferInformation(Bot bot, GameServerRequest gsr) { TradeOffer to; if (bot.TradeOfferManager.TryGetOffer(gsr.Arguments, out to)) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.TradeOfferInformation, to.PartnerSteamId.ConvertToUInt64() + "/" + to.OfferState + "/" + to.TradeOfferId); } else { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.TradeOfferInformation, "-1"); } }
private void ReportPlayer(Bot bot, GameServerRequest gsr) { GameServer gs = bot.Manager.GetServerByID(gsr.ServerID); string[] ids = gsr.Arguments.Split('/'); SteamID steamID = GetSteamIDFromString(ids[0]); if (!steamID.IsValid) { return; } SteamID reportedDude = GetSteamIDFromString(ids[1]); if (!steamID.IsValid) { return; } Infos spGuy = bot.GetSteamProfileInfo(steamID); Infos spDude = bot.GetSteamProfileInfo(reportedDude); if (spDude != null && spGuy != null) { string firstMsg = String.Format("{0} ({1}) reported {2} ({3}) for \"{4}\" @ {5} ({6}) !", spGuy.Name, steamID.ToString(), spDude.Name, reportedDude.ToString(), ids[2], DateTime.Now.ToString("dd/MM/yyyy"), DateTime.Now.ToString("HH:mm")); /*string[] data = { spGuy.Name, steamID.ToString(), spDude.Name, reportedDude.ToString(), ids[2], DateTime.Now.ToString("dd/MM/yyyy"), DateTime.Now.ToString("HH:mm") }; * string firstMsg = String.Format("REPORT_MSG_1", data);*/ string secondMsg = String.Format("Name of server : {0}", gs.Name); string thirdMsg = String.Format("Direct URL : steam://connect/{0}:{1}", gs.IP, gs.Port); foreach (SteamID steamid in bot.Friends) { if (bot.Config.IsAdmin(steamid) || bot.Config.IsAdmin(steamid)) { bot.SteamFriends.SendChatMessage(steamid, EChatEntryType.ChatMsg, firstMsg); Thread.Sleep(100); bot.SteamFriends.SendChatMessage(steamid, EChatEntryType.ChatMsg, secondMsg); Thread.Sleep(100); bot.SteamFriends.SendChatMessage(steamid, EChatEntryType.ChatMsg, thirdMsg); } } } else { Program.PrintErrorMessage("One of the following steam ID is wrong !"); Program.PrintErrorMessage("> " + ids[0]); Program.PrintErrorMessage("> " + ids[1]); Program.PrintErrorMessage("Report was denied !"); } }
private void UpdateUserTradeToken(Bot bot, GameServerRequest gsr) { string[] cmdinput = gsr.Arguments.Split("/", 2); string gwgewr = ""; if (cmdinput.Length > 1) { gwgewr = cmdinput[1]; } string token = ""; string argrs = gwgewr.Replace("https://", ""); string[] output = argrs.Split("?"); if (output.Length == 1) { argrs = output[0]; } else { argrs = output[1]; } string[] arg = argrs.Split("&"); if (arg.Length == 1) { token = arg[0]; } else { foreach (string t in arg) { if (t.StartsWith("token=")) { token = t.Replace("token=", ""); break; } } } SteamID steamID = GetSteamIDFromString(cmdinput[0]); if (cmdinput.Length == 1) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.TradeToken, cmdinput[0] + "/malformed_message/" + token); return; } bot.UpdateUserTradeToken(gsr.ServerID, gsr.ModuleID, steamID, token); }
private void ReportPlayer(Bot bot, GameServerRequest gsr) { GameServer gs = bot.Manager.GetServerByID(gsr.ServerID); string[] ids = gsr.Arguments.Split('/'); SteamID steamID = new SteamID(ids[0]); SteamID reportedDude = new SteamID(ids[1]); SteamProfileInfos spGuy = bot.GetSteamProfileInfo(steamID); SteamProfileInfos spDude = bot.GetSteamProfileInfo(reportedDude); if (spDude != null && spGuy != null) { string firstMsg = String.Format("{0} ({1}) reported {2} ({3}) for \"{4}\" @ {5} ({6}) !", spGuy.Name, steamID.ToString(), spDude.Name, reportedDude.ToString(), ids[2], DateTime.Now.ToString("dd/MM/yyyy"), DateTime.Now.ToString("HH:mm")); /*string[] data = { spGuy.Name, steamID.ToString(), spDude.Name, reportedDude.ToString(), ids[2], DateTime.Now.ToString("dd/MM/yyyy"), DateTime.Now.ToString("HH:mm") }; * string firstMsg = String.Format("REPORT_MSG_1", data);*/ string secondMsg = String.Format("Name of server : {0}", gs.Name); string thirdMsg = String.Format("Direct URL : steam://connect/{0}:{1}", gs.IP, gs.Port); foreach (SteamID steamid in bot.Friends) { if (bot.Config.SteamAdmins.Contains(steamid.ToString()) || bot.Config.SteamAdmins.Contains(steamid.ConvertToUInt64().ToString())) { bot.SteamFriends.SendChatMessage(steamid, EChatEntryType.ChatMsg, firstMsg); Thread.Sleep(100); bot.SteamFriends.SendChatMessage(steamid, EChatEntryType.ChatMsg, secondMsg); Thread.Sleep(100); bot.SteamFriends.SendChatMessage(steamid, EChatEntryType.ChatMsg, thirdMsg); } } } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("One of the following steam ID is wrong !"); Console.WriteLine("> " + ids[0]); Console.WriteLine("> " + ids[1]); Console.WriteLine("Report was denied !"); Console.ForegroundColor = ConsoleColor.White; } }
private void SendChatMessage(Bot bot, GameServerRequest gsr) { GameServer gs = bot.Manager.GetServerByID(gsr.ServerID); string[] steamID_msg = gsr.Arguments.Split(new char[] { '/' }, 2); SteamID steamID = new SteamID(steamID_msg[0]); if (steamID == null) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.Simple, "Invalid steam ID (STEAM_X:Y:ZZZZ) !"); } else if (!bot.Friends.Contains(steamID)) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.NotFriends, steamID_msg[0]); } else { bot.SteamFriends.SendChatMessage(steamID, EChatEntryType.ChatMsg, steamID_msg[1]); } }
private void InviteToSteamGroup(Bot bot, GameServerRequest gsr) { GameServer gs = bot.Manager.GetServerByID(gsr.ServerID); string[] steamIDgroupID = gsr.Arguments.Split('/'); if (steamIDgroupID.Length == 2) { SteamID steamID = GetSteamIDFromString(steamIDgroupID[0]); SteamID groupID = GetSteamIDFromString(steamIDgroupID[1]); if (steamID.IsValid) { if (bot.Friends.Contains(steamID.ConvertToUInt64())) { if (groupID.IsValid) { bot.InviteUserToGroup(steamID, groupID); if (gs != null) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.InviteSteamGroup, steamID.ConvertToUInt64().ToString()); } else { Console.WriteLine(">>>> COUDLN'T FIND SERVER; NO REPLY SENT !"); } } } else { if (gs != null) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.NotFriends, steamID.ConvertToUInt64().ToString()); } else { Console.WriteLine(">>>> COUDLN'T FIND SERVER; NO REPLY SENT !"); } } } } }
private void ScanInventory(Bot bot, GameServerRequest gsr, bool withImg) { if (bot.ArkarrSteamMarket == null) { bot.ArkarrSteamMarket = new SteamMarket(bot.Config.ArkarrAPIKey, bot.Config.DisableMarketScan, bot.SteamWeb); } SteamID steamID = GetSteamIDFromString(gsr.Arguments); if (!steamID.IsValid) { return; } /*string token = bot.GetToken(steamID); * if (!bot.Friends.Contains(steamID.ConvertToUInt64()) && token == null) * { * bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.TradeToken, steamID.ConvertToUInt64().ToString()+"/"+"trade_token_not_found"); * return; * }*/ string items = gsr.Arguments + "/"; items += AddInventoryItems(bot, Games.TF2, steamID, withImg) + "/"; items += AddInventoryItems(bot, Games.CSGO, steamID, withImg) + "/"; items += AddInventoryItems(bot, Games.Dota2, steamID, withImg); if (withImg) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.ScanInventoryIMG, items); } else { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.ScanInventory, items); } object[] args = new object[5]; args[0] = items; Program.ExecuteModuleFonction("InventoryItemsChanged", args); }
private void UnhookChat(Bot bot, GameServerRequest gsr) { List <SteamID> toRemove = new List <SteamID>(); foreach (KeyValuePair <SteamID, int> value in bot.ChatListener) { if (value.Value == gsr.ServerID) { SteamID partenar = value.Key; toRemove.Add(partenar); bot.SteamFriends.SendChatMessage(partenar, EChatEntryType.ChatMsg, "Server sent a unhook chat package, disconnecting..."); } } foreach (SteamID cl in toRemove) { bot.ChatListener.Remove(cl); bot.SteamFriends.SendChatMessage(cl, EChatEntryType.ChatMsg, "Done !"); } }
private void ScanInventory(Bot bot, GameServerRequest gsr, bool withImg) { if (bot.ArkarrSteamMarket == null) { bot.ArkarrSteamMarket = new SteamMarket(bot.Config.ArkarrAPIKey, bot.Config.DisableMarketScan, bot.SteamWeb); } SteamID steamID = GetSteamIDFromString(gsr.Arguments); if (!bot.Friends.Contains(steamID.ConvertToUInt64())) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.NotFriends, steamID.ConvertToUInt64().ToString()); return; } Thread invScan = new Thread(() => { Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); Thread.CurrentThread.IsBackground = true; string items = gsr.Arguments + "/"; items += AddInventoryItems(bot, Games.TF2, steamID, withImg) + "/"; items += AddInventoryItems(bot, Games.CSGO, steamID, withImg) + "/"; items += AddInventoryItems(bot, Games.Dota2, steamID, withImg); if (withImg) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.ScanInventoryIMG, items); } else { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.ScanInventory, items); } }); invScan.Start(); invScan.Join(); }
public EventArgGameServer(GameServerRequest gsr) { this.gsr = gsr; }
private void SendSteamID(Bot bot, GameServerRequest gsr) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.SteamID, bot.getSteamID().ConvertToUInt64().ToString()); }
private void CreateTradeOffer(Bot bot, GameServerRequest gsr) { float tradeValue = -1; string message = gsr.Arguments; //STEAM_0:1:42047781/2514414967/NULL/999900.00 //TOOOOOOOOO DOOOOOOOOOOOOOO string[] assetIDs = null; string[] myAssetIDs = null; string[] steamIDitems = message.Split('/'); SteamID steamid = GetSteamIDFromString(steamIDitems[0]); TradeOffer to = bot.TradeOfferManager.NewOffer(steamid); GameServer gameServer = bot.Manager.GetServerByID(gsr.ServerID); if (steamIDitems[1].Length > 1 && steamIDitems[1] != "NULL") { assetIDs = steamIDitems[1].Split(','); List <long> contextId = new List <long>(); contextId.Add(2); bot.OtherGenericInventory.load((int)Games.CSGO, contextId, steamid); foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values) { if (Array.IndexOf(assetIDs, item.assetid.ToString()) > -1) { GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid); to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid); } } bot.OtherGenericInventory.load((int)Games.TF2, contextId, steamid); foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values) { if (Array.IndexOf(assetIDs, item.assetid.ToString()) > -1) { GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid); to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid); } } bot.OtherGenericInventory.load((int)Games.Dota2, contextId, steamid); foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values) { if (Array.IndexOf(assetIDs, item.assetid.ToString()) > -1) { GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid); to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid); } } } if (steamIDitems[2].Length > 1 && steamIDitems[2] != "NULL") { myAssetIDs = steamIDitems[2].Split(','); List <long> contextId = new List <long>(); contextId.Add(2); bot.MyGenericInventory.load((int)Games.CSGO, contextId, steamid); foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values) { if (Array.IndexOf(myAssetIDs, item.assetid.ToString()) > -1) { GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid); to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid); } } bot.MyGenericInventory.load((int)Games.TF2, contextId, steamid); foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values) { if (Array.IndexOf(myAssetIDs, item.assetid.ToString()) > -1) { GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid); to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid); } } bot.MyGenericInventory.load((int)Games.Dota2, contextId, steamid); foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values) { if (Array.IndexOf(myAssetIDs, item.assetid.ToString()) > -1) { GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid); to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid); } } } if (steamIDitems[3] != "NULL") { tradeValue = float.Parse(steamIDitems[3], CultureInfo.InvariantCulture); } string offerId; to.Send(out offerId, String.Format("\"{0}\" the {1}@{2}", gameServer.Name, DateTime.Now.ToString("dd/MM/yyyy"), DateTime.Now.ToString("HH:mm"))); if (offerId != "") { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.CreateTradeOffer, offerId); bot.TradeoffersGS.Add(offerId, gsr.ModuleID + "|" + tradeValue); bot.TradeOfferValue.Add(offerId, tradeValue); bot.AcceptMobileTradeConfirmation(offerId); } else { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.CreateTradeOffer, "-1"); } }
public void Execute(Bot bot, GameServerRequest gsr) { try { switch ((NetworkCode.ASteambotCode)gsr.NetworkCode) { case NetworkCode.ASteambotCode.Core: RegisterBot(bot, gsr); break; case NetworkCode.ASteambotCode.Disconnect: Disconnect(bot, gsr); break; case NetworkCode.ASteambotCode.HookChat: HookChat(bot, gsr); break; case NetworkCode.ASteambotCode.ScanInventory: ScanInventory(bot, gsr, false); break; case NetworkCode.ASteambotCode.ScanInventoryIMG: ScanInventory(bot, gsr, true); break; case NetworkCode.ASteambotCode.CreateTradeOffer: CreateTradeOffer(bot, gsr); break; case NetworkCode.ASteambotCode.FriendInvite: SendFriendInvitation(bot, gsr); break; case NetworkCode.ASteambotCode.ReportPlayer: ReportPlayer(bot, gsr); break; case NetworkCode.ASteambotCode.InviteSteamGroup: InviteToSteamGroup(bot, gsr); break; case NetworkCode.ASteambotCode.Unhookchat: UnhookChat(bot, gsr); break; case NetworkCode.ASteambotCode.SGAnnoucement: PostSteamGroupAnnoucement(bot, gsr); break; case NetworkCode.ASteambotCode.SteamID: SendSteamID(bot, gsr); break; case NetworkCode.ASteambotCode.Simple: SendChatMessage(bot, gsr); break; } /*if (!bot.Friends.Contains(steamID)) * { * bot.Manager.Send(serverID, gsr.ModuleID, NetworkCode.ASteambotCode.NotFriends, gsr.Arguments); * return; * }*/ } catch (Exception e) { var st = new StackTrace(e, true); var frame = st.GetFrame(0); var line = frame.GetFileLineNumber(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e); Console.WriteLine("Crashing while executing net code " + gsr.NetworkCode + " !"); Console.WriteLine("Full detail message [MAY CONTAIN SENSITIVE INFOS] :"); Console.WriteLine("SRV ID : " + gsr.ServerID + " MDL ID: " + gsr.ModuleID); Console.WriteLine(gsr.Arguments); Console.WriteLine("Line number : " + line); Console.ForegroundColor = ConsoleColor.White; } }
private void HookChat(Bot bot, GameServerRequest gsr) { bot.SteamchatHandler.ServerMessage(gsr.ServerID, gsr.Arguments); }
private void Disconnect(Bot bot, GameServerRequest gsr) { bot.Manager.DisconnectServer(gsr.ServerID); }
public void Execute(Bot bot, GameServerRequest gsr) { try { switch ((NetworkCode.ASteambotCode)gsr.NetworkCode) { case NetworkCode.ASteambotCode.Core: RegisterBot(bot, gsr); break; case NetworkCode.ASteambotCode.Disconnect: Disconnect(bot, gsr); break; case NetworkCode.ASteambotCode.HookChat: HookChat(bot, gsr); break; case NetworkCode.ASteambotCode.ScanInventory: ScanInventory(bot, gsr, false); break; case NetworkCode.ASteambotCode.ScanInventoryIMG: ScanInventory(bot, gsr, true); break; case NetworkCode.ASteambotCode.CreateTradeOffer: CreateTradeOffer(bot, gsr); break; case NetworkCode.ASteambotCode.FriendInvite: SendFriendInvitation(bot, gsr); break; case NetworkCode.ASteambotCode.ReportPlayer: ReportPlayer(bot, gsr); break; case NetworkCode.ASteambotCode.InviteSteamGroup: InviteToSteamGroup(bot, gsr); break; case NetworkCode.ASteambotCode.Unhookchat: UnhookChat(bot, gsr); break; case NetworkCode.ASteambotCode.SGAnnoucement: PostSteamGroupAnnoucement(bot, gsr); break; case NetworkCode.ASteambotCode.SteamID: SendSteamID(bot, gsr); break; case NetworkCode.ASteambotCode.Simple: SendChatMessage(bot, gsr); break; case NetworkCode.ASteambotCode.TradeOfferInformation: SendTradeOfferInformation(bot, gsr); break; case NetworkCode.ASteambotCode.TradeToken: UpdateUserTradeToken(bot, gsr); break; } /*if (!bot.Friends.Contains(steamID)) * { * bot.Manager.Send(serverID, gsr.ModuleID, NetworkCode.ASteambotCode.NotFriends, gsr.Arguments); * return; * }*/ } catch (Exception e) { var st = new StackTrace(e, true); var frame = st.GetFrame(0); var line = frame.GetFileLineNumber(); Program.PrintErrorMessage(e.ToString()); Program.PrintErrorMessage("Crashing while executing net code " + gsr.NetworkCode + " !"); Program.PrintErrorMessage("Full detail message [MAY CONTAIN SENSITIVE INFOS] :"); Program.PrintErrorMessage("SRV ID : " + gsr.ServerID + " MDL ID: " + gsr.ModuleID); Program.PrintErrorMessage(gsr.Arguments); Program.PrintErrorMessage("Line number : " + line); Program.PrintErrorMessage("SEND LOGS TO ARKARR (see generated log file) !"); Program.GlobalUnhandledExceptionHandler(e); } }
private void CreateTradeOffer(Bot bot, GameServerRequest gsr) { float tradeValue = -1; string message = gsr.Arguments; string[] assetIDs = null; string[] myAssetIDs = null; string[] steamIDitems = message.Split('/'); SteamID steamid = GetSteamIDFromString(steamIDitems[0]); if (!steamid.IsValid) { return; } TradeOffer to = bot.TradeOfferManager.NewOffer(steamid); GameServer gameServer = bot.Manager.GetServerByID(gsr.ServerID); if (steamIDitems[1].Length > 1 && steamIDitems[1] != "NULL") { assetIDs = steamIDitems[1].Split(','); List <long> contextId = new List <long>(); contextId.Add(2); bot.OtherGenericInventory.load((int)Games.CSGO, contextId, steamid); foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values) { if (Array.IndexOf(assetIDs, item.assetid.ToString()) > -1) { GenericInventory.ItemDescription description = (ItemDescription)bot.OtherGenericInventory.getDescription(item.assetid); to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid); } } bot.OtherGenericInventory.load((int)Games.TF2, contextId, steamid); foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values) { if (Array.IndexOf(assetIDs, item.assetid.ToString()) > -1) { GenericInventory.ItemDescription description = (ItemDescription)bot.OtherGenericInventory.getDescription(item.assetid); to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid); } } bot.OtherGenericInventory.load((int)Games.Dota2, contextId, steamid); foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values) { if (Array.IndexOf(assetIDs, item.assetid.ToString()) > -1) { GenericInventory.ItemDescription description = (ItemDescription)bot.OtherGenericInventory.getDescription(item.assetid); to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid); } } } if (steamIDitems[2].Length > 1 && steamIDitems[2] != "NULL") { myAssetIDs = steamIDitems[2].Split(','); List <long> contextId = new List <long>(); contextId.Add(2); bot.MyGenericInventory.load((int)Games.CSGO, contextId, bot.getSteamID()); foreach (GenericInventory.Item item in bot.MyGenericInventory.items.Values) { if (Array.IndexOf(myAssetIDs, item.assetid.ToString()) > -1) { ItemDescription description = (ItemDescription)bot.MyGenericInventory.getDescription(item.assetid); to.Items.AddMyItem(item.appid, item.contextid, (long)item.assetid); } } bot.MyGenericInventory.load((int)Games.TF2, contextId, bot.getSteamID()); foreach (GenericInventory.Item item in bot.MyGenericInventory.items.Values) { if (Array.IndexOf(myAssetIDs, item.assetid.ToString()) > -1) { ItemDescription description = (ItemDescription)bot.MyGenericInventory.getDescription(item.assetid); to.Items.AddMyItem(item.appid, item.contextid, (long)item.assetid); } } bot.MyGenericInventory.load((int)Games.Dota2, contextId, bot.getSteamID()); foreach (GenericInventory.Item item in bot.MyGenericInventory.items.Values) { if (Array.IndexOf(myAssetIDs, item.assetid.ToString()) > -1) { ItemDescription description = (ItemDescription)bot.MyGenericInventory.getDescription(item.assetid); to.Items.AddMyItem(item.appid, item.contextid, (long)item.assetid); } } } if (steamIDitems[3] != "NULL") { tradeValue = float.Parse(steamIDitems[3], CultureInfo.InvariantCulture); } string offerId = ""; string token = bot.GetToken(steamid); if (bot.Friends.Contains(steamid.ConvertToUInt64())) { to.Send(out offerId, String.Format("\"{0}\" the {1}@{2}", gameServer.Name, DateTime.Now.ToString("dd/MM/yyyy"), DateTime.Now.ToString("HH:mm"))); } else if (token != null) { to.SendWithToken(out offerId, token, String.Format("\"{0}\" the {1}@{2}", gameServer.Name, DateTime.Now.ToString("dd/MM/yyyy"), DateTime.Now.ToString("HH:mm"))); } else { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.TradeToken, steamid.ConvertToUInt64().ToString() + "/" + "trade_token_not_found"); } if (offerId != "") { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.CreateTradeOffer, steamid.ConvertToUInt64() + "/" + offerId); bot.TradeoffersGS.Add(offerId, gsr.ServerID + "|" + gsr.ModuleID + "|" + tradeValue); bot.TradeOfferValue.Add(offerId, tradeValue); bot.AcceptMobileTradeConfirmation(offerId); bot.UpdateTradeOfferInDatabase(to, tradeValue); } else { if (token != null) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.TradeToken, steamid.ConvertToUInt64().ToString() + "/" + "trade_token_invalid"); } bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.CreateTradeOffer, steamid.ConvertToUInt64() + "/" + "-1"); } }