当前位置: 首页>>代码示例>>C#>>正文


C# Robot.RegisterCleanup方法代码示例

本文整理汇总了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);
        }
开发者ID:rdsimes,项目名称:mmbot,代码行数:101,代码来源:SpotifyPlayerScripts.cs


注:本文中的Robot.RegisterCleanup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。