我正在尝试使用SteamKit2为steam创建一个聊天机器人。我在文本文档中有一组预定义的消息,程序可以读取,但我希望它在收到的消息不在此列表时说出特定的响应。我尝试使用if-else语句,但是当我向机器人发送消息时,它只回复了else响应,而不是预定义的响应。
<iframe src="android-app://COM.YOUR.APP.IDENTIFIER/SCHEME/HOST?somegetparams"> </iframe>
<a href="android-app://COM.YOUR.APP.IDENTIFIER/SCHEME/HOST?somegetparams">LINK</a>
感谢。
答案 0 :(得分:0)
将其重写为:
while ((rLine = sReader.ReadLine()) != null) {
string text = rLine.Remove(rLine.IndexOf('|') - 1); //message | response
string response = rLine.Remove(0, rLine.IndexOf('|') + 2) ;
string realText = text.ToLower();
if (callback.Message.Contains(realText) || callback.Message.Contains(text))
{
steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, response);
Console.WriteLine("Someone has messaged me, and I replied with an automated message.");
sReader.Close();
return;
}
}
steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "I don't know what you mean. Could you maybe write it a bit differently? <3");
Console.WriteLine("Someone has messaged me, and it wasn't on my auto-response list: {0}",callback.Message);
sReader.Close();
return;