forked from Rachel030219/Telegram-Forwarder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforwarder.py
45 lines (33 loc) · 1.64 KB
/
forwarder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# coding=utf-8
import telebot
bot = telebot.TeleBot("<TOKEN>")
forwarder_list = [235274404, 136971973, 290855719, 242382379, 311300407, 363246572, 184292188]
@bot.message_handler(func=lambda message: True)
def forward_to_matpin(message):
if "group" in message.chat.type:
if str(message.chat.id) == "-1001076357496" and "#matpin" in message.text:
send_group_forward(message)
else:
send_private_forward(message)
@bot.message_handler(commands=['ping'])
def send_ping(message):
bot.send_message(message.chat.id, "群组 id 为 " + str(message.chat.id) + " ,用户 id 为 " + str(message.from_user.id) + " ,完毕。")
def send_group_forward(message):
if message.from_user.id in forwarder_list:
if message.reply_to_message is not None:
bot.forward_message("@matpin", message.chat.id, message.reply_to_message.message_id)
bot.send_message(message.chat.id, "已经转发过去了哟~")
else:
bot.reply_to(message, "咱只能转发回复的消息哟~")
else:
bot.reply_to(message, "你的 PY 度还不够高呢,不能转发消息哟~")
def send_private_forward(message):
if message.from_user.id in forwarder_list:
if message.forward_date is not None:
bot.forward_message("@matpin", message.chat.id, message.message_id)
bot.send_message(message.chat.id, "已经转发过去了哟~")
else:
bot.send_message(message.chat.id, "咱只能转发转发给咱的消息哟~")
else:
bot.send_message(message.chat.id, "你的 PY 度还不够高呢,不能转发消息哟~")
bot.polling()