add func - input numberic

This commit is contained in:
ada-dmitry
2023-05-23 09:28:53 +03:00
parent c0aafa1eb5
commit eb2cc0ad42
12 changed files with 14 additions and 8 deletions
Binary file not shown.
Binary file not shown.
+3 -3
View File
@@ -1,5 +1,5 @@
hostname = "localhost" hostname = "localhost"
databname = "ada" databname = "postgres"
username = "postgres" username = "ada"
passw = "Ri588856" passw = "?Ri588856"
api = "6285042955:AAEPprYo9K7Ta0RkDcoqO2Z4Ejdw8to1NX0" api = "6285042955:AAEPprYo9K7Ta0RkDcoqO2Z4Ejdw8to1NX0"
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

+1 -1
View File
@@ -17,7 +17,7 @@ except psycopg2.errors.DuplicateTable:
print("") print("")
for i in range(15): for i in range(20):
url = 'https://amwine.ru' + \ url = 'https://amwine.ru' + \
parser.pictures[i].find('a').find('img').attrs['data-src'] parser.pictures[i].find('a').find('img').attrs['data-src']
filename = f"Python/TeleBot/image/{i}.jpg" filename = f"Python/TeleBot/image/{i}.jpg"
+10 -4
View File
@@ -15,7 +15,7 @@ except psycopg2.errors.UndefinedTable:
import tableCreator import tableCreator
array = FuncForBot.sel(cursor, 'parser') array = FuncForBot.sel(cursor, 'parser')
finally: finally:
FuncForBot.upd(connection, cursor, 'parser') # FuncForBot.upd(connection, cursor, 'parser')
cursor.close() cursor.close()
connection.close() connection.close()
@@ -30,17 +30,23 @@ def start(m, res=False):
markup.add(item1) markup.add(item1)
markup.add(item2) markup.add(item2)
bot.send_message( 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"]) @bot.message_handler(content_types=["text"])
def handle_text(message): def handle_text(message):
if (message.text.strip() == 'Рандомное вино!'): m = message.text.strip()
if (m == 'Рандомное вино!'):
i = random.choice(array) i = random.choice(array)
ans = f'Название: {i[1]}\nЦена: {i[2]}\nЦена без скидки: {i[3]}\nОценка: {i[4]}\n' ans = f'Название: {i[1]}\nЦена: {i[2]}\nЦена без скидки: {i[3]}\nОценка: {i[4]}\n'
bot.send_message(message.chat.id, ans) bot.send_message(message.chat.id, ans)
bot.send_photo(message.chat.id, open(i[5], 'rb')) 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) bot.send_message(message.chat.id, 'Ввод: ' + message.text)