本文整理汇总了C#中SteamBot.Bot.StopBot方法的典型用法代码示例。如果您正苦于以下问题:C# Bot.StopBot方法的具体用法?C# Bot.StopBot怎么用?C# Bot.StopBot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SteamBot.Bot
的用法示例。
在下文中一共展示了Bot.StopBot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BotMode
// This mode is to run a single Bot until it's terminated.
private static void BotMode(int botIndex)
{
if (!Directory.Exists(BotManager.DATA_FOLDER))
{
Directory.CreateDirectory(BotManager.DATA_FOLDER);
}
if (!File.Exists(BotManager.DATA_FOLDER + "settings.json"))
{
Console.WriteLine("No settings.json file found.");
if (!File.Exists(BotManager.DATA_FOLDER + "settings-template.json"))
{
File.WriteAllText(BotManager.DATA_FOLDER + "settings-template.json", defSettingsStr);
}
return;
}
Configuration configObject;
try
{
configObject = Configuration.LoadConfiguration("settings.json");
}
catch (Newtonsoft.Json.JsonReaderException)
{
// handle basic json formatting screwups
Console.WriteLine("settings.json file is corrupt or improperly formatted.");
return;
}
if (botIndex >= configObject.Bots.Length)
{
Console.WriteLine("Invalid bot index.");
return;
}
Bot b = new Bot(configObject.Bots[botIndex], configObject.ApiKey,
(b2, sid) => BotManager.UserHandlerCreator(b2, sid, configObject), true, true);
Console.Title = "Bot Manager";
b.StartBot();
string AuthSet = "auth";
string ExecCommand = "exec";
string ExitCommand = "exit";
// this loop is needed to keep the botmode console alive.
// instead of just sleeping, this loop will handle console input
while (true)
{
string inputText = Console.ReadLine();
if (string.IsNullOrEmpty(inputText))
continue;
// Small parse for console input
var c = inputText.Trim();
var cs = c.Split(' ');
if (cs.Length > 1)
{
if (cs[0].Equals(AuthSet, StringComparison.CurrentCultureIgnoreCase))
{
b.AuthCode = cs[1].Trim();
}
else if (cs[0].Equals(ExecCommand, StringComparison.CurrentCultureIgnoreCase))
{
b.HandleBotCommand(c.Remove(0, cs[0].Length + 1));
}
else if (cs[0].ToLower() == ExitCommand)
{
b.StopBot();
}
}
}
}