public static void addMsgOpt(dynamic friendsList, SteamID steamID, string opt) { if (friendsList["steamID"][steamID.ToString()] == null) { friendsList = dumpFriendslist(); } switch (opt.ToLower()) { case "all": case "non": case "online": case "busy": case "away": friendsList["steamID"][steamID.ToString()]["Message_Conditions"] = opt; File.WriteAllText("FriendsList.json", friendsList.ToString()); SteamBot.SteamBot.steamFriends.SendChatMessage( steamID, EChatEntryType.ChatMsg, string.Format("Announcement conditions set to: {0}", opt) ); return; } SteamBot.SteamBot.steamFriends.SendChatMessage( steamID, EChatEntryType.ChatMsg, string.Format("Unknown condition: {0}", opt) ); }
public static bool Msg_Condition(EPersonaState personaState, SteamID steamID) { string state = personaState.ToString(); dynamic friendsList = readFriendsList(); string condition = "online"; if (friendsList["steamID"][steamID.ToString()] == null) { friendsList = dumpFriendslist(); } condition = friendsList["steamID"][steamID.ToString()]["Message_Conditions"]; switch (condition.ToLower()) { case null: if (state == "Online") { return(true); } return(false); case "non": return(false); case "all": if (state != "Offline") { return(true); } return(false); case "busy": if (state != "Away" && state != "Offline") { return(true); } return(false); case "away": if (state != "Busy" && state != "Offline") { return(true); } return(false); case "online": if (state == "Online") { return(true); } return(false); } return(true); }
/// <summary> /// Add the user to the friendslist /// Invite the user to our group and the group passed by the admin /// Allowed string passed by admin: group url, groupID32 and groupID64, groupID64 is prefered because of error measures /// If a url is passed, so get the groupID64 from the grouppage /// groupID32 will be converted into a groupID64 /// Welcome the user to the service and tell him we invited him to our Group /// </summary> /// <param name="_steamFriends"></param> /// <param name="_friendSteamID"></param> /// <param name="_groupID"></param> /// <param name="_steamUserWebAPI"></param> public async Task AcceptFriendRequestAndInviteToGroup(SteamFriends _steamFriends, SteamID _friendSteamID, SteamUserWebAPI _steamUserWebAPI, string _groupID = "") { _steamFriends.AddFriend(_friendSteamID); for (int i = 0; i < _steamFriends.GetClanCount(); i++) { SteamID groupID = _steamFriends.GetClanByIndex(i); if (groupID.ConvertToUInt64().Equals(103582791458407475) && _steamFriends.GetClanName(groupID).ToUpper().Contains("XETAS")) { await _steamUserWebAPI.InviteToGroup(groupID.ToString(), _friendSteamID.ConvertToUInt64().ToString()).ConfigureAwait(false); } if (!string.IsNullOrEmpty(_groupID)) { string groupID64; if (_groupID.Contains("steamcommunity") && _groupID.Contains("groups")) { groupID64 = await _steamUserWebAPI.GetGroupIDFromGroupAdress(_groupID).ConfigureAwait(false); } else { groupID64 = GetGroupID64String(_groupID); } await _steamUserWebAPI.InviteToGroup(groupID64, _friendSteamID.ConvertToUInt64().ToString()).ConfigureAwait(false); } } _steamFriends.SendChatMessage(_friendSteamID, EChatEntryType.ChatMsg, "Hello and welcome to my Service!" + "\nI've invited you to my group, where you can check the other bots or get to learn and trade with other steamusers." + "\nYou can type !c or !commands to see all available commands."); }
public void RendersSteam3ByDefault() { SteamID sid = 76561197969249708; Assert.Equal("[U:1:8983980]", sid.Render()); Assert.Equal("[U:1:8983980]", sid.ToString()); }
static public string accountIDFormat(uint accountID) { var id = new SteamID(); id.AccountID = accountID; return(id.ToString()); }
/// <summary> /// Checks players groups against the config value set in the plugin config to see if they're a VIP. /// </summary> /// <returns>true if a match is found.</returns> public bool IsVip() { if (!IsValid()) { return(false); } return(R.Permissions.GetGroups(new RocketPlayer(SteamID.ToString()), true).FirstOrDefault(g => g.Id == PlayerInfoLib.Instance.Configuration.Instance.VipCheckGroupName) != null); }
/// <summary> /// Accepts the invite to a Steam Group /// </summary> /// <param name="group">SteamID of the group to accept the invite from.</param> private void AcceptGroupInvite(SteamID group) { var acceptMsg = new ClientMsg <CMsgGroupInviteAction>((int)EMsg.ClientAcknowledgeClanInvite); acceptMsg.Body.GroupID = group.ConvertToUInt64(); acceptMsg.Body.AcceptInvite = true; SteamClient.Send(acceptMsg); Log.Success("Accepted group invite to {0}.", group.ToString()); }
public string Retrieve(SteamID steamID) { var account = steamID.ToString(); if (Data.Cache.ContainsKey(account)) { return(Data.Cache[account]); } return(""); }
public SteamAccountHyperlinkModel(int accountId) { var steamId = new SteamID((uint)accountId, EUniverse.Public, EAccountType.Individual).ConvertToUInt64(); this.AccountName = SettingsProvider.GetInstance().SteamAccounts.FirstOrDefault(a => a.SteamId == steamId)?.Login ?? steamId.ToString(); this.AccountLink = $"https://steamcommunity.com/profiles/{steamId}/"; }
/// <summary> /// Declines the invite to a Steam Group /// </summary> /// <param name="group">SteamID of the group to decline the invite from.</param> private void DeclineGroupInvite(SteamID group) { var declineMsg = new ClientMsg <CMsgGroupInviteAction>((int)EMsg.ClientAcknowledgeClanInvite); declineMsg.Body.GroupID = group.ConvertToUInt64(); declineMsg.Body.AcceptInvite = false; SteamClient.Send(declineMsg); Log.Info("Declined group invite to {0}.", group.ToString()); }
static public bool checkAdmin(SteamID sid) { if (admins.Contains(sid.ToString())) { return(true); } else { steamFriends.SendChatMessage(sid, EChatEntryType.ChatMsg, "You cannot use this command because you're not an admin."); } return(false); }
public void Steam2RenderIsValid() { SteamID sid = 76561197969249708; Assert.Equal("STEAM_0:0:4491990", sid.Render()); Assert.Equal(sid.Render(), sid.ToString()); sid.AccountUniverse = EUniverse.Beta; Assert.Equal("STEAM_2:0:4491990", sid.Render()); sid.AccountType = EAccountType.GameServer; Assert.Equal("157625991261918636", sid.Render()); }
public void Store(SteamID steamID, string name) { var account = steamID.ToString(); if (!Data.Cache.ContainsKey(account)) { Data.Cache.Add(account, name); } else { Data.Cache[account] = name; } Save(); }
public void HandleMessage(SteamID partenar, string msg) { if (!bot.Manager.Config.SteamAdmins.Contains(partenar.ToString())) { if (!bot.Manager.Config.SteamAdmins.Contains(partenar.ConvertToUInt64().ToString())) { return; } } string command = msg.Split(' ')[0]; string message = msg.Replace(command + " ", ""); if (!command.Equals("STOPHOOK") && !command.Equals("UNHOOK") && bot.ChatListener.ContainsKey(partenar)) { SendMessageToGameServer(-2, partenar, msg); return; } switch (command) { case "help": case "HELP": PrintHelp(partenar); break; case "SERVER": PrintServer(partenar, command); break; case "HOOKCHAT": case "HOOKVOICE": HookGameServerChat(Networking.NetworkCode.MSG_FOR_ALL_MODULE, partenar, message); break; case "UNHOOK": case "STOPHOOK": StopHook(Networking.NetworkCode.MSG_FOR_ALL_MODULE, partenar); break; case "EXEC": ExecuteServerCommand(partenar, message); break; default: //bot.SteamFriends.SendChatMessage(partenar, EChatEntryType.ChatMsg, "Sorry I don't understand you. Yet."); PrintChatMessage(partenar, msg); break; } }
void OnLoggedOn(SteamUser.LoggedOnCallback callback) { if (callback.Result == EResult.AccountLogonDenied) { Console.WriteLine("Steam Guard denied your a(cce)ss!", Console.ForegroundColor = ConsoleColor.Green); Console.WriteLine("Please enter code that you got emailed!", Console.ForegroundColor = ConsoleColor.Green); Console.ResetColor(); Console.Write("AuthCode> "); authCode = Console.ReadLine(); Console.WriteLine("Your Authcode is: " + authCode); return; } if (callback.Result == EResult.AccountLoginDeniedNeedTwoFactor) { Console.WriteLine("Steam Guard denied your a(cce)ss!", Console.ForegroundColor = ConsoleColor.Green); Console.WriteLine("Please enter code from two-factor authentication (ie. from your mobile app)!: ", Console.ForegroundColor = ConsoleColor.Green); Console.ResetColor(); Console.Write("Two-Factor Code> "); twofactor = Console.ReadLine(); return; } if (callback.Result == EResult.LogonSessionReplaced || callback.Result == EResult.LoggedInElsewhere || callback.Result == EResult.AlreadyLoggedInElsewhere) { Console.WriteLine("I'm already logged in elsewhere! Shut down the other me first!", Console.ForegroundColor = ConsoleColor.Green); Console.ResetColor(); steamClient.Disconnect(); return; } if (callback.Result != EResult.OK) { Console.WriteLine("Login failed! Reason: " + callback.Result, Console.ForegroundColor = ConsoleColor.Green); return; } Console.WriteLine("I'm logged in and ready to go!", Console.ForegroundColor = ConsoleColor.Red); Console.Write("My SteamID: "); Console.WriteLine(steamClient.SteamID.ToString(), Console.ForegroundColor = ConsoleColor.Yellow); Console.Write("Owner SteamID (I'm assuming this is you.):", Console.ForegroundColor = ConsoleColor.Red); Console.WriteLine(BotOwnerID.ToString(), Console.ForegroundColor = ConsoleColor.Yellow); Console.ResetColor(); authed = true; }
public static void AnnounceServer(dynamic gatherInfo) { string message = gatherServerInfo_(gatherInfo); if (message == "") { return; } int friendCount = SteamBot.steamFriends.GetFriendCount(); for (int x = 0; x < friendCount; x++) { SteamID steamIdFriend = SteamBot.steamFriends.GetFriendByIndex(x); //This prevents bot from messaging people who are in any other state than "Online" - including busy, away etc. EPersonaState personaState = SteamBot.steamFriends.GetFriendPersonaState(steamIdFriend); bool condition = Json.Config.Msg_Condition(personaState, steamIdFriend); if (condition == false) { continue; } dynamic ensl_users = gatherInfo["gatherers"]; string enslID = steamIdFriend.ToString().Replace("STEAM_", ""); foreach (dynamic user in ensl_users) { if (user["user"]["steam"]["id"] != enslID) { continue; } SteamBot.steamFriends.SendChatMessage( steamIdFriend, EChatEntryType.ChatMsg, message ); } } }
public static String ChatSend(Command command) { SteamFriends friends = command.Steam.Friends; if (command.Parameters.Length == 2) { int count = friends.GetFriendCount(); for (int i = 0; i < count; i++) { SteamID id = friends.GetFriendByIndex(i); if (id.ToString() == command.Parameters[0]) { friends.SendChatMessage(id, EChatEntryType.ChatMsg, command.Parameters[1].Trim('"')); return(Protocol.Server.Success); } } return(Protocol.Server.NoSuchFriend); } return(Protocol.Server.InvalidArgument); }
public static dynamic dumpFriendslist() { int friendCount = SteamBot.SteamBot.steamFriends.GetFriendCount(); dynamic friendsList; if (!File.Exists("FriendsList.json")) { friendsList = new JObject(); friendsList.steamID = new JObject(); } else { friendsList = JsonConvert.DeserializeObject(File.ReadAllText("FriendsList.json")); } friendsList.usercount = friendCount; for (int x = 0; x < friendCount; x++) { SteamID steamID = SteamBot.SteamBot.steamFriends.GetFriendByIndex(x); string FriendID = steamID.ToString(); string nick = SteamBot.SteamBot.steamFriends.GetFriendPersonaName(steamID); if (friendsList.steamID[FriendID] == null) { dynamic obj_name = new JObject(); obj_name.name = nick; friendsList.steamID[FriendID] = obj_name; } if (friendsList.steamID[FriendID]["Message_Conditions"] == null) { friendsList.steamID[FriendID]["Message_Conditions"] = "online"; } } File.WriteAllText("FriendsList.json", friendsList.ToString()); return(friendsList); }
/// <summary> /// (Async) (Requires <see cref="SteamSharp.Authenticators.APIKeyAuthenticator"/> or <see cref="SteamSharp.Authenticators.UserAuthenticator"/>) /// Returns the friend list of any Steam user, provided the user's Steam Community profile visibility is set to "Public." /// Throws <see cref="SteamRequestException"/> on failure. /// </summary> /// <param name="client"><see cref="SteamClient"/> instance to use.</param> /// <param name="steamID">SteamID to return friend's list for.</param> /// <returns><see cref="SteamFriendsList"/> object containing a list of <see cref="SteamFriend"/> objects mapping to the Friend's list of the target user.</returns> public async static Task<SteamFriendsList> GetFriendsListAsync( SteamClient client, SteamID steamID ) { client.IsAuthorizedCall( new Type[] { typeof( Authenticators.UserAuthenticator ), typeof( Authenticators.APIKeyAuthenticator ) } ); SteamRequest request; List<SteamFriend> response; if( client.Authenticator is Authenticators.UserAuthenticator ) { // ISteamUserOAuth provides a higher level of access (with User Authentication), assuming a personal relationship with the target user request = new SteamRequest( "ISteamUserOAuth", "GetFriendList", "v0001" ); request.AddParameter( "steamID", steamID.ToString() ); response = VerifyAndDeserialize<SteamFriendsListResponse>( ( await client.ExecuteAsync( request ) ) ).Friends; } else { request = new SteamRequest( "ISteamUser", "GetFriendList", "v0001" ); request.AddParameter( "steamID", steamID.ToString() ); response = VerifyAndDeserialize<GetFriendsListResponse>( ( await client.ExecuteAsync( request ) ) ).FriendsList.Friends; } Dictionary<SteamID, SteamUser> users = new Dictionary<SteamID, SteamUser>(); foreach( var friend in response ) { users.Add( friend.SteamID, new SteamUser { SteamID = friend.SteamID, FriendSince = friend.FriendSince, } ); } return new SteamFriendsList { Friends = await GetBulkProfileDataAsync( client, users ) }; }
void OnFriendsList(SteamFriends.FriendsListCallback callback) { // at this point, the client has received it's friends list int friendCount = _steamFriends.GetFriendCount(); Console.WriteLine("We have {0} friends", friendCount); for (int x = 0; x < friendCount; x++) { // steamids identify objects that exist on the steam network, such as friends, as an example SteamID steamIdFriend = _steamFriends.GetFriendByIndex(x); // we'll just display the STEAM_ rendered version Console.WriteLine("Friend: {0}", steamIdFriend.Render()); if (_cmd == Command.SendAll) { _steamFriends.SendChatMessage(steamIdFriend, EChatEntryType.ChatMsg, _messageText); Thread.Sleep(500); } else if (_cmd == Command.SendSingle) { if (_userId == steamIdFriend.ConvertToUInt64().ToString()) { _steamFriends.SendChatMessage(steamIdFriend, EChatEntryType.ChatMsg, _messageText); _isMessageSent = true; break; } } else if (_cmd == Command.AcceptFriends) { foreach (var friend in callback.FriendList) { if (friend.Relationship == EFriendRelationship.RequestRecipient) { // this _user has added us, let's add him back and send him a message _steamFriends.AddFriend(friend.SteamID); _steamFriends.SendChatMessage(friend.SteamID, EChatEntryType.ChatMsg, _messageText); _isMessageSent = true; } } } else if (_cmd == Command.GetAllIds) { foreach (var friend in callback.FriendList) { if (!_friendsIds.ContainsKey(friend.SteamID.ConvertToUInt64().ToString())) { var val = _steamFriends.RequestProfileInfo(friend.SteamID).ToTask().Result; _friendsIds[friend.SteamID.ConvertToUInt64().ToString()] = val.RealName; } } _isMessageSent = true; } else if (_cmd == Command.GetFriendInfo) { if (_userId == steamIdFriend.ConvertToUInt64().ToString()) { var val = _steamFriends.RequestProfileInfo(steamIdFriend).ToTask().Result; _friendInfoVm.country = val.CountryName; _friendInfoVm.summary = val.Summary; _friendInfoVm.realName = val.RealName; _friendInfoVm.headline = val.Headline; _friendInfoVm.state = val.StateName; _friendInfoVm.steamId = steamIdFriend.ToString(); _friendInfoVm.profileUrl = "https://steamcommunity.com/profiles/" + steamIdFriend.ConvertToUInt64().ToString(); string html; using (WebClient client = new WebClient()) { client.Headers[HttpRequestHeader.UserAgent] = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2"; html = client.DownloadString("https://steamid.xyz/" + val.SteamID.ConvertToUInt64().ToString()); } _friendInfoVm.image_url = GetImagesInHTMLString(html); _isMessageSent = true; } } } if (_cmd == Command.SendAll) { _isMessageSent = true; } }
/// <summary> /// Initializes a new instance of the <see cref="SteamTrade.Exceptions.InventoryFetchException"/> class. /// </summary> /// <param name='steamId'> /// Steam identifier that caused the fetch exception. /// </param> public InventoryFetchException(SteamID steamId) : base(String.Format("Failed to fetch inventory for: {0}", steamId.ToString())) { FailingSteamId = steamId; }
public static string returnStatus(string current_state, int gatherers, dynamic ensl_users, SteamID steamID, bool announce = false) { string announcement = ""; #region Handles players who have signed up for gather. string enslID = steamID.ToString().Replace("STEAM_", ""); foreach (dynamic user in ensl_users) { if (user["user"]["steam"]["id"] != enslID) { continue; } switch (current_state) { case "gathering": announcement = string.Format( "You are signed up for the gather as {0}\n{1}/12 Players\nSee lineup at http://gathers.ensl.org/", user["user"]["username"], gatherers ); break; case "election": announcement = string.Format( "Gather is starting!\nYou are signed up for the gather as {0}\nElect captains at http://gathers.ensl.org/", user["user"]["username"] ); break; case "selection": announcement = string.Format( "Gather is starting!\nYou are signed up for the gather as {0}\nSee lineup at http://gathers.ensl.org/", user["user"]["username"] ); if (user["leader"] == true) { announcement = announcement + "\nYou have been elected as leader, don't forget to select your team!"; } break; } } if (announcement != "") { return(announcement); } #endregion switch (current_state) { case "election": case "selection": if (announce == true) { break; } announcement = "Gather is starting. Sign up for the next one at http://gathers.ensl.org/"; break; case "gathering": announcement = string.Format( "{0}/12 Players\nJoin up at http://gathers.ensl.org/", gatherers ); break; } return(announcement); }
// When the friends list gets updated we need to do things such as add the person back. private void OnFriendsList(SteamFriends.FriendsListCallback callback) { // at this point, the client has receivedh it's friends list int friendCount = steamFriends.GetFriendCount(); for (int x = 0; x < friendCount; x++) { // Cycle through the friends list, if there's anybody we don't know we're going to keep a tab on him SteamID steamIdFriend = steamFriends.GetFriendByIndex(x); if (!Program.friends.ContainsKey(steamIdFriend)) { Program.friends.Add(steamIdFriend, new Chatter(steamIdFriend, this, Program.GetOldChannel(steamIdFriend.ToString()))); } } // we can also iterate over our friendslist to accept or decline any pending invites foreach (var friend in callback.FriendList) { try { if (friend.Relationship == EFriendRelationship.Friend) { Program.friends[friend.SteamID].addedToList = true; } else if (friend.Relationship == EFriendRelationship.RequestRecipient) { if (Program.friends[friend.SteamID].addedToList) { steamFriends.IgnoreFriend(friend.SteamID); } else { // this user has added us, let's add him back steamFriends.AddFriend(friend.SteamID); Program.friends[friend.SteamID].addedToList = true; } } } catch (System.Collections.Generic.KeyNotFoundException) { } } }
public void OnMessageHandler(string message, EChatEntryType type) { _lastMessageWasFromTrade = false; if (!HandleWaitingOnUserResponse(message)) { if (message[0] == '/') { string command = message.Substring(1); string commandName = command.Split(' ')[0]; string[] commandArgs = new string[0]; if (command.Contains(" ")) { commandArgs = command.Split(' ').Skip(1).ToArray(); } switch (commandName) { case "dummy": ChatCommand dummyCommand = new ChatCommand(2); Log.Success("Dummycall successful!"); dummyCommand.Parse(message); foreach (var s in dummyCommand.GetArguments()) { Log.Success(s); } break; case "comment": try { string comment_id = commandArgs[0]; SteamID comment_steamId = new SteamID((ulong.Parse(comment_id))); string comment_message = commandArgs[1]; var success = PostProfileComment(comment_steamId, comment_message); if (success == HttpStatusCode.OK) { SendReplyMessage("Posted comment \"" + comment_message + "\" on " + comment_steamId.ToString() + "'s profile."); } else { SendReplyMessage("Commandexecution failed. Statuscode: " + success); } } catch (Exception e) { SendReplyMessage("Command execution failed. Command requires (string)steamid (string)message."); } break; case "game": ChatCommand gameCommand = new ChatCommand(1); gameCommand.Parse(message); string game_arg = gameCommand.GetArgument(0); if (game_arg == "stop") { Bot.SetGamePlaying(0); SendReplyMessage("Stopped game simulation"); } else { try { Bot.SetGamePlaying(int.Parse(game_arg)); SendReplyMessage("Started simulating gameplay of " + game_arg); } catch (Exception e) { SendReplyMessage(e.ToString()); } } break; default: SendReplyMessage("Command execution failed. Command not found."); break; } } else if (message.Contains("+csgo_econ_action_preview")) { Bot.RequestFloat(message, PrintFloat); } OnMessage(message, type); } }
public bool IsAdmin(SteamID id) { return(config.Data.Admins != null?config.Data.Admins.Contains(id.ToString()) : false); }
public bool IsUser(SteamID id) { return(config.Data.Users != null?config.Data.Users.Contains(id.ToString()) : false); }
internal async Task Init(string webAPIUserNonce) { steamID = _bot.steamClient.SteamID; sessionID = Convert.ToBase64String(Encoding.UTF8.GetBytes(steamID.ToString())); // Generate an AES session key byte[] sessionKey = CryptoHelper.GenerateRandomBlock(32); // RSA encrypt it with the public key for the universe we're on byte[] cryptedSessionKey; using (var crypto = new RSACrypto(KeyDictionary.GetPublicKey(_bot.steamClient.ConnectedUniverse))) { cryptedSessionKey = crypto.Encrypt(sessionKey); } // Copy our login key byte[] loginKey = new byte[webAPIUserNonce.Length]; Array.Copy(Encoding.ASCII.GetBytes(webAPIUserNonce), loginKey, webAPIUserNonce.Length); // AES encrypt the loginkey with our session key byte[] cryptedLoginKey = CryptoHelper.SymmetricEncrypt(loginKey, sessionKey); _bot.Log("Logging in to ISteamUserAuth", LogType.Info); KeyValue autResult; using (dynamic iSteamUserAuth = WebAPI.GetInterface("ISteamUserAuth")) { iSteamUserAuth.Timeout = 60000; try { autResult = iSteamUserAuth.AuthenticateUser( steamid: steamID.ConvertToUInt64(), sessionkey: Encoding.ASCII.GetString(WebUtility.UrlEncodeToBytes(cryptedSessionKey, 0, cryptedSessionKey.Length)), encrypted_loginkey: Encoding.ASCII.GetString(WebUtility.UrlEncodeToBytes(cryptedLoginKey, 0, cryptedLoginKey.Length)), method: WebRequestMethods.Http.Post, secure: true); } catch (Exception e) { _bot.Log("Cant AuthenticateUser " + e.Message, LogType.Error); return; } } if (autResult == null) { return; } _bot.Log("Success", LogType.Info); string steamLogin = autResult["token"].Value; string steamLoginSecure = autResult["tokensecure"].Value; webClient.cookieContainer.Add(new Cookie("sessionid", sessionID, "/", "." + SteamCommunityHOST)); webClient.cookieContainer.Add(new Cookie("steamLogin", steamLogin, "/", "." + SteamCommunityHOST)); webClient.cookieContainer.Add(new Cookie("steamLoginSecure", steamLoginSecure, "/", "." + SteamCommunityHOST)); gameminerBot = new GameminerBot(webClient, _bot.BotConfig); Initialized = true; //GiveawayBotInit().Forget(); }
private bool Respond(SteamID toID, SteamID userID, string message) { Dictionary <SteamID, Dictionary <SteamID, int> > groups = Options.AntiSpamTriggerOptions.groups; AntiSpamTriggerOptions options = Options.AntiSpamTriggerOptions; if (!groups.ContainsKey(toID)) { groups[toID] = new Dictionary <SteamID, int>(); } if (!groups[toID].ContainsKey(userID)) { groups[toID][userID] = 0; } groups[toID][userID] += options.msgPenalty; if (groups[toID][userID] >= options.score.warn && groups[toID][userID] <= options.score.warnMax) { Log("warning", userID, toID); SendMessageAfterDelay(userID, options.warnMessage, false); return(true); } else if (groups[toID][userID] >= options.score.kick) { Log("kicking", userID, toID); Bot.steamFriends.KickChatMember(toID, userID); return(true); } else if (groups[toID][userID] >= options.score.ban) { Log("banning", userID, toID); Timer unban = new Timer(options.timers.unban); unban.Elapsed += new ElapsedEventHandler((sender, e) => Unban_Elapsed(sender, e, toID, userID)); return(true); } else if (groups[toID][userID] >= options.score.tattle && groups[toID][userID] <= options.score.tattleMax) { Log("tattling on", userID, toID); foreach (SteamID admin in options.admins) { SendMessageAfterDelay(admin, Bot.steamFriends.GetFriendPersonaName(userID) + " is spamming in https://steamcommunity.com/gid/" + toID.ToString(), false); } return(true); } return(false); }
/// <summary> /// Logs bot actions to the console /// </summary> /// <param name="prefix">Action that was taken</param> /// <param name="userID">The user to act upon</param> /// <param name="groupID">The group the action is taking place in</param> /// <param name="reason">Reason they had action taken upon them</param> private void Log(string prefix, SteamID userID, SteamID groupID, string reason) { string message = string.Format("{0}/{1}: {2} {3} for spamming in https://steamcommunity.com/gid/{4} to prevent spam ({5})", Bot.username, Name, prefix, Bot.steamFriends.GetFriendPersonaName(userID), groupID.ToString(), reason); SteamChatBot.Log.Instance.Info(message); }
/// <summary> /// Sends a message, with text, to the target user. /// </summary> /// <param name="destinationUser">Targeted receipient for the message.</param> /// <param name="text">Message to send.</param> /// <returns>Asynchronous task to be used for tracking request completion.</returns> public async Task SendMessage( SteamID destinationUser, string text ) { SteamRequest request = new SteamRequest( "ISteamWebUserPresenceOAuth", "Message", "v0001", HttpMethod.Post ); request.AddParameter( "umqid", ChatSession.ChatSessionID, ParameterType.GetOrPost ); request.AddParameter( "type", ( ( text == null ) ? "typing" : "saytext" ), ParameterType.GetOrPost ); request.AddParameter( "steamid_dst", destinationUser.ToString(), ParameterType.GetOrPost ); if( text != null ) request.AddParameter( "text", text, ParameterType.GetOrPost ); SteamInterface.VerifyAndDeserialize<SteamChatSendMessageResponse>( ( await ExecuteAsync( request ) ) ); }
private void ReportPlayer(Bot bot, GameServerRequest gsr) { GameServer gs = bot.Manager.GetServerByID(gsr.ServerID); string[] ids = gsr.Arguments.Split('/'); SteamID steamID = GetSteamIDFromString(ids[0]); SteamID reportedDude = GetSteamIDFromString(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.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 { 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 InviteToSteamGroup(Bot bot, GameServerRequest gsr) { GameServer gs = bot.Manager.GetServerByID(gsr.ServerID); string[] steamIDgroupID = gsr.Arguments.Split('/'); if (steamIDgroupID.Length == 2) { SteamID steamID = new SteamID(steamIDgroupID[0]); SteamID groupID = new SteamID(ulong.Parse(steamIDgroupID[1])); if (steamID.IsValid) { if (bot.Friends.Contains(steamID)) { if (groupID.IsValid) { bot.InviteUserToGroup(steamID, groupID); if (gs != null) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.InviteSteamGroup, steamID.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, steamIDgroupID[0]); } else { Console.WriteLine(">>>> COUDLN'T FIND SERVER; NO REPLY SENT !"); } } } } }