简体   繁体   English

Steamkit2消息给特定用户

[英]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 有人将漫游器添加到好友列表后,该漫游器正在接受请求并向新的“朋友”发送消息,我希望它也向我的SteamID发送消息,但由于某种原因,它无法正常工作

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, 同时在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/ SteamFriends/ M/ SendChatMessage

Based on the message, "Value" isn't a field for the SteamID object. 根据消息,“值”不是SteamID对象的字段。 Looking at SteamID , it looks like the item you're looking for is AccountID. 查看SteamID ,看起来您要查找的项目是AccountID。

Based on the constructors for SteamID , it looks like instead of: 基于SteamID构造函数 ,它看起来像是:

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!");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM