hhstore / blog

My Tech Blog: about Mojo / Rust / Golang / Python / Kotlin / Flutter / VueJS / Blockchain etc.
https://github.com/hhstore/blog/issues
288 stars 24 forks source link

Telegram API: dev #125

Open hhstore opened 5 years ago

hhstore commented 5 years ago

related:

hhstore commented 5 years ago

电报API:

APIs:

API 说明
https://core.telegram.org/api api
https://core.telegram.org/methods 所有API方法列表
https://core.telegram.org/method/auth.signIn 登录
https://core.telegram.org/api/auth auth API
xxx xxx
https://my.telegram.org/ web 登录, 手机号格式: +86171xxxx
xxx xxx
xxx xxx

Libs:

语言 说明
https://github.com/sdidyk/mtproto go 命令行, 支持 mtproto 协议
https://github.com/eternnoir/pyTelegramBotAPI xxx xxx
https://github.com/LonamiWebs/Telethon xxx xxx
https://github.com/python-telegram-bot/python-telegram-bot xxx xxx
https://github.com/aiogram/aiogram python3 异步 ⭐⭐⭐⭐⭐
xxx xxx xxx
xxx xxx xxx
https://github.com/daviddrysdale/python-phonenumbers
hhstore commented 5 years ago

示例代码:

获取一个频道, 小组:

# Dialogs are the "conversations you have open".
# This method returns a list of Dialog, which
# has the .entity attribute and other information.
dialogs = client.get_dialogs()

# All of these work and do the same.
lonami = client.get_entity('lonami')
lonami = client.get_entity('t.me/lonami')
lonami = client.get_entity('https://telegram.dog/lonami')

# Other kind of entities.
channel = client.get_entity('telegram.me/joinchat/AAAAAEkk2WdoDrB4-Q8-gg')
contact = client.get_entity('+34xxxxxxxxx')
friend  = client.get_entity(friend_id)

# Getting entities through their ID (User, Chat or Channel)
entity = client.get_entity(some_id)

# You can be more explicit about the type for said ID by wrapping
# it inside a Peer instance. This is recommended but not necessary.
from telethon.tl.types import PeerUser, PeerChat, PeerChannel

my_user    = client.get_entity(PeerUser(some_id))
my_chat    = client.get_entity(PeerChat(some_id))
my_channel = client.get_entity(PeerChannel(some_id))
hhstore commented 3 years ago

ref:

官方 bot:

基于 telegram 的第三方服务:

hhstore commented 3 years ago

创建一个 bot:

添加/修改 bot commands:

start - 開啟keyboard
test1 - 執行功能1
test2 - 執行功能2

常用API:

设置 webhook:

hhstore commented 3 years ago

golang sdk: