當前位置: 首頁>>代碼示例>>C#>>正文


C# Bot.Leave方法代碼示例

本文整理匯總了C#中Bot.Leave方法的典型用法代碼示例。如果您正苦於以下問題:C# Bot.Leave方法的具體用法?C# Bot.Leave怎麽用?C# Bot.Leave使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Bot的用法示例。


在下文中一共展示了Bot.Leave方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BotHostModule

        public BotHostModule(Bot bot)
            : base("bot")
        {
            _bot = bot;

            Get["/start"] = _ =>
            {
                try
                {
                    StartBot();
                    return "Bot Started";
                }
                catch (Exception e)
                {
                    return e.Message;
                }
            };

            Get["/stop"] = _ =>
            {
                try
                {
                    ShutDownBot();
                    return "Bot Shut Down";
                }
                catch (Exception e)
                {
                    return e.Message;
                }
            };

            // This is for ensuring that the process doesn't die permanently --
            // We create a task with MomentApp (TBD whether we will use this permanently
            Get["/keepalive"] = _ =>
            {
                ScheduleKeepAlive(Request.Url.ToString());
                return "OK";
            };

            Post["/launch"] = _ =>
            {
                //TODO: verify there is an auth token

                return "";
            };

            Post["/join"] = _ =>
                                {
                                    _bot.Join(Request.Form.Room);
                                    return Response.AsRedirect("/Rooms");
                                };

            Get["/leave"] = _ =>
                                {
                                    _bot.Leave(Request.Query.Room);
                                    return Response.AsRedirect("/Rooms");
                                };
        }
開發者ID:Raion,項目名稱:jibbr,代碼行數:58,代碼來源:BotHostModule.cs

示例2: BotHostModule

        public BotHostModule(Bot bot, SprocketManager sprockets, IEnumerable<ISprocketInitializer> sprocketInitializers)
            : base("bot")
        {
            _bot = bot;
            _sprockets = sprockets;
            _sprocketInitializers = sprocketInitializers;

            Get["/start"] = _ =>
            {
                try
                {
                    StartBot();

                    return "Bot Started";
                }
                catch (Exception e)
                {
                    return e.Message;
                }
            };

            Get["/stop"] = _ =>
            {
                try
                {
                    ShutDownBot();
                    return "Bot Shut Down";
                }
                catch (Exception e)
                {
                    return e.Message;
                }
            };

            // This is for ensuring that the process doesn't die permanently --
            // We create a task with MomentApp (TBD whether we will use this permanently
            Get["/keepalive"] = _ =>
            {
                ScheduleKeepAlive(Request.Url.ToString());
                return "OK";
            };

            Get["/launch"] = _ =>
            {
                //TODO: verify there is an auth token
                LoadCoffeeScript();
                return "";
            };

            Post["/join"] = _ =>
                                {
                                    _bot.Join(Request.Form.Room);
                                    return Response.AsRedirect("/Rooms");
                                };

            Get["/leave"] = _ =>
                                {
                                    _bot.Leave(Request.Query.Room);
                                    return Response.AsRedirect("/Rooms");
                                };
            Post["/send/{room}"] = _ =>
                                       {
                                           _bot.Say(Request.Form.Message, _.Room);
                                           return Response.AsRedirect("/");
                                       };

            Post["/attach"] = _ =>
                                  {
                                      AttachScript(Request.Form.script);
                                      return Response.AsRedirect("/");
                                  };

            Post["/disable/{sprocket}"] = _ =>
                                              {
                                                  var sprocket = sprockets[_.Sprocket];
                                                  _bot.DisableSprocket(sprocket);
                                                  return Response.AsRedirect("/");
                                              };

            Post["/enable/{sprocket}"] = _ =>
                                              {
                                                  var sprocket = sprockets[_.Sprocket];
                                                  _bot.EnableSprocket(sprocket);
                                                  return Response.AsRedirect("/");
                                              };
        }
開發者ID:brooklynDev,項目名稱:jibbr,代碼行數:86,代碼來源:BotHostModule.cs


注:本文中的Bot.Leave方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。