Пример #1
0
 public FakeBotProperties()
 {
     User = new User()
     {
         FirstName = "Fake bot",
         Username  = "******",
         IsBot     = true
     };
     CommandHelper = new BotCommandHelper(this, true);
 }
Пример #2
0
        public void MatchParams(string @params)
        {
            _outputHelper.WriteLine("Input text: {0}", @params);

            var args = BotCommandHelper.MatchParameters(@params);

            _outputHelper.WriteLine("{0} parameters has been detected", args.Count());
            foreach (var arg in args)
            {
                _outputHelper.WriteLine(arg);
            }
        }
        public HelloBotProperties(IConfiguration configuration)
        {
            var telegram = configuration.GetSection("Telegram"); // JSON: "Telegram"
            var botToken = telegram["BotToken"];                 // ENV: Telegram__BotToken, JSON: "Telegram:BotToken"

            Api  = new BotClient(botToken);
            User = Api.GetMe();

            _commandHelper = new BotCommandHelper(this);

            // Delete my old commands
            Api.DeleteMyCommands();
            // Set my commands
            Api.SetMyCommands(
                new BotCommand("hello", "Hello world!"));

            // Delete webhook to use Long Polling
            Api.DeleteWebhook();
        }