What tools are needed to build the Telegram-Bot with Asp.net And C#?

860 Views Asked by At

I've made a robot with the console, now I wanna put the robot on the host server to always be active so I need to change the robot to ASP.net. I tried many commands but did not succeed.

I'm asking that,What tools are needed to build the Telegram-Bot with Asp.net And C# ?

C# 2013 update3

Summary code:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetTelegramBotApi;
using NetTelegramBotApi.Requests;
using NetTelegramBotApi.Types;
using System.Net.Http;
using System.Runtime.Remoting.Channels;
using System.Data;
using System.Data.SqlClient;

namespace TestMyCam_bot
{


    class Program
    {
        private static string Token = "";
        private static ReplyKeyboardMarkup mainmenu;


        int i, j;
        int Counter = 0;



        bool success = false;
        bool bool_EndHtml = false;
        bool yek_Bar_Downloaded = false;


        Exception Ex;

        static void Main(string[] args)
        {

            mainmenu = new ReplyKeyboardMarkup 
            {

                Keyboard = new[] { new[] { "Sony" }, new[] { "Apple" }, new[] { "Nokia"} } 


            };

            Task.Run(() => RunBot());
            Console.ReadLine();
        }


        public static async Task RunBot()
        {





            var bot = new TelegramBot(Token);
            var me = await bot.MakeRequestAsync(new GetMe());
            Console.WriteLine("User Name is {0}", me.Username);
            long offset = 0;
            int whilecount = 0;
            while (true)
            {

                Console.WriteLine("while is {0}", whilecount);
                whilecount += 1;
                var updates = await bot.MakeRequestAsync(new GetUpdates() { Offset = offset });
                Console.WriteLine("Update Count is {0} ", updates.Count());
                Console.WriteLine("-------------------------------------");
                try
                {
                    foreach (var update in updates)
                    {

                        offset = update.UpdateId + 1;
                        var text = update.Message.Text;
                        if (text == "/start")
                        {
                            var req = new SendMessage(update.Message.Chat.Id, "Select Button") { ReplyMarkup = mainmenu};

                            await bot.MakeRequestAsync(req);
                            continue;

                        }



                }
                catch (Exception ex)
                {
                    throw;
                }

            }
        }
    }
}

if my questions is not clear i am sorry . I need to tell me,for example : vs 2015 ,webhook,ssl and etc. or simple code for my example code above.thanks

0

There are 0 best solutions below