Telegram.Bot icon indicating copy to clipboard operation
Telegram.Bot copied to clipboard

Is is possible to use this library in Xamarin.Android?

Open sinasaeedi opened this issue 9 years ago • 2 comments

I'm trying to create an Android app to communicate with a Telegram Bot. Is is possible to use this library in Xamarin.Android?

sinasaeedi avatar Feb 18 '17 20:02 sinasaeedi

@sinasaeedi should be

MrRoundRobin avatar Feb 18 '17 21:02 MrRoundRobin

Here is a sample in Xamarin.Android for those who are interested:

public class MainActivity : Activity
    {
        private static readonly TelegramBotClient Bot = new TelegramBotClient("xxxxxxxx");

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

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

        private static async void BotOnMessageReceived(object sender, MessageEventArgs messageEventArgs)
        {
            Telegram.Bot.Types.Message message = messageEventArgs.Message;

            await Bot.SendTextMessageAsync(message.Chat.Id, "From Xamarin");
        }
    }

sinasaeedi avatar Apr 20 '17 20:04 sinasaeedi