# -*- coding: utf-8 -*-
import telebot
import config
from telebot.apihelper import ApiTelegramException
from telebot import types
from array import *
bot = telebot.TeleBot(config.TOKEN)
chat_user_id = 0 # ID чата пользователя
user_id = 0
name_user = ""
chat_id_channel1 = -100.....
chat_id_channel2 = -100....
chat_id_channel3 = -100....
chat_id_channel4 = -100...
chat_id_channel5 = -100....
@bot.message_handler(commands=['start'])
def welcome(message):
global chat_user_id, name_user, user_id
chat_user_id = message.chat.id
user_id = message.from_user.id
name_user = message.from_user.first_name
# keyboard
markup = types.InlineKeyboardMarkup(row_width=1)
item1P = types.InlineKeyboardButton("Кнопка под сообщением", callback_data='want')
markup.add(item1P)
bot.send_message(message.chat.id,
"Текст".format(
message.from_user, bot.get_me()),
parse_mode='html')
bot.send_message(message.chat.id,
"Текст".format(
message.from_user, bot.get_me()),
parse_mode='html', reply_markup=markup)
def answer1():
img = open('Money.jpg', 'rb')
bot.send_photo(Chat_user_id, img,
caption="Текст", parse_mode="Markdown")
markup = types.InlineKeyboardMarkup(row_width=1)
item1P = types.InlineKeyboardButton("Кнопка под сообщением", callback_data='nextquest')
markup.add(item1P)
bot.send_message(Chat_user_id,
Name_user + "Текст",
parse_mode='html', reply_markup=markup)
def answer2():
bot.send_message(Chat_user_id, "Текст")
markup = types.InlineKeyboardMarkup(row_width=1)
item1P = types.InlineKeyboardButton("Кнопка под сообщением", callback_data='watchsub')
markup.add(item1P)
bot.send_message(Chat_user_id, "Текст " ,parse_mode='html', reply_markup=markup)
def answer3():
bot.send_message(Chat_user_id, 'Тескт')
bot.send_message(Chat_user_id, 'Тескт')
markup = types.InlineKeyboardMarkup(row_width=1)
item1P = types.InlineKeyboardButton("Кнопка под сообщением", callback_data='nextquest2')
markup.add(item1P)
img = open('Description.jpg', 'rb')
bot.send_photo(Chat_user_id, img,
caption="Тескт", parse_mode="Markdown", reply_markup=markup)
def answer4():
bot.send_message(Chat_user_id, 'Текст')
markup = types.InlineKeyboardMarkup(row_width=1)
item1P = types.InlineKeyboardButton("Кнопка под сообщением", callback_data='nextquest3')
markup.add(item1P)
img = open('adPhoto.jpg', 'rb')
bot.send_photo(Chat_user_id, img,
caption="Текст ", parse_mode="Markdown")
bot.send_message(chat_user_id, 'Текст»', reply_markup=markup)
def proverka(..., ...):
if ...
...
else:
answer3()
def is_subscribed(Chat_id_channel, User_id):
try:
bot.get_chat_member(Chat_id_channel, User_id)
return True
except ApiTelegramException as e:
if e.result_json['description'] == 'Bad Request: user not found':
return False
@bot.callback_query_handler(func=lambda call: True)
def check(call):
global chat_user_id, name_user, user_id
if call.message:
if call.data == "want":
answer1()
elif call.data == "nextquest":
answer2()
elif call.data == "watchsub":
proverka(chat_user_id, user_id)
elif call.data == "nextquest2":
answer4()
elif call.data == "nextquest3":
bot.send_message(chat_user_id, 'Текст')
else:
bot.send_message(chat_user_id, "Error".format(bot.get_me()))
# RUN
bot.polling(none_stop=True)