Skip to content

Commit

Permalink
Rename marketing
Browse files Browse the repository at this point in the history
  • Loading branch information
annndruha committed Jul 17, 2023
1 parent c5e9a1f commit db96fa5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Print-bot
# print-vkbot

## ВКонтакте бот для отправки файлов на печать на принтер
Бот ВКонтакте отправки заданий на печать бесплатного принтера профкома студентов физического факультета МГУ

Продовый бот: http://vk.me/profcomff_print_bot

Тестовый бот: https://vk.com/profcomff_print_test_bot
* [Продовый vk-бот](https://vk.me/profcomff_print_bot)
* [Тестовый vk-бот](https://vk.me/profcomff_print_test_bot)

## Ключевые особенности

* Возможность отправлять файлы pdf на сервер печати
* Возможность проверки пользователя
* Валидация принимаемых типов сообщений
* Красивые клавиатуры
Другое:
* [Печать через сайт](https://www.profcomff.com/work/obshkom/print)
* [Telegram-Бот](https://t.me/profcomff_print_bot)
16 changes: 8 additions & 8 deletions src/__main__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import logging
import time
from threading import Thread

import src.chat as chat

logging.getLogger("httpx").setLevel(logging.WARNING)

logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
level=logging.INFO,
datefmt="%Y-%m-%d %H:%M:%S",
)

if __name__ == '__main__':
logging.basicConfig(
format='%(asctime)s %(levelname)-8s %(message)s', level=logging.INFO, datefmt='%Y-%m-%d %H:%M:%S'
)

if __name__ == '__main__':
chat_thread = Thread(target=chat.chat_loop)
chat_thread.start()

time.sleep(1)
logging.info("=== BOT START ===")

chat_thread.join()
22 changes: 11 additions & 11 deletions src/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import src.answers as ru
import src.keybords as kb
import src.marketing as log
import src.marketing as marketing
import src.vkontakte_functions as vk
from src.db import VkUser, reconnect_session, session
from src.settings import Settings
Expand All @@ -25,14 +25,14 @@
def get_attachments(user):
if len(user.attachments) > 1:
vk.write_msg(user, ru.print_ans['many_files'])
log.print_exc_many(
marketing.print_exc_many(
file_count=len(user.attachments),
vk_id=user.user_id,
)
return
if user.attachments[0]['type'] != 'doc':
vk.write_msg(user, ru.print_ans['only_pdfs'])
log.print_exc_format(
marketing.print_exc_format(
file_ext='image',
vk_id=user.user_id,
)
Expand All @@ -41,7 +41,7 @@ def get_attachments(user):
ext = user.attachments[0]['doc']['ext']
if ext != 'pdf':
vk.write_msg(user, ru.print_ans['only_pdfs'])
log.print_exc_format(
marketing.print_exc_format(
file_ext=len(user.attachments[0]['doc']['ext']),
vk_id=user.user_id,
)
Expand Down Expand Up @@ -76,15 +76,15 @@ def order_print(user, requisites):
kb_qr = vk.VkKeyboard(inline=True)
kb_qr.add_openlink_button(ru.print_ans['qr_button_text'], link=settings.PRINT_URL_QR + str(pin))
vk.send_keyboard(user, kb_qr.get_keyboard(), ru.print_ans['send_to_print'].format(pin))
log.print_success(
marketing.print_success(
vk_id=vk_id,
surname=surname,
number=number,
pin=pin,
)
elif rfile.status_code == 413:
vk.write_msg(user, ru.errors['file_size_err'])
log.print_exc_other(
marketing.print_exc_other(
vk_id=vk_id,
surname=surname,
number=number,
Expand All @@ -94,7 +94,7 @@ def order_print(user, requisites):
)
else:
vk.write_msg(user, ru.errors['print_err'])
log.print_exc_other(
marketing.print_exc_other(
vk_id=vk_id,
surname=surname,
number=number,
Expand All @@ -104,7 +104,7 @@ def order_print(user, requisites):
)
else:
vk.write_msg(user, ru.errors['print_err'])
log.print_exc_other(
marketing.print_exc_other(
vk_id=vk_id,
surname=surname,
number=number,
Expand All @@ -125,7 +125,7 @@ def register_bot_user(user):
session.add(VkUser(vk_id=user.user_id, surname=surname, number=number))
session.commit()
kb.auth_button(user, ru.val_ans['val_pass'])
log.register(
marketing.register(
vk_id=user.user_id,
surname=surname,
number=number,
Expand All @@ -135,7 +135,7 @@ def register_bot_user(user):
data.surname = surname
data.number = number
kb.auth_button(user, ru.val_ans['val_update_pass'])
log.re_register(
marketing.re_register(
vk_id=user.user_id,
surname=surname,
number=number,
Expand All @@ -144,7 +144,7 @@ def register_bot_user(user):
elif r.json() is False:
vk.write_msg(user, ru.val_ans['val_fail'])
vk.write_msg(user, ru.val_ans['exp_name'])
log.register_exc_wrong(
marketing.register_exc_wrong(
vk_id=user.user_id,
surname=surname,
number=number,
Expand Down

0 comments on commit db96fa5

Please sign in to comment.