'Telegram & Visual Basic

I'm trying to create my first telegram bot on visual basic (I know it's not the best, but I know it and I don't want to try my hand in a new language).
I am using the Telegram.Bot v17.0.0 and Telegrm.Bot.Extensions.Polling v1.0.2 library Reading and copying on the net I was able to write this code but it doesn't seem to work.
Everything starts regularly but I can't receive anything or send anything.
Can anyone help me spot any errors? THANK YOU!!!!

Imports System.IO
Imports System
Imports System.Threading
Imports System.Text
Imports System.Timers
Imports System.Globalization
'Imports IS_tg_sender.IS_tg_sender
Imports Telegram.Bot
Imports Telegram.Bot.Args
Imports Telegram.Bot.Types
Imports Telegram.Bot.Types.Enums
Imports Telegram.Bot.Types.ReplyMarkups
Imports Telegram.Bot.Exceptions
Imports Telegram.Bot.Extensions.Polling
Module GestBot

    Dim BotToken = "111111111111111111111111111"
    Public cts = New CancellationTokenSource()
    Public chatId As String
    Public messageText As String
    Public bott As Telegram.Bot.TelegramBotClient

    Async Function InitBot() As Task

        Try
            bott = New Telegram.Bot.TelegramBotClient(BotToken)

            Dim ReceiverOptions = New ReceiverOptions()

            bott.StartReceiving(AddressOf HandleUpdateAsync, AddressOf HandleErrorAsync, ReceiverOptions, cts.Token)

            Dim _me = Await bott.GetMeAsync()

            Console.WriteLine($"Start listening for @{_me.Username}")

            ' Send cancellation request to stop bot
            cts.Cancel()
        Catch e As Exception
            strLog = e.ToString
            strLog = "InitBot(). " & e.ToString
            Console.WriteLine(strLog)
        End Try
    End Function
    Function HandleErrorAsync(ByVal bott As ITelegramBotClient, ByVal exception As Exception, ByVal cancellationToken As CancellationToken) As Task
        Dim ErrorMessage = exception.ToString()
        Console.WriteLine(ErrorMessage)
        Return Task.CompletedTask
    End Function

    Async Function HandleUpdateAsync(ByVal bott As ITelegramBotClient, ByVal update As Update, ByVal cancellationToken As CancellationToken) As Task

        Dim _FirstName As String

        'Only process Message updates: https://core.telegram.org/bots/api#message
        If update.Type <> UpdateType.Message Then
            Return
        End If
        ' Only process text messages
        If update.Message.Type <> MessageType.Text Then
            Return
        End If
        chatId = update.Message.Chat.Id
        messageText = update.Message.Text

        _FirstName = update.Message.From.FirstName
        Console.WriteLine($"Received a '{messageText}' message in chat {chatId}." & _FirstName)

        ' Echo received message text
        Dim msg = "You said:" & vbLf & messageText
        Dim sentMessage = Await bott.SendTextMessageAsync(chatId, msg, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, cancellationToken)
        Dim Message = Await bott.SendTextMessageAsync(chatId, "hello world", cts)
    End Function
End Module


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source