Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to login bot by using a token? #36

Closed
exzhawk opened this issue Mar 18, 2017 · 11 comments
Closed

Is it possible to login bot by using a token? #36

exzhawk opened this issue Mar 18, 2017 · 11 comments

Comments

@exzhawk
Copy link
Contributor

exzhawk commented Mar 18, 2017

No description provided.

@Lonami
Copy link
Member

Lonami commented Mar 19, 2017

Note to newcomers: things have evolved since this issue was first posted, and Telethon now makes it just as easy to write bots as it does to write scripts that control user accounts (although that could be seen further below). So yes, Telethon can be used to make bots too.

Below follow the original comments.


If I understood correctly, no. Telethon is for using Telegram as a normal client would, not for bots. You can build a bot with this and it would seem to be a normal use, but you can't control Telegram bots per se with Telethon. You can, however, manage them by talking to the @BotFather, in the same way you can do with any client.

@Lonami Lonami closed this as completed Mar 19, 2017
@Lonami
Copy link
Member

Lonami commented Mar 19, 2017

By the way, if you want to build a bot, maybe Lonabot is a good start, if you're looking for something that I made. There are tons of other libraries out there.

@exzhawk
Copy link
Contributor Author

exzhawk commented Mar 19, 2017

I want to access full MTProto method rather than normal vanilla bot API. What I need is a bot token login method like Telegram-CLI --bot (https://github.com/vysheng/tg/wiki/Telegram-CLI-Arguments).
I believe if Telegram-CLI can do it, all MTProto lib can do it as well. I think it's just about auth staff. If you have no plan of this feature, I'll try to implement.

@Lonami
Copy link
Member

Lonami commented Mar 19, 2017

What I need is a bot token login method like Telegram-CLI --bot

But there's no bot token, is there? It's just a normal user, and it would need a phone (even if it is just a virtual one), as far as I know.

If you have no plan of this feature

I don't know if it's possible to use a bot token to access the full list of methods as a normal user would, but if you manage to succeed, I'd be glad to merge!

@Lonami Lonami reopened this Mar 19, 2017
@exzhawk
Copy link
Contributor Author

exzhawk commented Mar 19, 2017

@XyLoNaMiyX if you use Telegram-CLI --bot to start it, it will ask you a bot token instead of phone number and code. Then the client works like a normal one but you are a bot. You can chat with others like normal user. But bot limitations are still there, like you can't initiate a new chat.

@Lonami
Copy link
Member

Lonami commented Mar 19, 2017

I see… Pretty cool. Maybe we could make a different class, TelegramBotClient, which behaved just like the normal TelegramClient but was a bot.

@Lonami
Copy link
Member

Lonami commented Mar 19, 2017

I have more questions. What are we supposed to implement for the bot? Should we parse the bot methods just like we parsed the original .tl methods? Is this only for the interactive client, or as another client (TelegramBotClient)? Thing is a bot works quite differently than how a normal user does. Perhaps this should be a completely separate project?

@JuanPotato
Copy link
Contributor

you dont need to implement anything other than the authorize
auth.importBotAuthorization#67a3ff2c flags:int api_id:int api_hash:string bot_auth_token:string = auth.Authorization;
then everything else works like a normal user, but some methods are disabled and others are limited. Like adding users to group etc

@Lonami
Copy link
Member

Lonami commented Mar 20, 2017

I didn't know that was a thing @JuanPotato, thanks for pointing us in the right direction!

@Lonami Lonami closed this as completed in 258c7f1 Mar 20, 2017
@Lonami
Copy link
Member

Lonami commented Mar 20, 2017

Usage: client.sign_in(bot_token='your hash').

@mktcockpit
Copy link

Can this works on the telegram desktop application?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants