diff --git a/Python/TeleBot/__pycache__/FuncForBot.cpython-310.pyc b/Python/TeleBot/__pycache__/FuncForBot.cpython-310.pyc index 89a7912..7101969 100644 Binary files a/Python/TeleBot/__pycache__/FuncForBot.cpython-310.pyc and b/Python/TeleBot/__pycache__/FuncForBot.cpython-310.pyc differ diff --git a/Python/TeleBot/__pycache__/config.cpython-310.pyc b/Python/TeleBot/__pycache__/config.cpython-310.pyc index 75f49ea..3487213 100644 Binary files a/Python/TeleBot/__pycache__/config.cpython-310.pyc and b/Python/TeleBot/__pycache__/config.cpython-310.pyc differ diff --git a/Python/TeleBot/__pycache__/parser.cpython-310.pyc b/Python/TeleBot/__pycache__/parser.cpython-310.pyc index 8c09077..0a49c94 100644 Binary files a/Python/TeleBot/__pycache__/parser.cpython-310.pyc and b/Python/TeleBot/__pycache__/parser.cpython-310.pyc differ diff --git a/Python/TeleBot/__pycache__/tableCreator.cpython-310.pyc b/Python/TeleBot/__pycache__/tableCreator.cpython-310.pyc new file mode 100644 index 0000000..6f5c837 Binary files /dev/null and b/Python/TeleBot/__pycache__/tableCreator.cpython-310.pyc differ diff --git a/Python/TeleBot/config.py b/Python/TeleBot/config.py index 980be0e..45f5460 100644 --- a/Python/TeleBot/config.py +++ b/Python/TeleBot/config.py @@ -1,5 +1,5 @@ hostname = "localhost" -databname = "ada" -username = "postgres" -passw = "Ri588856" +databname = "postgres" +username = "ada" +passw = "?Ri588856" api = "6285042955:AAEPprYo9K7Ta0RkDcoqO2Z4Ejdw8to1NX0" \ No newline at end of file diff --git a/Python/TeleBot/image/15.jpg b/Python/TeleBot/image/15.jpg new file mode 100644 index 0000000..caa4c17 Binary files /dev/null and b/Python/TeleBot/image/15.jpg differ diff --git a/Python/TeleBot/image/16.jpg b/Python/TeleBot/image/16.jpg new file mode 100644 index 0000000..397accf Binary files /dev/null and b/Python/TeleBot/image/16.jpg differ diff --git a/Python/TeleBot/image/17.jpg b/Python/TeleBot/image/17.jpg new file mode 100644 index 0000000..40e22a5 Binary files /dev/null and b/Python/TeleBot/image/17.jpg differ diff --git a/Python/TeleBot/image/18.jpg b/Python/TeleBot/image/18.jpg new file mode 100644 index 0000000..fde172c Binary files /dev/null and b/Python/TeleBot/image/18.jpg differ diff --git a/Python/TeleBot/image/19.jpg b/Python/TeleBot/image/19.jpg new file mode 100644 index 0000000..320b2ea Binary files /dev/null and b/Python/TeleBot/image/19.jpg differ diff --git a/Python/TeleBot/tableCreator.py b/Python/TeleBot/tableCreator.py index 57e06db..9e14a03 100644 --- a/Python/TeleBot/tableCreator.py +++ b/Python/TeleBot/tableCreator.py @@ -17,7 +17,7 @@ except psycopg2.errors.DuplicateTable: print("") -for i in range(15): +for i in range(20): url = 'https://amwine.ru' + \ parser.pictures[i].find('a').find('img').attrs['data-src'] filename = f"Python/TeleBot/image/{i}.jpg" diff --git a/Python/TeleBot/tgBot.py b/Python/TeleBot/tgBot.py index f36db68..e5ee809 100644 --- a/Python/TeleBot/tgBot.py +++ b/Python/TeleBot/tgBot.py @@ -15,7 +15,7 @@ except psycopg2.errors.UndefinedTable: import tableCreator array = FuncForBot.sel(cursor, 'parser') finally: - FuncForBot.upd(connection, cursor, 'parser') + # FuncForBot.upd(connection, cursor, 'parser') cursor.close() connection.close() @@ -30,17 +30,23 @@ def start(m, res=False): markup.add(item1) markup.add(item2) bot.send_message( - m.chat.id, '"Рандомное вино!" - для получения карточки товара\n "Повтори!" - для повторения сообщений.', reply_markup=markup) + m.chat.id, '"Рандомное вино!" - для получения карточки товара\n Введите число(1-20) для вывода определенной позиции\n "Повтори!" - для повторения сообщений.', reply_markup=markup) @bot.message_handler(content_types=["text"]) def handle_text(message): - if (message.text.strip() == 'Рандомное вино!'): + m = message.text.strip() + if (m == 'Рандомное вино!'): i = random.choice(array) ans = f'Название: {i[1]}\nЦена: {i[2]}\nЦена без скидки: {i[3]}\nОценка: {i[4]}\n' bot.send_message(message.chat.id, ans) bot.send_photo(message.chat.id, open(i[5], 'rb')) - elif (message.text.strip() == 'Повтори!'): + elif (m.isnumeric() == True): + i = array[int(m)] + ans = f'Название: {i[1]}\nЦена: {i[2]}\nЦена без скидки: {i[3]}\nОценка: {i[4]}\n' + bot.send_message(message.chat.id, ans) + bot.send_photo(message.chat.id, open(i[5], 'rb')) + elif (m == 'Повтори!'): bot.send_message(message.chat.id, 'Ввод: ' + message.text)