From c8cc2b841db22403261c2eea483f998d34e80f8c Mon Sep 17 00:00:00 2001
From: iOnTuMuCTi <7133210@gmail.com>
Date: Mon, 10 Apr 2023 21:47:15 +0300
Subject: [PATCH 01/33] =?UTF-8?q?=D0=94=D0=B7=20=D0=B1=D0=BE=D1=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/.name | 5 ----
.idea/workspace.xml | 8 +++---
Задания/task1/Sukhanov/BOT_TG.py | 46 ++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 9 deletions(-)
delete mode 100644 .idea/.name
create mode 100644 Задания/task1/Sukhanov/BOT_TG.py
diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index 03f298c..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1,5 +0,0 @@
-<<<<<<< HEAD
-parcing.py
-=======
-Work with driver.py
->>>>>>> origin/master
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 4d658fb..b89946a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -33,11 +33,11 @@
- {
+ "keyToString": {
+ "last_opened_file_path": "C:/Users/Honor/c22712"
}
-}]]>
+}
diff --git a/Задания/task1/Sukhanov/BOT_TG.py b/Задания/task1/Sukhanov/BOT_TG.py
new file mode 100644
index 0000000..77500b9
--- /dev/null
+++ b/Задания/task1/Sukhanov/BOT_TG.py
@@ -0,0 +1,46 @@
+import telebot
+import random
+from telebot import types
+
+# Загружаем список интересных фактов
+f = open('C:\\Users\\71332\\Desktop\\p\\факт.txt', 'r', encoding='UTF-8')
+facts = f.read().split('\n')
+f.close()
+# Загружаем список поговорок
+f = open('C:\\Users\\71332\\Desktop\\p\\поговорка.txt', 'r', encoding='UTF-8')
+thinks = f.read().split('\n')
+f.close()
+
+# Создаем экземпляр бота
+bot = telebot.TeleBot('6293063008:AAEFscB5LEjxC_4irrcgT-z6Eb0NXYOxZng')
+
+# Функция, обрабатывающая команду /start
+@bot.message_handler(commands=["start"])
+def start(m, res=False):
+
+ # Добавляем две кнопки
+ markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
+ item1 = types.KeyboardButton("Факт")
+ item2 = types.KeyboardButton("Поговорка")
+ markup.add(item1)
+ markup.add(item2)
+ bot.send_message(m.chat.id, 'Нажми: \nФакт'
+ ' для получения интересного факта\nПоговорка '
+ '— для получения мудрой цитаты ', reply_markup=markup)
+
+# Получение сообщений от юзера
+@bot.message_handler(content_types=["text"]) #прослушиваем сообщения
+def handle_text(message):
+ # Если юзер прислал 1, выдаем ему случайный факт
+ if message.text.strip() == 'Факт':
+ answer = random.choice(facts)
+ # Если юзер прислал 2, выдаем умную мысль
+ elif message.text.strip() == 'Поговорка':
+ answer = random.choice(thinks)
+ # Отсылаем юзеру сообщение в его чат
+ bot.send_message(message.chat.id, answer)
+
+ #bot.send_message(message.chat.id, 'Вы написали: ' + message.text)
+
+# Запускаем бота
+bot.infinity_polling(none_stop=True, interval=0) #запустить через DEBUG
\ No newline at end of file
From efb8b451306d41019794d1ad01c1865c4e81872b Mon Sep 17 00:00:00 2001
From: iOnTuMuCTi <124861991+iOnTuMuCTi@users.noreply.github.com>
Date: Mon, 10 Apr 2023 21:49:15 +0300
Subject: [PATCH 02/33] Update BOT_TG.py
---
Задания/task1/Sukhanov/BOT_TG.py | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/Задания/task1/Sukhanov/BOT_TG.py b/Задания/task1/Sukhanov/BOT_TG.py
index 77500b9..cb85ce0 100644
--- a/Задания/task1/Sukhanov/BOT_TG.py
+++ b/Задания/task1/Sukhanov/BOT_TG.py
@@ -2,23 +2,21 @@ import telebot
import random
from telebot import types
-# Загружаем список интересных фактов
f = open('C:\\Users\\71332\\Desktop\\p\\факт.txt', 'r', encoding='UTF-8')
facts = f.read().split('\n')
f.close()
-# Загружаем список поговорок
+
f = open('C:\\Users\\71332\\Desktop\\p\\поговорка.txt', 'r', encoding='UTF-8')
thinks = f.read().split('\n')
f.close()
-# Создаем экземпляр бота
+
bot = telebot.TeleBot('6293063008:AAEFscB5LEjxC_4irrcgT-z6Eb0NXYOxZng')
-# Функция, обрабатывающая команду /start
+
@bot.message_handler(commands=["start"])
def start(m, res=False):
- # Добавляем две кнопки
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton("Факт")
item2 = types.KeyboardButton("Поговорка")
@@ -28,19 +26,14 @@ def start(m, res=False):
' для получения интересного факта\nПоговорка '
'— для получения мудрой цитаты ', reply_markup=markup)
-# Получение сообщений от юзера
-@bot.message_handler(content_types=["text"]) #прослушиваем сообщения
+@bot.message_handler(content_types=["text"])
def handle_text(message):
- # Если юзер прислал 1, выдаем ему случайный факт
if message.text.strip() == 'Факт':
answer = random.choice(facts)
- # Если юзер прислал 2, выдаем умную мысль
elif message.text.strip() == 'Поговорка':
answer = random.choice(thinks)
- # Отсылаем юзеру сообщение в его чат
bot.send_message(message.chat.id, answer)
- #bot.send_message(message.chat.id, 'Вы написали: ' + message.text)
-# Запускаем бота
-bot.infinity_polling(none_stop=True, interval=0) #запустить через DEBUG
\ No newline at end of file
+
+bot.infinity_polling(none_stop=True, interval=0)
From 43744a8e17e8fe98f165c403c7161f599d974d3e Mon Sep 17 00:00:00 2001
From: Dmitry <124861781+ada-dmitry@users.noreply.github.com>
Date: Tue, 11 Apr 2023 21:03:25 +0300
Subject: [PATCH 03/33] Create link_to_gh
---
Задания/task1/Antipenko/link_to_gh | 1 +
1 file changed, 1 insertion(+)
create mode 100644 Задания/task1/Antipenko/link_to_gh
diff --git a/Задания/task1/Antipenko/link_to_gh b/Задания/task1/Antipenko/link_to_gh
new file mode 100644
index 0000000..457aba9
--- /dev/null
+++ b/Задания/task1/Antipenko/link_to_gh
@@ -0,0 +1 @@
+https://github.com/ada-dmitry/PyProg_ada/tree/master/Python/TeleBot
From 775a3f58a5313219fe01698bbdfe7ef34b233c09 Mon Sep 17 00:00:00 2001
From: Dronminator
Date: Sat, 15 Apr 2023 13:18:11 +0300
Subject: [PATCH 04/33] =?UTF-8?q?=D0=A2=D0=B5=D0=BB=D0=B5=D0=B3=D1=80?=
=?UTF-8?q?=D0=B0=D0=BC=20=D0=91=D0=BE=D1=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Задания/task1/Lahin/postgres.py | 19 ++++++++-------
Задания/task1/Lahin/telegrambot.py | 37 ++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 10 deletions(-)
create mode 100644 Задания/task1/Lahin/telegrambot.py
diff --git a/Задания/task1/Lahin/postgres.py b/Задания/task1/Lahin/postgres.py
index cfa0920..3afaf45 100644
--- a/Задания/task1/Lahin/postgres.py
+++ b/Задания/task1/Lahin/postgres.py
@@ -4,6 +4,7 @@ from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import time
+
i = 1
s = Service("С:\DATA\ChromeDriver\chromedriver.exe")
browser = webdriver.Chrome(service=s)
@@ -24,12 +25,12 @@ features = soup.find_all('span', class_="product-feature-list__value")
pictures = soup.find_all('div', class_="product-picture-container")
connection=psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4')
cursor = connection.cursor()
-""" insert = CREATE TABLE public.laptops(
+insert = """CREATE TABLE public.laptops(
id serial primary key,
-product varchar(100),
-price varchar(15),
-diagonal varchar(5),
-resolution varchar(20),
+Product varchar(100),
+Price varchar(15),
+Diagonal varchar(5),
+Resolution varchar(20),
CPU varchar(50),
RAM varchar(15),
Graphics_Controller varchar(40),
@@ -37,7 +38,7 @@ Volume varchar(25),
src varchar(100)
);
"""
-insert = """TRUNCATE TABLE public.laptops; ALTER SEQUENCE laptops_id_seq RESTART WITH 1;"""
+
cursor.execute(insert)
connection.commit()
for i in range(len(productst)):
@@ -49,13 +50,11 @@ for i in range(len(productst)):
wget.download(url, filename)
t = pricest[i].text.replace("\xa0", " ")
insert = f"""INSERT INTO public.laptops(
- product, price, diagonal, resolution, CPU, RAM, Graphics_Controller, Volume, src)
+ Product, Price, Diagonal, Resolution, CPU, RAM, Graphics_Controller, Volume, src)
VALUES
('{productst[i].text.strip()}', '{t.strip()}', '{u[0][:u[0].find("/")]}', '{u[0][u[0].find("/")+1:]}',
'{u[2]}', '{u[4]+" "+u[5]}', '{u[6]}', '{u[8]}', '{filename}');"""
cursor.execute(insert)
connection.commit()
-cursor.execute("select * from laptops")
-print("Результат", cursor.fetchall())
cursor.close()
-connection.close()
+connection.close()
\ No newline at end of file
diff --git a/Задания/task1/Lahin/telegrambot.py b/Задания/task1/Lahin/telegrambot.py
new file mode 100644
index 0000000..b09b60e
--- /dev/null
+++ b/Задания/task1/Lahin/telegrambot.py
@@ -0,0 +1,37 @@
+import telebot
+import psycopg2
+def execute_request(request):
+ connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4')
+ cursor = connection.cursor()
+ cursor.execute(request)
+ result = cursor.fetchall()
+ cursor.close()
+ connection.close()
+ return result
+max_id = int(execute_request("select count(*) from laptops")[0][0])
+bot = telebot.TeleBot('5656574233:AAEU1Ggc4J1aWMtlLnphtScDd3jGCrzbuuY')
+@bot.message_handler(commands=["start"])
+def start(m, res=False):
+ bot.send_message(m.chat.id, f'Привет. Введите идентификатор от 1 до {max_id}, чтобы получить данные: ')
+
+@bot.message_handler(content_types=["text"])
+def from_bd(message):
+ try:
+ current_id = int(message.text)
+ except BaseException:
+ bot.send_message(message.chat.id, "Вы неправильно ввели ID. Попробуйте снова:")
+ return
+ if current_id > max_id:
+ bot.send_message(message.chat.id, "ID больше, чем количество товаров. Попробуйте снова:")
+ return
+ else:
+ data = execute_request(f"select * from laptops where id = {current_id}")[0][1:-1]
+ names_of_columns = [i[0] for i in execute_request(f"""select Column_name from Information_schema.columns where Table_name = 'laptops'""")][1:-1]
+ everydata = []
+ for data_name, column_name in zip(data, names_of_columns):
+ everydata.append(column_name.capitalize() + ": " + data_name)
+ bot.send_message(message.chat.id, "\n\n".join(everydata))
+ bot.send_message(message.chat.id, f"Введите следующий ID от 1 до {max_id}:")
+bot.polling(none_stop=True, interval=0)
+
+
From b50a1dccf508a4b739be9fa33cd5d803787927fa Mon Sep 17 00:00:00 2001
From: Dronminator
Date: Sat, 15 Apr 2023 19:40:02 +0300
Subject: [PATCH 05/33] =?UTF-8?q?=D0=A2=D0=B5=D0=BB=D0=B5=D0=B3=D1=80?=
=?UTF-8?q?=D0=B0=D0=BC=20=D0=91=D0=BE=D1=82=20(=D0=98=D1=81=D0=BF=D1=80?=
=?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=BD=D1=8B=D0=B9)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Задания/task1/Lahin/postgres.py | 4 ++--
Задания/task1/Lahin/telegrambot.py | 5 +++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/Задания/task1/Lahin/postgres.py b/Задания/task1/Lahin/postgres.py
index 3afaf45..fe8a029 100644
--- a/Задания/task1/Lahin/postgres.py
+++ b/Задания/task1/Lahin/postgres.py
@@ -4,7 +4,7 @@ from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import time
-
+import config
i = 1
s = Service("С:\DATA\ChromeDriver\chromedriver.exe")
browser = webdriver.Chrome(service=s)
@@ -23,7 +23,7 @@ productst = soup.find_all('a', class_="product-title__text")
pricest = soup.find_all('span', class_="price__main-value")
features = soup.find_all('span', class_="product-feature-list__value")
pictures = soup.find_all('div', class_="product-picture-container")
-connection=psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4')
+connection=psycopg2.connect(host=config.host, dbname=config.dbname, user=config.user, password=config.password)
cursor = connection.cursor()
insert = """CREATE TABLE public.laptops(
id serial primary key,
diff --git a/Задания/task1/Lahin/telegrambot.py b/Задания/task1/Lahin/telegrambot.py
index b09b60e..ee3ac7d 100644
--- a/Задания/task1/Lahin/telegrambot.py
+++ b/Задания/task1/Lahin/telegrambot.py
@@ -1,7 +1,8 @@
import telebot
import psycopg2
+import config
def execute_request(request):
- connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4')
+ connection = psycopg2.connect(host=config.host, dbname=config.dbname, user=config.user, password=config.password)
cursor = connection.cursor()
cursor.execute(request)
result = cursor.fetchall()
@@ -9,7 +10,7 @@ def execute_request(request):
connection.close()
return result
max_id = int(execute_request("select count(*) from laptops")[0][0])
-bot = telebot.TeleBot('5656574233:AAEU1Ggc4J1aWMtlLnphtScDd3jGCrzbuuY')
+bot = telebot.TeleBot(config.bot_token)
@bot.message_handler(commands=["start"])
def start(m, res=False):
bot.send_message(m.chat.id, f'Привет. Введите идентификатор от 1 до {max_id}, чтобы получить данные: ')
From 8d96d62299bb03caa7323e3655d43d64b98d4b75 Mon Sep 17 00:00:00 2001
From: Dronminator
Date: Sat, 15 Apr 2023 20:13:13 +0300
Subject: [PATCH 06/33] =?UTF-8?q?=D0=A2=D0=B5=D0=BB=D0=B5=D0=B3=D1=80?=
=?UTF-8?q?=D0=B0=D0=BC=20=D0=91=D0=BE=D1=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Задания/task1/Lahin/telegrambot.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Задания/task1/Lahin/telegrambot.py b/Задания/task1/Lahin/telegrambot.py
index ee3ac7d..3031c38 100644
--- a/Задания/task1/Lahin/telegrambot.py
+++ b/Задания/task1/Lahin/telegrambot.py
@@ -27,7 +27,7 @@ def from_bd(message):
return
else:
data = execute_request(f"select * from laptops where id = {current_id}")[0][1:-1]
- names_of_columns = [i[0] for i in execute_request(f"""select Column_name from Information_schema.columns where Table_name = 'laptops'""")][1:-1]
+ names_of_columns = ["Товар", "Цена", "Диагональ", "Разрешение", "Процессор", "Оперативная память", "Графический контроллер", "Объём диска"]
everydata = []
for data_name, column_name in zip(data, names_of_columns):
everydata.append(column_name.capitalize() + ": " + data_name)
From 1dab6aae0544450dd06bb18aba112dce50ba4307 Mon Sep 17 00:00:00 2001
From: inweems
Date: Wed, 19 Apr 2023 11:10:43 +0300
Subject: [PATCH 07/33] =?UTF-8?q?=D1=82=D0=B5=D0=BB=D0=B5=D0=B3=D1=80?=
=?UTF-8?q?=D0=B0=D0=BC=D0=BC=20=D0=B1=D0=BE=D1=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/22712.iml | 2 +-
.idea/misc.xml | 2 +-
.idea/workspace.xml | 73 ++++++++++++++++++++++++++++++-
Задания/task1/Prokhorova/dz.py | 10 ++++-
Задания/task1/Prokhorova/tgbot.py | 37 ++++++++++++++++
5 files changed, 119 insertions(+), 5 deletions(-)
create mode 100644 Задания/task1/Prokhorova/tgbot.py
diff --git a/.idea/22712.iml b/.idea/22712.iml
index 74d515a..9e6c4ca 100644
--- a/.idea/22712.iml
+++ b/.idea/22712.iml
@@ -4,7 +4,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index a971a2c..a6fa933 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index b89946a..4572841 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,13 @@
-
+
+
+
+
+
+
+
@@ -33,12 +39,45 @@
+<<<<<<< HEAD
{
"keyToString": {
"last_opened_file_path": "C:/Users/Honor/c22712"
}
}
+=======
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+>>>>>>> d1c29f6 (телеграмм бот)
@@ -61,6 +100,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -84,6 +144,8 @@
+
+
@@ -147,7 +209,14 @@
1680206771744
-
+
+ 1680207517708
+
+
+
+ 1680207517708
+
+
diff --git a/Задания/task1/Prokhorova/dz.py b/Задания/task1/Prokhorova/dz.py
index 3f21c6b..2dfcb87 100644
--- a/Задания/task1/Prokhorova/dz.py
+++ b/Задания/task1/Prokhorova/dz.py
@@ -19,12 +19,20 @@ browser.get('https://www.ozon.ru/category/platya-zhenskie-7502/')
html_code = browser.page_source
soup = BeautifulSoup(html_code, 'lxml')
-name = soup.find_all('span', class_="m2e e3m m3e m5e tsBodyL k7l l7k")
+names = []
sale = soup.find_all('div', class_="eg1 g3e")
+
price = soup.find_all('span', class_="a2a-a2")
info = soup.find_all('span', class_="je4")
picture = soup.find_all('div', class_="k1m")
+products = soup.find_all("div", class_="k7o o7k")
+for product in products:
+ names.append(soup.find('span', class_="m2e e3m m3e m5e tsBodyL k7l l7k").text.strip())
+
+print(names)
+exit(0)
+
for i in range(20):
url = picture[i].find('img').attrs['src']
file_name = f"C:\\Users\\Honor\\Desktop\\учеба\\прога\\pictures\\{i}.jpg"
diff --git a/Задания/task1/Prokhorova/tgbot.py b/Задания/task1/Prokhorova/tgbot.py
new file mode 100644
index 0000000..6c10419
--- /dev/null
+++ b/Задания/task1/Prokhorova/tgbot.py
@@ -0,0 +1,37 @@
+import telebot
+import random
+from telebot import types
+
+f = open('C:\\Users\\Honor\\Desktop\\учеба\\прога\\тг_бот\\бот\\факт.txt', 'r', encoding='UTF-8')
+facts = f.read().split('\n')
+f.close()
+
+f = open('C:\\Users\\Honor\\Desktop\\учеба\\прога\\тг_бот\\бот\\поговорка.txt', 'r', encoding='UTF-8')
+thinks = f.read().split('\n')
+f.close()
+
+bot = telebot.TeleBot('5696445699:AAEPKQgUAs39DTLr_iyQvlaFAsJNFK8DMnc')
+
+@bot.message_handler(commands=["start"])
+def start(m, res=False):
+
+ markup=types.ReplyKeyboardMarkup(resize_keyboard=True)
+ item1=types.KeyboardButton("Факт")
+ item2=types.KeyboardButton("Поговорка")
+ markup.add(item1)
+ markup.add(item2)
+ bot.send_message(m.chat.id, 'Нажми: \nФакт'
+ ' для получения интересного факта\nПоговорка '
+ '— для получения мудрой цитаты ', reply_markup=markup)
+
+@bot.message_handler(content_types=["text"])
+def handle_text(message):
+ if message.text.strip() == 'Факт' :
+ answer = random.choice(facts)
+
+ elif message.text.strip() == 'Поговорка':
+ answer = random.choice(thinks)
+
+ bot.send_message(message.chat.id, answer)
+
+bot.polling(none_stop=True, interval=0)
\ No newline at end of file
From 218e465e1aa3a95d7a9698aed999c64a49dc74d5 Mon Sep 17 00:00:00 2001
From: TatianaFilcheva <124861990+TatianaFilcheva@users.noreply.github.com>
Date: Wed, 19 Apr 2023 22:20:24 +0300
Subject: [PATCH 08/33] Add files via upload
---
Задания/task1/Filcheva/bot1.py | 121 +++++++++++++++++++++++++++++++++
1 file changed, 121 insertions(+)
create mode 100644 Задания/task1/Filcheva/bot1.py
diff --git a/Задания/task1/Filcheva/bot1.py b/Задания/task1/Filcheva/bot1.py
new file mode 100644
index 0000000..7265303
--- /dev/null
+++ b/Задания/task1/Filcheva/bot1.py
@@ -0,0 +1,121 @@
+import telebot
+import psycopg2
+from telebot import types
+# Создаем экземпляр бота
+bot = telebot.TeleBot('5898574743:AAF2y_y3U2IfWwQVJ_lF6mmiDPlx1YgU9-Q')
+# Функция, обрабатывающая команду /start
+
+@bot.message_handler(commands=["start"])
+def start_messanger(messanger):
+ connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4t5')
+ cursor = connection.cursor()
+ cursor.execute("select id, name from Distilleries")
+ first_step = []
+ for id, name in cursor.fetchall():
+ f_s = str(id) + '. ' + name
+ first_step.append(f_s)
+ my_str = '\n'.join(first_step)
+ bot.send_message(messanger.chat.id, 'Я на связи. Выберите интересующую вас Винокурню, введите ее номер\n' + my_str.strip())
+ cursor.close()
+ connection.close()
+
+
+@bot.message_handler(content_types=["text"])
+def output(put):
+ n = put.text.strip()
+ m = int(n)
+ connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4t5')
+ cursor = connection.cursor()
+
+ if (m==1):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(1)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 2):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(2)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 3):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(3)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 4):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(4)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 5):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(5)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 6):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(6)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 7):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(7)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 8):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(8)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 9):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(9)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+ if (m == 10):
+ cursor.execute("select place, contacts, imagelink from Distilleries where id in(10)")
+
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+
+bot.polling()
From 7387d8bfc7964822b3c13c172df4a3a51d508d7a Mon Sep 17 00:00:00 2001
From: eauskova <124862140+eauskova@users.noreply.github.com>
Date: Wed, 19 Apr 2023 23:21:21 +0300
Subject: [PATCH 09/33] tgbot
---
Задания/task1/Uskova/bott | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 Задания/task1/Uskova/bott
diff --git a/Задания/task1/Uskova/bott b/Задания/task1/Uskova/bott
new file mode 100644
index 0000000..bce252f
--- /dev/null
+++ b/Задания/task1/Uskova/bott
@@ -0,0 +1,28 @@
+import telebot
+import random
+from telebot import types
+f = open('C:\\Users\\Yekaterina\\Desktop\\бот\\pisateli.txt', 'r', encoding='UTF-8')
+facts = f.read().split('\n')
+f.close()
+f = open('C:\\Users\\Yekaterina\\Desktop\\бот\\facts.txt', 'r', encoding='UTF-8')
+thinks = f.read().split('\n')
+f.close()
+bot = telebot.TeleBot('6205726630:AAF4zfV_P2b0f7bClm__sWuRmoZ1XpiC_xo')
+@bot.message_handler(commands=["start"])
+def start(m, res=False):
+ markup=types.ReplyKeyboardMarkup(resize_keyboard=True)
+ item1=types.KeyboardButton("Писатели")
+ item2=types.KeyboardButton("Факты")
+ markup.add(item1)
+ markup.add(item2)
+ bot.send_message(m.chat.id, 'Нажми: \nПисатель'
+ ' для получения интересного факта о писателе\nФакт '
+ '— для получения факта о книгах ', reply_markup=markup)
+@bot.message_handler(content_types=["text"])
+def handle_text(message):
+ if message.text.strip() == 'Писатели' :
+ answer = random.choice(facts)
+ elif message.text.strip() == 'Факты':
+ answer = random.choice(thinks)
+ bot.send_message(message.chat.id, answer)
+bot.polling(none_stop=True, interval=0)
From a8d18552bb4f53486ea979fd2fbff86c9bce1587 Mon Sep 17 00:00:00 2001
From: eauskova <124862140+eauskova@users.noreply.github.com>
Date: Wed, 19 Apr 2023 23:21:57 +0300
Subject: [PATCH 10/33] Rename bott to bott.py
---
Задания/task1/Uskova/{bott => bott.py} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename Задания/task1/Uskova/{bott => bott.py} (100%)
diff --git a/Задания/task1/Uskova/bott b/Задания/task1/Uskova/bott.py
similarity index 100%
rename from Задания/task1/Uskova/bott
rename to Задания/task1/Uskova/bott.py
From 6f79bc44868b04dd11a352550da40f90fdb3027a Mon Sep 17 00:00:00 2001
From: eauskova <124862140+eauskova@users.noreply.github.com>
Date: Wed, 19 Apr 2023 23:29:23 +0300
Subject: [PATCH 11/33] Delete bott.py
---
Задания/task1/Uskova/bott.py | 28 ----------------------------
1 file changed, 28 deletions(-)
delete mode 100644 Задания/task1/Uskova/bott.py
diff --git a/Задания/task1/Uskova/bott.py b/Задания/task1/Uskova/bott.py
deleted file mode 100644
index bce252f..0000000
--- a/Задания/task1/Uskova/bott.py
+++ /dev/null
@@ -1,28 +0,0 @@
-import telebot
-import random
-from telebot import types
-f = open('C:\\Users\\Yekaterina\\Desktop\\бот\\pisateli.txt', 'r', encoding='UTF-8')
-facts = f.read().split('\n')
-f.close()
-f = open('C:\\Users\\Yekaterina\\Desktop\\бот\\facts.txt', 'r', encoding='UTF-8')
-thinks = f.read().split('\n')
-f.close()
-bot = telebot.TeleBot('6205726630:AAF4zfV_P2b0f7bClm__sWuRmoZ1XpiC_xo')
-@bot.message_handler(commands=["start"])
-def start(m, res=False):
- markup=types.ReplyKeyboardMarkup(resize_keyboard=True)
- item1=types.KeyboardButton("Писатели")
- item2=types.KeyboardButton("Факты")
- markup.add(item1)
- markup.add(item2)
- bot.send_message(m.chat.id, 'Нажми: \nПисатель'
- ' для получения интересного факта о писателе\nФакт '
- '— для получения факта о книгах ', reply_markup=markup)
-@bot.message_handler(content_types=["text"])
-def handle_text(message):
- if message.text.strip() == 'Писатели' :
- answer = random.choice(facts)
- elif message.text.strip() == 'Факты':
- answer = random.choice(thinks)
- bot.send_message(message.chat.id, answer)
-bot.polling(none_stop=True, interval=0)
From 4a3f88a0537508b8fdf7c0405ba9540670a8cff5 Mon Sep 17 00:00:00 2001
From: eauskova <124862140+eauskova@users.noreply.github.com>
Date: Wed, 19 Apr 2023 23:55:44 +0300
Subject: [PATCH 12/33] tgbot
---
Задания/task1/Uskova/bott | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
create mode 100644 Задания/task1/Uskova/bott
diff --git a/Задания/task1/Uskova/bott b/Задания/task1/Uskova/bott
new file mode 100644
index 0000000..47436e0
--- /dev/null
+++ b/Задания/task1/Uskova/bott
@@ -0,0 +1,36 @@
+import telebot
+import psycopg2
+import config
+from telebot import types
+import random
+import tableCreator
+
+connection = psycopg2.connect(host='localhost', dbname='parc', user='postgres', password='Q1w2e3r4')
+cursor = connection.cursor()
+
+ins_query = """SELECT * FROM public.Notebooks"""
+cursor.execute(ins_query)
+array = list(cursor.fetchall())
+
+bot = telebot.TeleBot('6205726630:AAF4zfV_P2b0f7bClm__sWuRmoZ1XpiC_xo')
+@bot.message_handler(commands=["start"])
+
+def start(m, res=False):
+ markup=types.ReplyKeyboardMarkup(resize_keyboard=True)
+ item1=types.KeyboardButton("Выбери ноутбук")
+ item2=types.KeyboardButton("Еще!")
+ markup.add(item1)
+ markup.add(item2)
+ bot.send_message(m.chat.id, 'Нажми: \nВыбери ноутбук'
+ ' для просмотра товара\nЕще! '
+ '— для повтора', reply_markup=markup)
+@bot.message_handler(content_types=["text"])
+def handle_text(message):
+ if message.text.strip() == 'Выбери ноутбук' :
+ q = random.choice(array)
+ answer = f'Название: {q[1]}\nОписание: {q[2]}\nКод: {q[3]}\nЦена: {q[4]}\n'
+ bot.send_message(message.chat.id, answer)
+ bot.send_picture(message.chat.id, open(q[5], 'rb'))
+ elif message.text.strip() == 'Еще!':
+ bot.send_message(message.chat.id, 'Ввод: '+ message.text)
+bot.polling(none_stop=True, interval=0)
From 09ffcf3a6678e333b6f8d5605bebca6d7e632745 Mon Sep 17 00:00:00 2001
From: eauskova <124862140+eauskova@users.noreply.github.com>
Date: Wed, 19 Apr 2023 23:56:26 +0300
Subject: [PATCH 13/33] tgbot
---
Задания/task1/Uskova/{bott => bott.py} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename Задания/task1/Uskova/{bott => bott.py} (100%)
diff --git a/Задания/task1/Uskova/bott b/Задания/task1/Uskova/bott.py
similarity index 100%
rename from Задания/task1/Uskova/bott
rename to Задания/task1/Uskova/bott.py
From c7f1594b3d999c62d80787f5b10ed7345b0b8129 Mon Sep 17 00:00:00 2001
From: TatianaFilcheva <124861990+TatianaFilcheva@users.noreply.github.com>
Date: Thu, 20 Apr 2023 08:40:24 +0300
Subject: [PATCH 14/33] Add files via upload
---
Задания/task1/Filcheva/bot.py | 37 +++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 Задания/task1/Filcheva/bot.py
diff --git a/Задания/task1/Filcheva/bot.py b/Задания/task1/Filcheva/bot.py
new file mode 100644
index 0000000..7e700c6
--- /dev/null
+++ b/Задания/task1/Filcheva/bot.py
@@ -0,0 +1,37 @@
+import telebot
+import psycopg2
+from telebot import types
+# Создаем экземпляр бота
+bot = telebot.TeleBot('5898574743:AAF2y_y3U2IfWwQVJ_lF6mmiDPlx1YgU9-Q')
+# Функция, обрабатывающая команду /start
+
+@bot.message_handler(commands=["start"])
+def start_messanger(messanger):
+ connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4t5')
+ cursor = connection.cursor()
+ cursor.execute("select id, name from Distilleries")
+ first_step = []
+ for id, name in cursor.fetchall():
+ f_s = str(id) + '. ' + name
+ first_step.append(f_s)
+ my_str = '\n'.join(first_step)
+ bot.send_message(messanger.chat.id, 'Я на связи. Выберите интересующую вас Винокурню, введите ее номер\n' + my_str.strip())
+ cursor.close()
+ connection.close()
+
+
+@bot.message_handler(content_types=["text"])
+def output(put):
+ n = put.text.strip()
+ m = int(n)
+ connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4t5')
+ cursor = connection.cursor()
+ cursor.execute(f"select place, contacts, imagelink from Distilleries where id = {m}")
+ for place, contacts, imagelink in cursor.fetchall():
+ answer = 'Адрес: ' + place + ' ' + 'Контакты: ' + contacts + ' ' + 'Фото: ' + imagelink
+ bot.send_message(put.chat.id, answer)
+ cursor.close()
+ connection.close()
+
+
+bot.polling()
From 64a637a41bae0f101bf1e884d22a0dc6c96f6740 Mon Sep 17 00:00:00 2001
From: iOnTuMuCTi <124861991+iOnTuMuCTi@users.noreply.github.com>
Date: Thu, 20 Apr 2023 08:45:47 +0300
Subject: [PATCH 15/33] Update BOT_TG.py
---
Задания/task1/Sukhanov/BOT_TG.py | 38 --------------------------------
1 file changed, 38 deletions(-)
diff --git a/Задания/task1/Sukhanov/BOT_TG.py b/Задания/task1/Sukhanov/BOT_TG.py
index cb85ce0..8b13789 100644
--- a/Задания/task1/Sukhanov/BOT_TG.py
+++ b/Задания/task1/Sukhanov/BOT_TG.py
@@ -1,39 +1 @@
-import telebot
-import random
-from telebot import types
-f = open('C:\\Users\\71332\\Desktop\\p\\факт.txt', 'r', encoding='UTF-8')
-facts = f.read().split('\n')
-f.close()
-
-f = open('C:\\Users\\71332\\Desktop\\p\\поговорка.txt', 'r', encoding='UTF-8')
-thinks = f.read().split('\n')
-f.close()
-
-
-bot = telebot.TeleBot('6293063008:AAEFscB5LEjxC_4irrcgT-z6Eb0NXYOxZng')
-
-
-@bot.message_handler(commands=["start"])
-def start(m, res=False):
-
- markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
- item1 = types.KeyboardButton("Факт")
- item2 = types.KeyboardButton("Поговорка")
- markup.add(item1)
- markup.add(item2)
- bot.send_message(m.chat.id, 'Нажми: \nФакт'
- ' для получения интересного факта\nПоговорка '
- '— для получения мудрой цитаты ', reply_markup=markup)
-
-@bot.message_handler(content_types=["text"])
-def handle_text(message):
- if message.text.strip() == 'Факт':
- answer = random.choice(facts)
- elif message.text.strip() == 'Поговорка':
- answer = random.choice(thinks)
- bot.send_message(message.chat.id, answer)
-
-
-
-bot.infinity_polling(none_stop=True, interval=0)
From 676b43a3663a6402139fa9fc434d94abbfa97f84 Mon Sep 17 00:00:00 2001
From: Sklvd
Date: Thu, 20 Apr 2023 09:59:34 +0300
Subject: [PATCH 16/33] parsing in tg from db
---
Задания/task1/Kluchinskaya1/telegram_bot.py | 36 +++++++++++++++++++++
1 file changed, 36 insertions(+)
create mode 100644 Задания/task1/Kluchinskaya1/telegram_bot.py
diff --git a/Задания/task1/Kluchinskaya1/telegram_bot.py b/Задания/task1/Kluchinskaya1/telegram_bot.py
new file mode 100644
index 0000000..73b714e
--- /dev/null
+++ b/Задания/task1/Kluchinskaya1/telegram_bot.py
@@ -0,0 +1,36 @@
+import telebot
+import psycopg2
+def execute_request(request):
+ connection = psycopg2.connect(host='localhost', dbname='dbdata',
+ user='postgres', password='Q1w2e3r4')
+ cursor = connection.cursor()
+ cursor.execute(request)
+ result = cursor.fetchall()
+ cursor.close()
+ connection.close()
+ return result
+min_id = int(execute_request("select min(id) from parsing")[0][0])
+max_id = int(execute_request("select max(id) from parsing")[0][0])
+bot = telebot.TeleBot('6060681334:AAHASvjmAEn_DF_NjymP1MMpq14kYx_2cZw')
+@bot.message_handler(commands=["start"])
+def start(m, res=False):
+ bot.send_message(m.chat.id, f'Привет. Введите идентификатор от {min_id} до {max_id}, чтобы получить данные: ')
+@bot.message_handler(content_types=["text"])
+def from_bd(message):
+ try:
+ current_id = int(message.text)
+ except BaseException:
+ bot.send_message(message.chat.id, "Вы неправильно ввели ID. Попробуйте снова:")
+ return
+ if current_id > max_id or current_id < min_id:
+ bot.send_message(message.chat.id, "ID больше, чем количество товаров. Попробуйте снова:")
+ return
+ else:
+ data = execute_request(f"select * from parsing where id = {current_id}")[0][1:]
+ names_of_columns = ["name", "link"]
+ everydata = []
+ for data_name, column_name in zip(data, names_of_columns):
+ everydata.append(column_name.capitalize() + ": " + data_name)
+ bot.send_message(message.chat.id, "\n\n".join(everydata))
+ bot.send_message(message.chat.id, f"Введите следующий ID от {min_id} до {max_id}:")
+bot.polling(none_stop=True, interval=0)
From cbf925e2875fa8b1e38d09b377314ec883a5f77b Mon Sep 17 00:00:00 2001
From: Sklvd
Date: Thu, 20 Apr 2023 10:05:02 +0300
Subject: [PATCH 17/33] parsing in tg from db
---
Задания/task1/Kluchinskaya1/{telegram_bot.py => telegramBot.py} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename Задания/task1/Kluchinskaya1/{telegram_bot.py => telegramBot.py} (100%)
diff --git a/Задания/task1/Kluchinskaya1/telegram_bot.py b/Задания/task1/Kluchinskaya1/telegramBot.py
similarity index 100%
rename from Задания/task1/Kluchinskaya1/telegram_bot.py
rename to Задания/task1/Kluchinskaya1/telegramBot.py
From e094efa7aa5a40837cc93db2c681f9960d82c901 Mon Sep 17 00:00:00 2001
From: Sklvd
Date: Thu, 20 Apr 2023 10:07:05 +0300
Subject: [PATCH 18/33] tgbot from db
---
Задания/task1/Kluchinskaya1/telegramBot.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/Задания/task1/Kluchinskaya1/telegramBot.py b/Задания/task1/Kluchinskaya1/telegramBot.py
index 73b714e..1723ade 100644
--- a/Задания/task1/Kluchinskaya1/telegramBot.py
+++ b/Задания/task1/Kluchinskaya1/telegramBot.py
@@ -34,3 +34,4 @@ def from_bd(message):
bot.send_message(message.chat.id, "\n\n".join(everydata))
bot.send_message(message.chat.id, f"Введите следующий ID от {min_id} до {max_id}:")
bot.polling(none_stop=True, interval=0)
+#for commit
From 3aa7bb3d7d50041ec837fb170c96ddebada9433f Mon Sep 17 00:00:00 2001
From: iOnTuMuCTi <124861991+iOnTuMuCTi@users.noreply.github.com>
Date: Thu, 20 Apr 2023 11:05:35 +0300
Subject: [PATCH 19/33] Update BOT_TG.py
---
Задания/task1/Sukhanov/BOT_TG.py | 38 ++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/Задания/task1/Sukhanov/BOT_TG.py b/Задания/task1/Sukhanov/BOT_TG.py
index 8b13789..4972205 100644
--- a/Задания/task1/Sukhanov/BOT_TG.py
+++ b/Задания/task1/Sukhanov/BOT_TG.py
@@ -1 +1,39 @@
+import telebot
+import psycopg2
+import config
+from telebot import types
+import random
+connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4')
+
+cursor = connection.cursor()
+
+sel_query = """SELECT * FROM public.parser"""
+cursor.execute(sel_query)
+array = list(cursor.fetchall())
+
+bot = telebot.TeleBot('6293063008:AAEFscB5LEjxC_4irrcgT-z6Eb0NXYOxZng')
+@bot.message_handler(commands=["start"])
+def start(m, res=False):
+ markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
+ item1 = types.KeyboardButton("Рандомный продукт")
+ item2 = types.KeyboardButton("Повтори!")
+ markup.add(item1)
+ markup.add(item2)
+ bot.send_message(m.chat.id,
+ '"Рандомный продукт" - для получения карточки товара\n "Повтори!" - для повторения сообщений.',
+ reply_markup=markup)
+
+
+@bot.message_handler(content_types=["text"])
+def handle_text(message):
+ if (message.text.strip() == 'Рандомный продукт'):
+ i = random.choice(array)
+ ans = f'Название: {i[1]}\nЦена: {i[2]}\nРейтинг: {i[3]}\n'
+ bot.send_message(message.chat.id, ans)
+ bot.send_photo(message.chat.id, open(i[4], 'rb'))
+ elif (message.text.strip() == 'Повтори!'):
+ bot.send_message(message.chat.id, 'Ввод: ' + message.text)
+
+
+bot.polling(none_stop=True, interval=0)
From 8fc1cf3f164a173a36aed65e784193f1fdbe0b55 Mon Sep 17 00:00:00 2001
From: Harutyun
Date: Thu, 20 Apr 2023 11:06:26 +0300
Subject: [PATCH 20/33] parser with database
---
Задания/task1/Garanyan/tgbot.py | 47 +++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
create mode 100644 Задания/task1/Garanyan/tgbot.py
diff --git a/Задания/task1/Garanyan/tgbot.py b/Задания/task1/Garanyan/tgbot.py
new file mode 100644
index 0000000..91ffddf
--- /dev/null
+++ b/Задания/task1/Garanyan/tgbot.py
@@ -0,0 +1,47 @@
+import telebot
+import psycopg2
+from telebot import types
+import random
+
+connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres',
+ password='Q1w2e3r4')
+cursor = connection.cursor()
+try:
+ sel_query = """SELECT * FROM public.food"""
+ cursor.execute(sel_query)
+except psycopg2.errors.UndefinedTable:
+ connection.rollback()
+ import tableCreator
+
+ sel_query = """SELECT * FROM public.food"""
+ cursor.execute(sel_query)
+
+array = list(cursor.fetchall())
+
+bot = telebot.TeleBot('841097550:AAFc5MoFRivTEfv-gOSJctqH53NfYMTKpCc')
+
+
+@bot.message_handler(commands=["start"])
+def start(m, res=False):
+ markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
+ item1 = types.KeyboardButton("Хот-доги и соусы!")
+ item2 = types.KeyboardButton("Повтори!")
+ markup.add(item1)
+ markup.add(item2)
+ bot.send_message(m.chat.id,
+ '"Хот-доги и соусы!" - для получения случайного товара из нашей хотдожной\n "Повтори!" - для повторения сообщений.',
+ reply_markup=markup)
+
+
+@bot.message_handler(content_types=["text"])
+def handle_text(message):
+ if (message.text.strip() == 'Хот-доги и соусы!'):
+ i = random.choice(array)
+ ans = f'Название: {i[1]}\nЦена: {i[2]}\n'
+ bot.send_message(message.chat.id, ans)
+ bot.send_photo(message.chat.id, open(i[3], 'rb'))
+ elif (message.text.strip() == 'Повтори!'):
+ bot.send_message(message.chat.id, 'Ввод: ' + message.text)
+
+
+bot.polling(none_stop=True, interval=0)
\ No newline at end of file
From 0981a7b70b4c1c3443bbb196a1615e34631e1f08 Mon Sep 17 00:00:00 2001
From: Harutyun
Date: Thu, 20 Apr 2023 11:07:53 +0300
Subject: [PATCH 21/33] bot telegram 1 popytka
---
Задания/task1/Garanyan/tgbot.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Задания/task1/Garanyan/tgbot.py b/Задания/task1/Garanyan/tgbot.py
index 91ffddf..2b47151 100644
--- a/Задания/task1/Garanyan/tgbot.py
+++ b/Задания/task1/Garanyan/tgbot.py
@@ -2,7 +2,7 @@ import telebot
import psycopg2
from telebot import types
import random
-
+#hello
connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres',
password='Q1w2e3r4')
cursor = connection.cursor()
From 67ff96b8636e5aa4c70ee31dbd81b78f2ac4b732 Mon Sep 17 00:00:00 2001
From: Sanich777
Date: Thu, 20 Apr 2023 11:21:46 +0300
Subject: [PATCH 22/33] =?UTF-8?q?=D0=9F=D0=B0=D1=80=D1=81=D0=B8=D0=BD?=
=?UTF-8?q?=D0=B3=20=D0=B1=D0=B4=20=D1=83=D0=BB=D1=83=D1=87=D1=88=D0=B5?=
=?UTF-8?q?=D0=BD=D0=BD=D1=8B=D0=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Задания/task1/Kulikov/db_parsV2.0.py | 54 ++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
create mode 100644 Задания/task1/Kulikov/db_parsV2.0.py
diff --git a/Задания/task1/Kulikov/db_parsV2.0.py b/Задания/task1/Kulikov/db_parsV2.0.py
new file mode 100644
index 0000000..2892449
--- /dev/null
+++ b/Задания/task1/Kulikov/db_parsV2.0.py
@@ -0,0 +1,54 @@
+from bs4 import BeautifulSoup
+from selenium.webdriver import Chrome
+from selenium import webdriver
+from selenium.webdriver.chrome.service import Service
+import time
+import wget
+import psycopg2
+import re
+s = Service('C:\Users\Alex\PycharmProjects\pythonProject\chromedriver.exe')
+browser = webdriver.Chrome(service=s)
+browser.get('https://music.yandex.ru/chart')
+time.sleep (1)
+html_text = browser.page_source
+soup = BeautifulSoup(html_text, 'lxml')
+Трек=soup.find_all('a', class_='d-track__title deco-link deco-link_stronger')
+Длительность=soup.find_all('div', class_='d-track__info d-track__nohover')
+Автор=soup.find_all('span', class_='d-track__artists')
+Картинки=soup.find_all('img', class_='entity-cover__image deco-pane')
+str_Картинки=[]
+for i in range(len(Картинки)):
+ str_Картинки.append(Картинки[i])
+str_Картинки=str(str_Картинки)
+str_Картинки=re.findall(r'src="(.*?)"',str_Картинки)
+for i in range(len(str_Картинки)):
+ str_Картинки[i]='https:'+str_Картинки[i]
+#for i in range(len(str_cartinki)):
+ #wget.download(str_cartinki[i], 'TOP'+str((i+1))+'.jpeg')
+
+
+connection = psycopg2.connect(dbname = 'dbdata',
+ user='postgres', password='Q1w2e3r4',
+ host='localhost')
+cursor=connection.cursor()
+creat_table="""CREATE TABLE music
+ (id serial primary key, "Трек" varchar(100),
+ "Длительность" varchar(100),
+ "Автор" varchar(100),
+ "Картинки" varchar(100))"""
+cursor.execute(creat_table)
+connection.commit()
+for Трек, Длительность, Автор, Картинки in zip(Трек, Автор, Длительность, Картинки):
+ qwery=f"""INSERT INTO public.music(
+ Трек, Длительность, Автор, Картинки)
+ VALUES
+ ('{Трек.text}','{Длительность.text}','{Автор.text}', '{Картинки.text}' )"""
+ cursor.execute(qwery)
+ connection.commit()
+for i in range(1,len(str_Картинки)+1):
+ puti = r'C:\papkta' + str(i) + '.jpeg'
+ qwery=f"""UPDATE public.music
+ SET Картинки='{puti}'
+ WHERE id={i}"""
+ cursor.execute(qwery)
+ connection.commit()
\ No newline at end of file
From 71d55083478f3642d2245e232f9041bd12d8d3a5 Mon Sep 17 00:00:00 2001
From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com>
Date: Sun, 23 Apr 2023 10:05:34 +0300
Subject: [PATCH 23/33] Create folder for tgBot
This is the file needed to create the folder
---
Задания/task1/Epifanov/folder for tgBot | 1 +
1 file changed, 1 insertion(+)
create mode 100644 Задания/task1/Epifanov/folder for tgBot
diff --git a/Задания/task1/Epifanov/folder for tgBot b/Задания/task1/Epifanov/folder for tgBot
new file mode 100644
index 0000000..7a5cafb
--- /dev/null
+++ b/Задания/task1/Epifanov/folder for tgBot
@@ -0,0 +1 @@
+folder-file
From 92c06f71a03cbc874d09823d44aa1939251bbbad Mon Sep 17 00:00:00 2001
From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com>
Date: Sun, 23 Apr 2023 10:07:22 +0300
Subject: [PATCH 24/33] Delete folder for tgBot
---
Задания/task1/Epifanov/folder for tgBot | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 Задания/task1/Epifanov/folder for tgBot
diff --git a/Задания/task1/Epifanov/folder for tgBot b/Задания/task1/Epifanov/folder for tgBot
deleted file mode 100644
index 7a5cafb..0000000
--- a/Задания/task1/Epifanov/folder for tgBot
+++ /dev/null
@@ -1 +0,0 @@
-folder-file
From e8bb76c772eac88de04253044d37bffe04c064a3 Mon Sep 17 00:00:00 2001
From: VladEpifanov
Date: Sun, 23 Apr 2023 10:17:19 +0300
Subject: [PATCH 25/33] =?UTF-8?q?=D0=A4=D1=83=D0=BD=D0=BA=D1=86=D0=B8?=
=?UTF-8?q?=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?=
=?UTF-8?q?=D1=8B=20=D1=81=20=D0=91=D0=94?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Задания/task1/Epifanov/WWFile.py | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
create mode 100644 Задания/task1/Epifanov/WWFile.py
diff --git a/Задания/task1/Epifanov/WWFile.py b/Задания/task1/Epifanov/WWFile.py
new file mode 100644
index 0000000..598f98f
--- /dev/null
+++ b/Задания/task1/Epifanov/WWFile.py
@@ -0,0 +1,22 @@
+import psycopg2
+
+connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4')
+cursor = connection.cursor()
+
+def edit(Col, N, NN, value):#Функция внесения изменений и сортировки
+ upd_query = f'''UPDATE Parse SET {Col} = '{NN}' WHERE {Col} = '{N}' '''
+ cursor.execute(upd_query)
+ ord_query = f'''SELECT * FROM public.parse order by {value};'''
+ cursor.execute(ord_query)
+ connection.commit()
+
+edit('Name', 'Ирисы небесно-голубого цвета', 'Ирисы', 'ID')
+
+#print(cursor.fetchall()) - для проверки
+
+def select(ID):
+ s_query = f'''SELECT * FROM public.Parse where ID = {ID}'''
+ cursor.execute(s_query)
+ return cursor.fetchone()
+
+#print(select(44)) - для проверки
From d6b3ab0894d85b65b9c7e735474ec3b5f027521f Mon Sep 17 00:00:00 2001
From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com>
Date: Sun, 23 Apr 2023 10:21:38 +0300
Subject: [PATCH 26/33] Delete WWFile.py
---
Задания/task1/Epifanov/WWFile.py | 22 ----------------------
1 file changed, 22 deletions(-)
delete mode 100644 Задания/task1/Epifanov/WWFile.py
diff --git a/Задания/task1/Epifanov/WWFile.py b/Задания/task1/Epifanov/WWFile.py
deleted file mode 100644
index 598f98f..0000000
--- a/Задания/task1/Epifanov/WWFile.py
+++ /dev/null
@@ -1,22 +0,0 @@
-import psycopg2
-
-connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4')
-cursor = connection.cursor()
-
-def edit(Col, N, NN, value):#Функция внесения изменений и сортировки
- upd_query = f'''UPDATE Parse SET {Col} = '{NN}' WHERE {Col} = '{N}' '''
- cursor.execute(upd_query)
- ord_query = f'''SELECT * FROM public.parse order by {value};'''
- cursor.execute(ord_query)
- connection.commit()
-
-edit('Name', 'Ирисы небесно-голубого цвета', 'Ирисы', 'ID')
-
-#print(cursor.fetchall()) - для проверки
-
-def select(ID):
- s_query = f'''SELECT * FROM public.Parse where ID = {ID}'''
- cursor.execute(s_query)
- return cursor.fetchone()
-
-#print(select(44)) - для проверки
From a8a81dd41c63d1ca0340b8f29642d416e88e4b9c Mon Sep 17 00:00:00 2001
From: VladEpifanov
Date: Sun, 23 Apr 2023 10:27:31 +0300
Subject: [PATCH 27/33] =?UTF-8?q?=D0=A4=D1=83=D0=BD=D0=BA=D1=86=D0=B8?=
=?UTF-8?q?=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?=
=?UTF-8?q?=D1=8B=20=D1=81=20=D0=91=D0=94?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Задания/task1/Epifanov/{WWFile.py => wwfuncs.py} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename Задания/task1/Epifanov/{WWFile.py => wwfuncs.py} (100%)
diff --git a/Задания/task1/Epifanov/WWFile.py b/Задания/task1/Epifanov/wwfuncs.py
similarity index 100%
rename from Задания/task1/Epifanov/WWFile.py
rename to Задания/task1/Epifanov/wwfuncs.py
From c1cc125a9664caf25cbb04027a6b764dafa1f209 Mon Sep 17 00:00:00 2001
From: VladEpifanov
Date: Sun, 23 Apr 2023 10:33:00 +0300
Subject: [PATCH 28/33] =?UTF-8?q?=D0=9A=D0=BE=D0=B4=20=D0=B4=D0=BB=D1=8F?=
=?UTF-8?q?=20=D0=B2=D0=B7=D0=B0=D0=B8=D0=BC=D0=BE=D0=B4=D0=B5=D0=B9=D1=81?=
=?UTF-8?q?=D1=82=D0=B2=D0=B8=D1=8F=20=D0=B1=D0=BE=D1=82=D0=B0=20=D1=81=20?=
=?UTF-8?q?=D0=91=D0=94=20+=20=D0=B7=D0=B0=D0=B4=D0=B5=D0=B9=D1=81=D1=82?=
=?UTF-8?q?=D0=B2=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=84=D1=83=D0=BD?=
=?UTF-8?q?=D0=BA=D1=86=D0=B8=D0=B8=20=D0=B8=D0=B7=20wwfuncs.py?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tgBot(try-exc-finally+usage of func-s.py | 63 +++++++++++++++++++
1 file changed, 63 insertions(+)
create mode 100644 Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py
diff --git a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py
new file mode 100644
index 0000000..47b402d
--- /dev/null
+++ b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py
@@ -0,0 +1,63 @@
+#Небольшое предисловие: кнопки item1, item2 и item3 похожи по своему функционалу, однако между ними есть разница в реализации - item3 реализована через функцию, прописанную в доп.файле
+import telebot
+import psycopg2
+from telebot import types
+import random
+from wwfuncs import select #импорт функции из другого файла
+
+connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4')
+cursor = connection.cursor()
+
+try:
+ s_query = """SELECT * FROM public.parse"""
+ cursor.execute(s_query)
+except psycopg2.errors.UndefinedTable: #рассматриваем случай, когда таблицы нет
+ connection.rollback() #возвращаемся "на действие назад"
+ import FHWDB #создаём и заполняем таблицу, если её не существовало ранее
+ connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4')
+ cursor = connection.cursor()
+ s_query = '''SELECT * FROM public.parse'''
+ cursor.execute(s_query)
+finally:
+ arr = list(cursor.fetchall())
+
+bot = telebot.TeleBot('5980905704:AAH2qIP4Gy60nhuKNAojOGpmI6zwNoJK1Iw')
+
+@bot.message_handler(commands=["start"])
+def start(m, res=False):
+ markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
+ item1 = types.KeyboardButton("Хочу информацию о любых цвеах, пожалуйста")
+ item2 = types.KeyboardButton("Хочу картинку любых цветов, пожалуйста")
+ item3 = types.KeyboardButton("Хочу информацию о предложении дня, пожалуйста")
+ item4 = types.KeyboardButton("Общая информация о сведениях, находящихся в базе данных")
+ markup.add(item1)
+ markup.add(item2)
+ markup.add(item3)
+ markup.add(item4)
+ bot.send_message(m.chat.id,
+ '"Хочу информацию о любых цветах, пожалуйста" - для получения карточки цветов;\n "Хочу картинку любых цветов, пожалуйста" - для получения картинки цветов;\n "Хочу информацию о предложении дня, пожалуйста" - сводка о конкретных цветах;\n "Общая информация о сведениях, находящихся в базе данных" - сводка об характеристиках товаров, информация о которых находится в БД.',
+ reply_markup=markup)
+
+@bot.message_handler(content_types=["text"])
+def handle_text(message):
+ if (message.text.strip() == "Хочу информацию о любых цвеах, пожалуйста"):
+ i = random.choice(arr)
+ a1 = f'Название: {i[1]};\nЦена: {i[2]};\nСкидка(в процентах): {i[3]};\n'
+ bot.send_message(message.chat.id, a1)
+ elif (message.text.strip() == "Хочу картинку любых цветов, пожалуйста"):
+ i = random.choice(arr)
+ bot.send_photo(message.chat.id, open(i[4], 'rb'))
+ elif (message.text.strip() == "Хочу информацию о предложении дня, пожалуйста"):
+ j = random.randint(1, 61)
+ i = list(select(j))
+ a1 = f'Название: {i[1]};\nЦена: {i[2]};\nСкидка(в процентах): {i[3]};\n'
+ bot.send_message(message.chat.id, "Предложение дня:\n")
+ bot.send_message(message.chat.id, a1)
+ bot.send_photo(message.chat.id, open(i[4], 'rb'))
+ else:
+ bot.send_message(message.chat.id, "С помощью данного бота вы можете получить информацию о 60-и цветах одного из московских магазинов по их продаже, в частности их: название, цену, скидку(в процентах) и фото. Вы можете это осуществить, взаимодействуя с ботом. Попробуйте! ")
+
+bot.polling(none_stop=True, interval=0)
+
+cursor.close()
+connection.close()
\ No newline at end of file
From effcf0e8ea93284673467f2d1bb15da87f601830 Mon Sep 17 00:00:00 2001
From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com>
Date: Sun, 23 Apr 2023 14:30:54 +0300
Subject: [PATCH 29/33] Delete tgBot(try-exc-finally+usage of func-s.py
---
.../tgBot(try-exc-finally+usage of func-s.py | 63 -------------------
1 file changed, 63 deletions(-)
delete mode 100644 Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py
diff --git a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py
deleted file mode 100644
index 47b402d..0000000
--- a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py
+++ /dev/null
@@ -1,63 +0,0 @@
-#Небольшое предисловие: кнопки item1, item2 и item3 похожи по своему функционалу, однако между ними есть разница в реализации - item3 реализована через функцию, прописанную в доп.файле
-import telebot
-import psycopg2
-from telebot import types
-import random
-from wwfuncs import select #импорт функции из другого файла
-
-connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4')
-cursor = connection.cursor()
-
-try:
- s_query = """SELECT * FROM public.parse"""
- cursor.execute(s_query)
-except psycopg2.errors.UndefinedTable: #рассматриваем случай, когда таблицы нет
- connection.rollback() #возвращаемся "на действие назад"
- import FHWDB #создаём и заполняем таблицу, если её не существовало ранее
- connection = psycopg2.connect(host='localhost', dbname='FHWDB', user='postgres', password='Q1w2e3r4')
- cursor = connection.cursor()
- s_query = '''SELECT * FROM public.parse'''
- cursor.execute(s_query)
-finally:
- arr = list(cursor.fetchall())
-
-bot = telebot.TeleBot('5980905704:AAH2qIP4Gy60nhuKNAojOGpmI6zwNoJK1Iw')
-
-@bot.message_handler(commands=["start"])
-def start(m, res=False):
- markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
- item1 = types.KeyboardButton("Хочу информацию о любых цвеах, пожалуйста")
- item2 = types.KeyboardButton("Хочу картинку любых цветов, пожалуйста")
- item3 = types.KeyboardButton("Хочу информацию о предложении дня, пожалуйста")
- item4 = types.KeyboardButton("Общая информация о сведениях, находящихся в базе данных")
- markup.add(item1)
- markup.add(item2)
- markup.add(item3)
- markup.add(item4)
- bot.send_message(m.chat.id,
- '"Хочу информацию о любых цветах, пожалуйста" - для получения карточки цветов;\n "Хочу картинку любых цветов, пожалуйста" - для получения картинки цветов;\n "Хочу информацию о предложении дня, пожалуйста" - сводка о конкретных цветах;\n "Общая информация о сведениях, находящихся в базе данных" - сводка об характеристиках товаров, информация о которых находится в БД.',
- reply_markup=markup)
-
-@bot.message_handler(content_types=["text"])
-def handle_text(message):
- if (message.text.strip() == "Хочу информацию о любых цвеах, пожалуйста"):
- i = random.choice(arr)
- a1 = f'Название: {i[1]};\nЦена: {i[2]};\nСкидка(в процентах): {i[3]};\n'
- bot.send_message(message.chat.id, a1)
- elif (message.text.strip() == "Хочу картинку любых цветов, пожалуйста"):
- i = random.choice(arr)
- bot.send_photo(message.chat.id, open(i[4], 'rb'))
- elif (message.text.strip() == "Хочу информацию о предложении дня, пожалуйста"):
- j = random.randint(1, 61)
- i = list(select(j))
- a1 = f'Название: {i[1]};\nЦена: {i[2]};\nСкидка(в процентах): {i[3]};\n'
- bot.send_message(message.chat.id, "Предложение дня:\n")
- bot.send_message(message.chat.id, a1)
- bot.send_photo(message.chat.id, open(i[4], 'rb'))
- else:
- bot.send_message(message.chat.id, "С помощью данного бота вы можете получить информацию о 60-и цветах одного из московских магазинов по их продаже, в частности их: название, цену, скидку(в процентах) и фото. Вы можете это осуществить, взаимодействуя с ботом. Попробуйте! ")
-
-bot.polling(none_stop=True, interval=0)
-
-cursor.close()
-connection.close()
\ No newline at end of file
From a6e53afcea24bdd120f4fbbff58e1d300a2a4781 Mon Sep 17 00:00:00 2001
From: VladEpifanov
Date: Sun, 23 Apr 2023 14:32:50 +0300
Subject: [PATCH 30/33] =?UTF-8?q?=D0=9A=D0=BE=D0=B4=20=D0=B4=D0=BB=D1=8F?=
=?UTF-8?q?=20=D0=B2=D0=B7=D0=B0=D0=B8=D0=BC=D0=BE=D0=B4=D0=B5=D0=B9=D1=81?=
=?UTF-8?q?=D1=82=D0=B2=D0=B8=D1=8F=20=D0=B1=D0=BE=D1=82=D0=B0=20=D1=81=20?=
=?UTF-8?q?=D0=91=D0=94=20+=20=D0=B7=D0=B0=D0=B4=D0=B5=D0=B9=D1=81=D1=82?=
=?UTF-8?q?=D0=B2=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=84=D1=83=D0=BD?=
=?UTF-8?q?=D0=BA=D1=86=D0=B8=D0=B8=20=D0=B8=D0=B7=20wwfuncs.py?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...py => tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename Задания/task1/Epifanov/{tgBot(try-exc-finally+usage of func-s.py => tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py} (100%)
diff --git a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py
similarity index 100%
rename from Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s.py
rename to Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py
From cb6699217d6b8a2bbcd7960ac776580355109cec Mon Sep 17 00:00:00 2001
From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com>
Date: Sun, 23 Apr 2023 14:39:06 +0300
Subject: [PATCH 31/33] Update tgBot(try-exc-finally+usage of func-s in
wwfuncs.py).py
---
.../tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py
index 47b402d..5aa490e 100644
--- a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py
+++ b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py
@@ -26,7 +26,7 @@ bot = telebot.TeleBot('5980905704:AAH2qIP4Gy60nhuKNAojOGpmI6zwNoJK1Iw')
@bot.message_handler(commands=["start"])
def start(m, res=False):
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
- item1 = types.KeyboardButton("Хочу информацию о любых цвеах, пожалуйста")
+ item1 = types.KeyboardButton("Хочу информацию о любых цветах, пожалуйста")
item2 = types.KeyboardButton("Хочу картинку любых цветов, пожалуйста")
item3 = types.KeyboardButton("Хочу информацию о предложении дня, пожалуйста")
item4 = types.KeyboardButton("Общая информация о сведениях, находящихся в базе данных")
@@ -60,4 +60,4 @@ def handle_text(message):
bot.polling(none_stop=True, interval=0)
cursor.close()
-connection.close()
\ No newline at end of file
+connection.close()
From 443831358966776c2ee61d199675a71de577f12e Mon Sep 17 00:00:00 2001
From: VladEpifanov <124862300+VladEpifanov@users.noreply.github.com>
Date: Sun, 23 Apr 2023 14:54:28 +0300
Subject: [PATCH 32/33] Update tgBot(try-exc-finally+usage of func-s in
wwfuncs.py).py
---
.../tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py
index 5aa490e..4b804da 100644
--- a/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py
+++ b/Задания/task1/Epifanov/tgBot(try-exc-finally+usage of func-s in wwfuncs.py).py
@@ -40,7 +40,7 @@ def start(m, res=False):
@bot.message_handler(content_types=["text"])
def handle_text(message):
- if (message.text.strip() == "Хочу информацию о любых цвеах, пожалуйста"):
+ if (message.text.strip() == "Хочу информацию о любых цветах, пожалуйста"):
i = random.choice(arr)
a1 = f'Название: {i[1]};\nЦена: {i[2]};\nСкидка(в процентах): {i[3]};\n'
bot.send_message(message.chat.id, a1)
From 842f08f77337084081675e4d79c065e1dbe126ae Mon Sep 17 00:00:00 2001
From: Harutyun
Date: Wed, 26 Apr 2023 14:09:41 +0300
Subject: [PATCH 33/33] attempt to create telegramBot
---
Задания/task1/Garanyan/{main.py => parser.py} | 0
Задания/task1/Garanyan/problems.py | 30 +++++++++++++++++++
Задания/task1/Garanyan/tgbot.py | 16 +++++-----
3 files changed, 38 insertions(+), 8 deletions(-)
rename Задания/task1/Garanyan/{main.py => parser.py} (100%)
create mode 100644 Задания/task1/Garanyan/problems.py
diff --git a/Задания/task1/Garanyan/main.py b/Задания/task1/Garanyan/parser.py
similarity index 100%
rename from Задания/task1/Garanyan/main.py
rename to Задания/task1/Garanyan/parser.py
diff --git a/Задания/task1/Garanyan/problems.py b/Задания/task1/Garanyan/problems.py
new file mode 100644
index 0000000..018fd04
--- /dev/null
+++ b/Задания/task1/Garanyan/problems.py
@@ -0,0 +1,30 @@
+import psycopg2
+import wget
+
+from Задания.task1.Garanyan import parser
+
+connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres',
+ password='Q1w2e3r4')
+cursor = connection.cursor()
+create_q = '''CREATE TABLE Food
+ (ID serial primary key, Name varchar(500), Price varchar(60), src varchar(100))'''
+
+try:
+ cursor.execute(create_q)
+ connection.commit()
+except psycopg2.errors.DuplicateTable:
+ print("s")
+
+for j in range(15):
+ url = parser.Image[j].find('img').attrs['src']
+ tempf = f"C:\\Users\\Harutyun\\Desktop\\prog\\food{j}.jpg"
+ wget.download(url, tempf)
+ try:
+ insert_query = f'''INSERT into public.Food(Name, Price, src) values ('{parser.Name[j].text}', '{parser.Price[j].text}', '{tempf}') '''
+ cursor.execute(insert_query)
+ connection.commit()
+ except:
+ connection.rollback()
+
+cursor.close()
+connection.close()
\ No newline at end of file
diff --git a/Задания/task1/Garanyan/tgbot.py b/Задания/task1/Garanyan/tgbot.py
index 2b47151..4bc1be5 100644
--- a/Задания/task1/Garanyan/tgbot.py
+++ b/Задания/task1/Garanyan/tgbot.py
@@ -2,7 +2,7 @@ import telebot
import psycopg2
from telebot import types
import random
-#hello
+
connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres',
password='Q1w2e3r4')
cursor = connection.cursor()
@@ -11,8 +11,7 @@ try:
cursor.execute(sel_query)
except psycopg2.errors.UndefinedTable:
connection.rollback()
- import tableCreator
-
+ import problems
sel_query = """SELECT * FROM public.food"""
cursor.execute(sel_query)
@@ -25,14 +24,14 @@ bot = telebot.TeleBot('841097550:AAFc5MoFRivTEfv-gOSJctqH53NfYMTKpCc')
def start(m, res=False):
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton("Хот-доги и соусы!")
- item2 = types.KeyboardButton("Повтори!")
+ item2 = types.KeyboardButton("Случайная фотография нашего товара!")
markup.add(item1)
markup.add(item2)
bot.send_message(m.chat.id,
- '"Хот-доги и соусы!" - для получения случайного товара из нашей хотдожной\n "Повтори!" - для повторения сообщений.',
+ '"Хот-доги и соусы!" - для получения случайного товара из нашей хотдожной\n'
+ ' "Случайная фотография нашего товара!" - для вывода фотографий',
reply_markup=markup)
-
@bot.message_handler(content_types=["text"])
def handle_text(message):
if (message.text.strip() == 'Хот-доги и соусы!'):
@@ -40,8 +39,9 @@ def handle_text(message):
ans = f'Название: {i[1]}\nЦена: {i[2]}\n'
bot.send_message(message.chat.id, ans)
bot.send_photo(message.chat.id, open(i[3], 'rb'))
- elif (message.text.strip() == 'Повтори!'):
- bot.send_message(message.chat.id, 'Ввод: ' + message.text)
+ elif (message.text.strip() == 'Случайная фотография нашего товара!'):
+ i = random.choice(array)
+ bot.send_photo(message.chat.id, open(i[3], 'rb'))
bot.polling(none_stop=True, interval=0)
\ No newline at end of file