diff --git a/Openai.py b/Openai.py index e03e9d2..eb2212f 100644 --- a/Openai.py +++ b/Openai.py @@ -4,6 +4,7 @@ class OpenAi: def __init__(self, openai_api_key): self.openai = openai + self.openai.log = "info" self.openai.api_key = openai_api_key async def question(self, text: str) -> str: diff --git a/Reminders.py b/Reminders.py index 6b38b59..89f0140 100644 --- a/Reminders.py +++ b/Reminders.py @@ -3,8 +3,6 @@ import datetime from multiprocessing import Process -import schedule - import functions import texts from Enum_classes import Reminder @@ -36,7 +34,7 @@ async def work(): time_transition_payment = datetime.datetime.utcfromtimestamp(user.time_transition_payment) if (now_time - time_transition_payment) > time_reminder_1 and user.count_reminder == 0: data = functions.create_pay(user_id=str(user_id), - price="2990.00") + price=2990) key = data[1] link = data[0] user.key_payment = key @@ -57,7 +55,7 @@ async def work(): and time_reminder.tm_min == now_time_tuple.tm_min: if user.reminder == Reminder.first_reminder: data = functions.create_pay(user_id=str(user_id), - price="2990.00") + price=2990) key = data[1] link = data[0] user.key_payment = key @@ -76,17 +74,17 @@ async def work(): elif user.reminder == Reminder.second_reminder: data = functions.create_pay(user_id=str(user_id), - price="9990.00") + price=9990) key = data[1] link = data[0] user.key_payment = key await bot.send_message(chat_id=user_id, text=texts.text_for_reminder_4.format(username=user.username), reply_markup=functions.inl_create_keyboard(buttons= - [["Написать нам", - link_to_bot], - ["Оплатить 9990 руб.", - link]])) + [["Написать нам",link_to_bot], + ["Оплатить 9990 руб.", link]] + ) + ) time_rem = datetime.datetime(year=now_time_tuple.tm_year, month=now_time_tuple.tm_mon, day=now_time_tuple.tm_mday, hour=15, minute=15, second=0) time_rem += datetime.timedelta(days=2) @@ -96,7 +94,7 @@ async def work(): elif user.reminder == Reminder.third_reminder: data = functions.create_pay(user_id=str(user_id), - price="990.00") + price=990) key = data[1] link = data[0] user.key_payment = key @@ -114,7 +112,7 @@ async def work(): elif user.reminder == Reminder.fourth_reminder: data = functions.create_pay(user_id=str(user_id), - price="990.00") + price=990) key = data[1] link = data[0] user.key_payment = key diff --git a/db.db b/db.db index 9635137..38548b3 100644 Binary files a/db.db and b/db.db differ diff --git a/db.db-shm b/db.db-shm deleted file mode 100644 index ac8d968..0000000 Binary files a/db.db-shm and /dev/null differ diff --git a/db.db-wal b/db.db-wal deleted file mode 100644 index 97cd3fa..0000000 Binary files a/db.db-wal and /dev/null differ diff --git a/functions.py b/functions.py index 868977f..75f82ac 100644 --- a/functions.py +++ b/functions.py @@ -5,7 +5,7 @@ Configuration.secret_key = 'live_JB-sjh_-FPp_2Rl5QeX5Rlm6lwqarahXnk4YAbZCOnQ' -def create_pay(user_id: str, price: str) -> tuple: +def create_pay(user_id: str, price: int) -> tuple: payment = Payment.create({ "amount": { "value": price, @@ -17,9 +17,13 @@ def create_pay(user_id: str, price: str) -> tuple: }, "capture": True, - "description": user_id + "description": user_id, + "receipt": {"customer": {"email": "evsevm@gmail.com"}} }) - + # print(payment.amount.__dict__) + # print(payment.recipient.__dict__) + # print(payment.confirmation.__dict__) + # print(payment.confirmation.confirmation_url, payment.id) return payment.confirmation.confirmation_url, payment.id @@ -34,7 +38,7 @@ def create_keyboard(name_buttons: list, ) -> types.ReplyKeyboardMarkup: return keyboard -def inl_create_keyboard(buttons: list[list], ): +def inl_create_keyboard(buttons: list, ): keyboard = types.InlineKeyboardMarkup(row_width=len(buttons), resize_keyboard=True) array = [] for button in buttons: @@ -55,4 +59,4 @@ def inl_create_keyboard(buttons: list[list], ): if __name__ == "__main__": - create_pay("55", "29990.00") + print(create_pay("55", 2)) diff --git a/main.py b/main.py index fe6383d..562a3f1 100644 --- a/main.py +++ b/main.py @@ -113,32 +113,32 @@ async def main_hand(message: types.Message): elif text == "Хочу начать": data = functions.create_pay(user_id=str(user_id), - price="2990.00") + price=2990) key = data[1] link = data[0] user.key_payment = key await bot.send_message(chat_id=user_id, text=texts.text_for_payment, reply_markup=functions.inl_create_keyboard( - buttons=[["Оплатить 2990 руб.", link + buttons=[["Оплатить 2990 руб.", f"{link}" ]] ), parse_mode="Markdown", disable_web_page_preview=True, ) - now_time = message.date + now_time = message.date.utcnow() now_time_tuple = now_time.timetuple() user.flag = Flags.Payment user.time_transition_payment = time.mktime(now_time_tuple) user.reminder = Reminder.first_reminder - if now_time_tuple.tm_hour >= 20 and now_time_tuple.tm_min >= 15: + if now_time_tuple.tm_hour >= 16 and now_time_tuple.tm_min >= 15: time_rem = datetime.datetime(year=now_time_tuple.tm_year, month=now_time_tuple.tm_mon, - day=now_time_tuple.tm_mday, hour=19, minute=48, second=0) + day=now_time_tuple.tm_mday, hour=16, minute=15, second=0) time_rem += datetime.timedelta(days=1) user.time_reminder = time.mktime(time_rem.timetuple()) else: time_rem = datetime.datetime(year=now_time_tuple.tm_year, month=now_time_tuple.tm_mon, - day=now_time_tuple.tm_mday, hour=19, minute=54, second=0) + day=now_time_tuple.tm_mday, hour=16, minute=15, second=0) user.time_reminder = time.mktime(time_rem.timetuple()) diff --git a/texts.py b/texts.py index 9438286..070ca9a 100644 --- a/texts.py +++ b/texts.py @@ -37,7 +37,7 @@ text_after_pay = "Спасибо за оплату! \n\nНу что, начнем?" -text_for_reminder = "Вы можете подробнее прочитать про наш курс на нашем сайте. Если у вас останутся вопросы, " \ +text_for_reminder = "Вы можете подробнее прочитать про наш курс на [нашем сайте](https://www.skillbots.ru/design?utm_source=error_code_tg&utm_medium=tgbot). Если у вас останутся вопросы, " \ "то напишите на [@skillbots_support]" \ "(https://t.me/skillbots_support)\n\nТакже напоминаю, " \ "что сегодня у вас есть возможность получить курс всего за 2990 руб."