本文整理汇总了C#中Robot.RegisterCleanup方法的典型用法代码示例。如果您正苦于以下问题:C# Robot.RegisterCleanup方法的具体用法?C# Robot.RegisterCleanup怎么用?C# Robot.RegisterCleanup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Robot
的用法示例。
在下文中一共展示了Robot.RegisterCleanup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register
//.........这里部分代码省略.........
return;
}
await _player.Pause();
var next = await _player.PlayNextInQueue();
await msg.Send(string.Format("Playing {0}", next.GetDisplayName()));
});
robot.Respond(@"(spotify )?(stop|pause)", async msg =>
{
if (!await CheckForPlayingSession(msg)) return;
await _player.Pause();
});
robot.Respond(@"mute", async msg =>
{
if (!await CheckForPlayingSession(msg)) return;
_player.Mute();
});
robot.Respond(@"unmute", async msg =>
{
if (!await CheckForPlayingSession(msg)) return;
_player.Unmute();
});
robot.Respond(@"spotify show queue", async msg =>
{
if (!await Login(msg)) return;
if (!_player.Queue.Any())
{
await msg.Send("There are no tracks in the queue");
return;
}
IEnumerable<string> queue = _player.Queue.Take(20).Select(item => item.GetDisplayName()).ToArray();
if (_player.Queue.Count() > 20)
{
queue = queue.Concat(new[] { string.Format("+ {0} not listed", _player.Queue.Count() - 20) });
}
await msg.Send(string.Join(Environment.NewLine, queue.ToArray()));
});
robot.Respond(@"spotify remove (.*) from( the)? queue", async msg =>
{
if (!await Login(msg)) return;
if (_player.Queue == null || !_player.Queue.Any())
{
await msg.Send("There are no tracks in the queue");
return;
}
int count = await _player.RemoveFromQueue(msg.Match[1]);
if (count == 0)
{
await msg.Send("There were no matching tracks in the queue");
}
else
{
await msg.Send(string.Format("{0} tracks were removed from the queue", count));
}
});
robot.Respond(@"(turn|crank) it (up|down)( to (\d+))?", async msg =>
{
if (!await CheckForPlayingSession(msg)) return;
string direction = msg.Match[2].Trim();
string amount = msg.Match[4].Trim();
if (!string.IsNullOrWhiteSpace(amount))
{
_player.SetVolume(int.Parse(amount));
}
if (direction.ToLowerInvariant() == "up")
{
_player.TurnUpVolume(10);
}
else
{
_player.TurnUpVolume(10);
}
});
robot.Respond(@"spotify ship it", async msg =>
{
if (!await Login(msg)) return;
await _player.PlayLink("spotify:track:77NNZQSqzLNqh2A9JhLRkg");
await Giphy.GifMe(_robot, "winning", msg);
});
robot.RegisterCleanup(Cleanup);
}