创建bot

首先我们要找到bot father https://t.me/BotFather

然后输入指令 /newbot 创建一个bot

接下来输入bot 的昵称和bot的 @username 即可创建一个bot

此时会获得一个token,保存起来

然后start bot

获取chat_id
访问

1
https://api.telegram.org/bot{Bot的API}/getUpdates

不用加空格,然后浏览器 ”ctrl+f “搜索 “chat”

示例:

1
https://api.telegram.org/botgslhjgfd:45g645gs-fgs/getUpdates

如果 getUpdates 不刷新,则可以通过访问下面的URL获取最新的消息

1
https://api.telegram.org/bot{Bot的API}/getUpdates?offset=-1

chat 后面跟着的id “id”:123456789就是chatid了,“

然后就可以用bot向自己发消息了

1
https://api.telegram.org/bot{Bot的API}/sendMessage?chat_id=123456789&text=1234

使用方法
有些github项目可以通过bot_api来实现发消息