Closed. This question needs details or clarity。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?添加详细信息并通过editing this post阐明问题。
                        
                        2年前关闭。
                                                                                            
                
        
嗨,我使用此FrameworkProject来创建我的电报机器人

但是这个例子是控制台应用程序,我需要在IIS上启动我的项目

如何在IIS上上传项目?

最佳答案

您应该创建MVC项目
并在Global.asax中编写所有代码

然后在IIS上午餐您的项目

它适合Evere

using Menu;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Telegram.Bot;
using Telegram.Bot.Args;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.InlineKeyboardButtons;
using Telegram.Bot.Types.ReplyMarkups;


namespace TelegramMVC
{
    public class MvcApplication : System.Web.HttpApplication
    {

        Telegram.Bot.TelegramBotClient Bot = new TelegramBotClient("my_api_key");

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Bot.OnMessage += Bot_OnMessage;
            Bot.StartReceiving();
        }

        private void Bot_OnMessage(object sender, MessageEventArgs messageEventArgs)
        {
            var message = messageEventArgs.Message;

            if (message == null || message.Type != MessageType.TextMessage) return;

            if (message.Text.Contains("/start"))
            {
                string Str = "Start Recived";
                Bot.SendTextMessageAsync(message.Chat.Id, Str, replyMarkup: MainMenu.ShowMenu(message));

            }
            else if (message.Text.Contains("/Stop"))
            {
                string Str = "Stop Recived";
                Bot.SendTextMessageAsync(message.Chat.Id, Str, replyMarkup: FollowerMenu.ShowFollowerMenu(message));
            }

        }

    }
}

09-30 22:42