I wrote a Telegram Bot in groovy and it was a piece of cake.
Now in order to register propper webhooks I need to get a hold of user's id.
I read, that I should call auth.sendCode method to start that process.
Are there any simpler alternatives to that?
If not, how can I invoke the sendCode
with the smallest effort and possibly w/o any additional dependencies? Any examples or pointers using plain java or curl would be good.
After some research I ended up with a simple solution.
Instead of authenticating against the Telegram API over MTProto, I reversed the process. I implemented a new bot-command:
/login {my-user-id}
so that the user sends his id (can be some generated token later) in Telegram bot chat and the bot sends this message - along with Telegram user id! - over webhook to my server, where I do the matching and saving.
The implementation looks like this:
switch( json.message.text ){
case ~/\/login \w+/:
String userId
text.toLowerCase().eachMatch( /\/login (\w+)/ ){ userId = it[ 1 ] }
String telegramUserId = json.message.from.id
saveJoin userId, telegramUserId
break
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.