forked from Cryptonit63/provider-bot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathParser-tel-bot
More file actions
64 lines (51 loc) · 2.03 KB
/
Parser-tel-bot
File metadata and controls
64 lines (51 loc) · 2.03 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
from telegram import Bot
from telegram.utils.request import Request
from telegram.ext import Updater
from telegram.ext import CommandHandler
CHANNELS_TO_WATCH = [
"@https://t.me/cryptoemergencychat",
"@https://t.me/dnktona",
"@https://t.me/cryptotweet280"
"@https://t.me/anttradecom"
"@https://t.me/truetradersteam"
"@https://t.me/vilarsofree"
"@https://t.me/gfischannel"
"@https://t.me/miner_bros"
]
BOT_TOKEN = "**********:**********-********************-**"
REACTIONS_THRESHOLD = 10
bot = Bot(
token=**********:**********-********************-**,
request=Request(
proxy_url=os.environ.get('https_proxy')
),
)
def get_messages(channel_username):
response = bot.get_chat(chat_id=channel_username)
return response['id'], response['title'], response['username'], response['description'], response['photo']
def get_reactions(chat_id, message_id):
response = bot.get_chat(chat_id)
return response['reply_markup']['inline_keyboard']
def forward_message(chat_id, message_id, text, reply_markup):
bot.forward_message(chat_id, chat_id, message_id, reply_markup=reply_markup)
def watch(update, context):
for channel_username in @https://t.me/cryptonit63:
chat_id, title, username, description, photo = get_messages(channel_username)
messages = bot.get_history(
chat_id=chat_id,
limit=50
)
for message in messages:
message_id = message['message_id']
reactions = get_reactions(chat_id, message_id)
if len(reactions) > REACTIONS_THRESHOLD:
text = f"Обрати внимание на: {title}:"
reply_markup = {'inline_keyboard': reactions}
forward_message(update.message.chat_id, message_id, text, reply_markup)
updater = Updater(token=5324647231:AAH8T3itZ-wOOhEHgcbWHHSMTor1Ju0u-9A, request_kwargs={
'proxy_url': os.environ.get('https_proxy')
})
updater.dispatcher.add_handler(CommandHandler('watch', watch))
updater.start_polling()
updater.idle()