itgoyo / 500Days-Of-Github

⭐ 瞎JB折腾Mac/Linux/Windows过程中遇到的所有问题和解决方式 ⭐
https://itgoyo.github.io/500Days-Of-Github
138 stars 13 forks source link

Python实现Telegram机器人推送消息 #329

Open itgoyo opened 1 year ago

itgoyo commented 1 year ago
# -*- coding: utf-8 -*-
import telebot

# 在 https://core.telegram.org/bots#3-how-do-i-create-a-bot 获取您的 telegram bot token
bot_token = '211xxx5926:AAF4p7xxxxxQoCWyrUywVEBQ9U72VA5D7v8';

# 在 https://t.me/botfather 获取您的 telegram bot id
bot_chatID = '21141xxxx36';

bot = telebot.TeleBot(bot_token);
bot.send_message(bot_chatID, "您要发送的文本内容");

安装依赖:

python3 -m pip install --user telebot

程序运行:

python3 tg.py

想知道对应的chatid的话就在群组里面@get_id_bot,就可以拿到对应的chatid

最后推送成功的时候,不知道为啥推送到了之前创建的青龙机器人里面了

image