Example #1
0
        public TelegramBotService(ITelegramMessageRouter messageRouter, ITelegramBotClient botClient)
        {
            _logger        = LogManager.GetCurrentClassLogger();
            _messageRouter = messageRouter;
            _botClient     = botClient;
            var me = botClient.GetMeAsync().Result;

            Console.WriteLine(
                $"Telegram bot client instantiated. I am user {me.Id} and my name is {me.FirstName}."
                );

            botClient.OnMessage += Bot_OnMessage;
        }
Example #2
0
        public TelegramBotService(ITelegramMessageRouter messageRouter, UsersContext context, IOptions <Settings> settings)
        {
            _messageRouter = messageRouter;
            _context       = context;
            _settings      = settings.Value;
            botClient      = new TelegramBotClient(_settings.Telegram.AccessT);
            var me = botClient.GetMeAsync().Result;

            Console.WriteLine(
                $"Hello, World! I am user {me.Id} and my name is {me.FirstName}."
                );

            botClient.OnMessage += Bot_OnMessage;
        }