-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
58 lines (47 loc) · 2.96 KB
/
main.py
File metadata and controls
58 lines (47 loc) · 2.96 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
import telebot
from telebot import types
from config import Config
config = Config()
bot = telebot.TeleBot(config.bot_token)
@bot.message_handler(commands=['start'])
def start(message):
bot.send_message(message.chat.id, text="""Привет!👋
Напиши свою интересную историю, которая может попасть к нам в канал!🎉
Это будет анонимно и никто не узнает чья она!🤫""")
bot.send_message(message.chat.id, text="Учти, что ты можешь отправлять не более 2-х сообщений/историй в сутки❗️")
@bot.message_handler(content_types=["text","photo", "audio", "video", "voice"])
def story(message):
markup = types.InlineKeyboardMarkup()
approve_btn = types.InlineKeyboardButton(text="Одобрить✅", callback_data="approve")
reject_btn = types.InlineKeyboardButton(text="Отклонить❌", callback_data="reject")
markup.add(approve_btn, reject_btn)
caption_text = f"Новая история от пользователя: @{message.from_user.username}\n\n"
if message.text:
bot.send_message(config.admin_chat_id, text=message.text, reply_markup=markup)
elif message.photo:
bot.send_photo(config.admin_chat_id, photo=message.photo[-1].file_id, caption=caption_text + (message.caption or ""), reply_markup=markup)
elif message.audio:
bot.send_audio(config.admin_chat_id, audio=message.audio.file_id, caption=caption_text + (message.caption or ""), reply_markup=markup)
elif message.video:
bot.send_video(config.admin_chat_id, video=message.video.file_id, caption=caption_text + (message.caption or ""), reply_markup=markup)
elif message.voice:
bot.send_voice(config.admin_chat_id, voice=message.voice.file_id, caption=caption_text + (message.caption or ""), reply_markup=markup)
bot.reply_to(message, f"""Отлично, теперь ваша история в списке!📋
После модерации🖊 у неё есть шанс попасть в канал!\n
Желаем удачи!""")
@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
if call.data == "approve":
if call.message.text:
bot.send_message(config.channel_id, text=call.message.text)
elif call.message.photo:
bot.send_photo(config.channel_id, photo=call.message.photo[-1].file_id, caption=call.message.caption or "")
elif call.message.audio:
bot.send_audio(config.channel_id, audio=call.message.audio.file_id, caption=call.message.caption or "")
elif call.message.video:
bot.send_video(config.channel_id, video=call.message.video.file_id, caption=call.message.caption or "")
elif call.message.voice:
bot.send_voice(config.channel_id, voice=call.message.voice.file_id, caption=call.message.caption or "")
elif call.data == "reject":
pass
bot.polling()