2

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

  • http://www.nudoq.org/#!/Packages/SteamKit2/SteamKit2/SteamID - I don't see a "Value" field. Have you tried AccountID? – Robert Sep 21 '15 at 13:44
  • Yep, not working new SteamID { AccountID = "76561198145164176" } Severity Code Description Project File Line Error CS0029 Cannot implicitly convert type 'string' to 'uint' Tutorialbot C:\Users\Stagiair\Documents\Visual Studio 2015\Projects\Tutorialbot\Tutorialbot\Program.cs 180 –  Sep 21 '15 at 13:46
  • Actually, just looked. http://www.nudoq.org/#!/Packages/SteamKit2/SteamKit2/SteamID/ctor - try steamFriends.SendChatMessage(new SteamID(76561198145164176), EChatEntryType.ChatMsg, "A friend had added me!"); – Robert Sep 21 '15 at 13:47
  • The reason for that 2nd error message (string to uint) is that "76561198145164176" is the string representation and it doesn't automatically know it is a uint. you could do new SteamID { AccountID = 76561198145164176} and it may work, but if there is more going on behind the scenes with the SteamID(UInt) constructor, you may miss out on it. – Robert Sep 21 '15 at 13:49
  • 1
    @robert place your comment as an answer so I can put it as Answered, I've tested it and it worked! Thanks –  Sep 21 '15 at 13:52
  • Awesome, glad it worked – Robert Sep 21 '15 at 13:56

1 Answers1

0

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!");
Robert
  • 1,745
  • 5
  • 34
  • 61