Steamkit2给特定用户的消息

时间:2015-09-21 13:42:08

标签: c# steambot

一旦有人在好友列表中添加机器人,机器人就会接受请求并向新的朋友发送消息"我希望它也向我的steamID发送消息,但由于某种原因它没有工作

它接受并向新朋友发送消息,但不向我发送消息,

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
                }
            }
        }

在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

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

1 个答案:

答案 0 :(得分:0)

根据消息,"价值"不是SteamID对象的字段。查看SteamID,看起来您正在寻找的项目是AccountID。

基于constructors for SteamID,它看起来像而不是:

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

你想要改用它:

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