-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
52 lines (48 loc) · 1.89 KB
/
bot.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
46
47
48
49
50
51
52
from xml.etree.ElementTree import tostring
import telebot
from telebot import types
import time
import random
from config import token
import sqlite3
from messages import *
sqliteConnection = sqlite3.connect('db.db', check_same_thread=False)
cursor = sqliteConnection.cursor()
i = 0
bot = telebot.TeleBot(token)
@bot.message_handler(commands=["start"])
def start(message):
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
start_button = types.KeyboardButton(text = 'Начать')
markup.add(start_button)
bot.send_message(message.chat.id, m_hello, reply_markup = markup)
@bot.message_handler(func = lambda message: not message.from_user.is_bot)
def begin(message):
isStopped = False
if message.chat.type == 'private':
if message.text == 'Начать':
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
minus_button = types.KeyboardButton(text = "+")
plus_button = types.KeyboardButton(text = "-")
markup.add(minus_button,plus_button)
bot.send_message(message.from_user.id, m_instruction,reply_markup=markup)
elif message.text == '-':
global i
spisok = cursor.execute("""SELECT name, gender FROM information_of_psych""")
data = cursor.fetchall()
try :
list_of_inf = []
for value in data[i]:
list_of_inf.append(value)
inf = ''
for value in list_of_inf:
value = value + '\n'
inf += '' + value
bot.send_message(message.from_user.id,inf)
i = i + 1
except IndexError:
i = 0
bot.send_message(message.from_user.id,m_update)
elif message.text == '+':
bot.send_message(message.from_user.id, m_sent)
bot.polling(none_stop=True, interval=0)