好的,首先,我在这方面不是很先进,xD
在public override void OnMessage (string message, EChatEntryType type)
我想执行一系列测试来确定要发送哪个响应。
第一个测试是查看消息是否以命令开头。我是名为“Warmup Servers”的 CSGO 服务器组的管理员,这将是一串部分,它们将生成信息并将信息反馈到单独的日志文件中。
所以我正在
UserHandler.cs
为我的蒸汽机器人定制。exec [botname] TGTOnline
我计划编写一个简单的脚本,这样我就可以exec [botname] TGTOffline
告诉机器人是否使用它的帐户。(例如在该帐户上玩游戏或其他东西)。测试消息是否以任何预定义的响应开头。(更多内容稍后补充)
测试机器人之前是否发送过消息。我不希望有人与我开始对话,并且机器人每次收到消息时都发送其默认响应,这对双方来说都会很烦人。
因此,在调用默认消息之前,我需要一个函数来检查机器人帐户(机器人响应或人工响应)是否最近(最后 5 分钟)向用户发送了一条消息,如果有,告诉机器人什么都不做...
但是我不知道从哪里开始这个脚本,并且希望得到一些建议!
这是我的TGTUserHandler.cs
相关部分:
using System;
using SteamKit2;
using System.Threading.Tasks;
using System.Collections.Generic;
using SteamTrade;
using SteamTrade.TradeOffer;
using SteamTrade.TradeWebAPI;
namespace SteamBot
{
public class TGTUserHandler : UserHandler
{
private bool TGTOnline = false;
private TaskCompletionSource<string> _UserReport;
public TGTUserHandler(Bot bot, SteamID sid) : base(bot, sid) { }
private bool HandleUserReport(string message)
{
if (_UserReport == null)
return false;
//to be scripted in the morning
_UserReport = null;
return true;
}
public override void OnMessage(string message, EChatEntryType type)
{
if (message.StartsWith("!"))
{
if (message.StartsWith("!help"))
{
SendChatMessage("Welcome to the TGTGaming Automated Bots, We have very limited commands and currently do not do any type of automated trade. Here is the list of current commands you can use:");
SendChatMessage("!WarmupServers [help | Report | Issue] | This command is used for all issues related to the WarmupServer's. Do `!Warmupservers help` for more information");
SendChatMessage("!getadmin | This command is used to contact a TGTGaming administrator. Please do `!getadmin help` for more information");
}
if (message.StartsWith("!WarmupServers"))
{
if (message.StartsWith("!WarmupServers help"))
{
SendChatMessage("Warmup Servers Automated Support by TGTGamer");
SendChatMessage("Commands:");
SendChatMessage("!WarmupServers Report | Used to report a user for specific reasons. This is step by step process");
SendChatMessage("!WarmupServers issue | Used to report a issue with the servers. This is a step by step process");
}
if (message.StartsWith("!WarmupServers Report"))
{
GetUserResponse("You have started the user reporting process, please confirm this is what you wanted to do. [y/n]");
if (message.StartsWith("y"))
{
SendChatMessage("A few quick questions first, please respond yes or no");
GetUserResponse("Are you still in the server?");
if (message.StartsWith("y"))
{
GetUserResponse("Is the User you wish to report still in your server?");
if (message.StartsWith("y"))
{
GetUserResponse("Is there a VIP in the server?");
if (message.StartsWith("y"))
{
SendChatMessage("Please ask the VIP to do a !startvote on this user with your reason.");
}
else
{
_UserReport = new TaskCompletionSource<string>();
return _UserReport.Task;
}
}
else
{
_UserReport = new TaskCompletionSource<string>();
return _UserReport.Task;
}
}
else
{
_UserReport = new TaskCompletionSource<string>();
return _UserReport.Task;
}
}
else
{
SendChatMessage("You have cancelled this action");
}
}
}
}
else
{
if (TGTOnline)
{
//general Responses
if (message.StartsWith("Hello"))
{
SendChatMessage("What's up?");
}
if (message.StartsWith("Heya"))
{
SendChatMessage("Hello");
}
if (message.StartsWith("Hi"))
{
SendChatMessage("Heya");
}
else
{
//defualt response
SendChatMessage(Bot.ChatResponse);
}
}
else
{
//defualt response
SendChatMessage(Bot.ChatResponse);
}
}
}
}
}
所有和任何帮助将不胜感激。
亲切的问候。
TGT
您可能会发现有用的外部链接:
机器人 Github:https ://github.com/Jessecar96/SteamBot/
UserHandler.cs:https ://github.com/Jessecar96/SteamBot/blob/master/SteamBot/UserHandler.cs
脚注:
Steam 用户协议:
steam订户协议规定如下:
您不得使用秘籍、自动化软件(机器人)、模组、黑客或任何其他未经授权的第三方软件来修改或自动化任何订阅市场流程。
当我使用这个机器人来自动执行第 3 方服务器操作(Rcon Kick's、服务器重启等)时,它在机器人的 Steam 订户协议接受范围内。如果我随后开始使用该机器人自动进行买卖,则会违反订阅者协议。