Rebase
This commit is contained in:
parent
8c34492247
commit
df334cb70b
117
1.p
117
1.p
@ -1,117 +0,0 @@
|
||||
diff --git a/engineering_works.py b/engineering_works.py
|
||||
index a122c3c..ebd6cea 100644
|
||||
--- a/engineering_works.py
|
||||
+++ b/engineering_works.py
|
||||
@@ -13,11 +13,11 @@ logging.basicConfig(
|
||||
|
||||
|
||||
|
||||
-WEBAPP_HOST = config.bot("ip")
|
||||
-WEBAPP_PORT = config.bot("port")
|
||||
+WEBAPP_HOST = config.ip
|
||||
+WEBAPP_PORT = config.port
|
||||
|
||||
WEBHOOK_HOST = f'http://{WEBAPP_HOST}:{WEBAPP_PORT}'
|
||||
-WEBHOOK_PATH = f'/bot{config.bot("token")}/'
|
||||
+WEBHOOK_PATH = f'/bot{config.token}/'
|
||||
WEBHOOK_URL = f"{WEBHOOK_HOST}{WEBHOOK_PATH}"
|
||||
|
||||
engeneerings_works = (
|
||||
@@ -29,7 +29,7 @@ parse_error = (
|
||||
"Бот приостановлен на неопределенный срок!\n"
|
||||
"Что случилось?\n"
|
||||
"Администрация коледжа изменила формат файла с google docs на docx(Microsoft Office)\n"
|
||||
- "Замены вы можете посмотреть тут: https://docs.google.com/document/d/{}".format(config.documentid)
|
||||
+ "Замены вы можете посмотреть тут: https://docs.google.com/document/d/{}".format("")
|
||||
)
|
||||
|
||||
new_year = (
|
||||
@@ -48,7 +48,11 @@ september_1 = ("Всіх з 1 вересням, всього найкращог
|
||||
"Бот буде запущений чуть пізніше, "
|
||||
"коли заміни будуть публіковаться текстом")
|
||||
|
||||
-send_msg = the_end
|
||||
+upd_1 = ("Невеликі зміни в боті.\n"
|
||||
+ "1. Добавлени донати, тепер ви можете підтримати автора бота\n"
|
||||
+ "2. Добалено звязок з адміністратором")
|
||||
+
|
||||
+send_msg = upd_1
|
||||
|
||||
async def on_startup(dp):
|
||||
await bot.set_webhook(url=WEBHOOK_URL)
|
||||
@@ -81,7 +85,7 @@ async def start(message: types.Message):
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
- if config.bot("use_webhook").lower() in ['t', 'true', '1', 'yes', 'y']:
|
||||
+ if config.use_webhook.lower() in ['t', 'true', '1', 'yes', 'y']:
|
||||
executor.start_webhook(
|
||||
dispatcher=dp,
|
||||
webhook_path=WEBHOOK_PATH,
|
||||
diff --git a/filters/main.py b/filters/main.py
|
||||
index 849e6de..7539de0 100644
|
||||
--- a/filters/main.py
|
||||
+++ b/filters/main.py
|
||||
@@ -28,7 +28,7 @@ class BotAdmin(BoundFilter):
|
||||
self.admin = admin
|
||||
|
||||
async def check(self, message: types.Message):
|
||||
- if message.from_user.id in config.admin_user:
|
||||
+ if message.from_user.id in [int(i) for i in config.admin_users.split(",")]:
|
||||
return True
|
||||
else:
|
||||
await message.answer("Хорошая попытка, но ты не администратор!")
|
||||
diff --git a/handlers/private/main.py b/handlers/private/main.py
|
||||
index de03596..370218a 100644
|
||||
--- a/handlers/private/main.py
|
||||
+++ b/handlers/private/main.py
|
||||
@@ -45,7 +45,7 @@ async def get_replace(message: types.Message, state: FSMContext):
|
||||
|
||||
link = (
|
||||
'<a href="{}">Проверьте замены тут</a>'
|
||||
- .format(config.bot("link"))
|
||||
+ .format(config.link)
|
||||
)
|
||||
logging.info("User: {user_id} - {username}".format(
|
||||
user_id=str(message.from_user.id),
|
||||
@@ -94,7 +94,7 @@ async def get_replace(message: types.Message, state: FSMContext):
|
||||
async def get_link(message: types.Message):
|
||||
msg = (
|
||||
'<a href="{}">Проверьте замены тут</a>'
|
||||
- .format(config.bot("link"))
|
||||
+ .format(config.link)
|
||||
)
|
||||
await bot.send_message(
|
||||
message.chat.id,
|
||||
diff --git a/utils/announcements.py b/utils/announcements.py
|
||||
index f70541e..4e264de 100644
|
||||
--- a/utils/announcements.py
|
||||
+++ b/utils/announcements.py
|
||||
@@ -1,3 +1,4 @@
|
||||
+
|
||||
import datetime
|
||||
import asyncio
|
||||
import aioschedule as schedule
|
||||
@@ -15,8 +16,8 @@ async def announce():
|
||||
except Exception:
|
||||
message = "Ошибка обновления данных!"
|
||||
if config.admin_users.split(',') is not None:
|
||||
- for user_id in config.admin_users.split(','):
|
||||
- if user_id in config.exclude:
|
||||
+ for user_id in [int(i) for i in config.admin_users.split(',')]:
|
||||
+ if user_id in [int(i) for i in config.exclude.split(",")]:
|
||||
continue
|
||||
await dp.bot.send_message(user_id, message)
|
||||
|
||||
diff --git a/utils/bot_commands.py b/utils/bot_commands.py
|
||||
index b65bc62..3de6ed1 100644
|
||||
--- a/utils/bot_commands.py
|
||||
+++ b/utils/bot_commands.py
|
||||
@@ -7,6 +7,6 @@ async def set_commands(dp):
|
||||
types.BotCommand("help", "информация"),
|
||||
types.BotCommand("link", "получить ссылку на файл"),
|
||||
types.BotCommand('timetable', "Розклад"),
|
||||
- types.BotCommand('feedback', "Звязок з адміністратором")
|
||||
+ types.BotCommand('feedback', "Звязок з адміністратором"),
|
||||
types.BotCommand("reload", "только для администрации"),
|
||||
])
|
@ -68,7 +68,6 @@ def get_about_replacements() -> dict:
|
||||
count = document['body']["content"][element]["table"]["rows"]
|
||||
except (IndexError, KeyError):
|
||||
image, image_bytes = helper.find_image(document)
|
||||
print(image)
|
||||
if not image:
|
||||
element = helper.find_with_table(document)
|
||||
if element:
|
||||
|
@ -32,14 +32,6 @@ self.months = {
|
||||
}
|
||||
'''
|
||||
|
||||
headers = {
|
||||
'user-agent':(
|
||||
"Mozilla/5.0 (Windows NT 10.0; WOW64) "
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) "
|
||||
"Chrome/62.0.3202.9 Safari/537.36"
|
||||
)
|
||||
}
|
||||
|
||||
class Helper():
|
||||
|
||||
def __init__(self):
|
||||
@ -199,13 +191,23 @@ class Helper():
|
||||
element += 1
|
||||
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_link_and_download(cls, id_doc, document):
|
||||
if "inlineObjects" in document:
|
||||
if id_doc in document['inlineObjects']:
|
||||
link = (document
|
||||
['inlineObjects'][id_doc]['inlineObjectProperties']
|
||||
['embeddedObject']['imageProperties']['contentUri'])
|
||||
r = requests.get(link, stream=True)
|
||||
return base64.b64encode(r.content).decode('utf-8')
|
||||
|
||||
@classmethod
|
||||
def find_image(cls, document):
|
||||
for i in document['body']["content"]:
|
||||
if ("paragraph" in i) and ("elements" in i["paragraph"]):
|
||||
if "inlineObjectElement" in i["paragraph"]["elements"][0]:
|
||||
import base64
|
||||
return True, base64.b64encode(open("photo.png", 'rb').read()).decode('utf-8')
|
||||
if "inlineObjectElement" in i["paragraph"]["elements"]:
|
||||
return True, cls.get_link_and_download(
|
||||
i["paragraph"]["elements"]
|
||||
['inlineObjectElement']['inlineObjectId'], document)
|
||||
return False, None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user