Search code examples
c#steambot

Steamkit2 Message to specific user


Once someone adds the bot in friendlist, the bot is accepting the request and send a message to the new "friend", I want it to send a message to my steamID as well, but for some reason it isn't working

it does accept and send message to the new friend, but does not send me a message,

static void OnFriendsList(SteamFriends.FriendsListCallback callback)
        {
            Thread.Sleep(2500);
            foreach(var friend in callback.FriendList)
            {
                if (friend.Relationship == EFriendRelationship.RequestRecipient)
                {
                    steamFriends.AddFriend(friend.SteamID);
                    Thread.Sleep(500);
                    steamFriends.SendChatMessage(friend.SteamID, EChatEntryType.ChatMsg, "Hello I am a bot");
                    steamFriends.SendChatMessage(new SteamID { Value = "76561198145164176" }, EChatEntryType.ChatMsg, "A friend had added me!"); //This ain't working
                }
            }
        }

Also getting a syntax error at Value,

Severity    Code    Description Project File    Line
Error   CS0117  'SteamID' does not contain a definition for 'Value' Tutorialbot C:\Users\Stagiair\Documents\Visual Studio 2015\Projects\Tutorialbot\Tutorialbot\Program.cs  180

documentation: http://www.nudoq.org/#!/Packages/SteamKit2/SteamKit2/SteamFriends/M/SendChatMessage


Solution

  • Based on the message, "Value" isn't a field for the SteamID object. Looking at SteamID, it looks like the item you're looking for is AccountID.

    Based on the constructors for SteamID, it looks like instead of:

    steamFriends.SendChatMessage(new SteamID { Value = "76561198145164176" }, EChatEntryType.ChatMsg, "A friend had added me!");
    

    you'll want to use this instead:

    steamFriends.SendChatMessage(new SteamID(76561198145164176), EChatEntryType.ChatMsg, "A friend had added me!");