Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User refactor #50

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
8 changes: 5 additions & 3 deletions core.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import importlib
import sys
import threading

import telegram
import worker

import configloader
import utils
import threading
import importlib
import worker

language = configloader.config["Config"]["language"]
strings = importlib.import_module("strings." + language)
Expand Down
21 changes: 12 additions & 9 deletions database.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import datetime
import importlib
import typing
from sqlalchemy import create_engine, Column, ForeignKey, UniqueConstraint
from sqlalchemy import Integer, BigInteger, String, Text, LargeBinary, DateTime, Boolean
from sqlalchemy.orm import sessionmaker, relationship, backref

import requests
import telegram
from sqlalchemy import (BigInteger, Boolean, Column, DateTime, ForeignKey,
Integer, LargeBinary, String, Text, UniqueConstraint,
create_engine)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import backref, relationship, sessionmaker

import configloader
import telegram
import requests
import utils
import importlib

language = configloader.config["Config"]["language"]
strings = importlib.import_module("strings." + language)
Expand All @@ -31,9 +35,10 @@ class User(TableDeclarativeBase):
first_name = Column(String, nullable=False)
last_name = Column(String)
username = Column(String)
last_seen = Column(DateTime, default=datetime.datetime.utcnow)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing existing tables... is troublesome, as all current users of the bot would need to migrate somehow their database to the new schema.

Either we provide a migration script, or we put the new info in a new, different table instead... 🤔

I could probably help with that, but it may take a while...


# Current wallet credit
credit = Column(Integer, nullable=False)
credit = Column(Integer, nullable=False, default=0)
pzhuk marked this conversation as resolved.
Show resolved Hide resolved

# Extra table parameters
__tablename__ = "users"
Expand All @@ -46,8 +51,6 @@ def __init__(self, telegram_chat: telegram.Chat, **kwargs):
self.first_name = telegram_chat.first_name
self.last_name = telegram_chat.last_name
self.username = telegram_chat.username
# The starting wallet value is 0
self.credit = 0

def __str__(self):
"""Describe the user in the best way possible given the available data."""
Expand Down
12 changes: 10 additions & 2 deletions strings/en_US.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,13 @@
conversation_open_help_menu = "What kind of help do you need?"

# Conversation: confirm promotion to admin
conversation_confirm_admin_promotion = "Are you sure you want to promote this user to 💼 Manager?\n" \
"It is an irreversible action!"
conversation_confirm_admin_promotion = "Are you sure you want to promote this user to 💼 Manager?\n"

# Conversation: remove administrator
conversation_admin_dismissal_menu = "❌ Remove administrator"
pzhuk marked this conversation as resolved.
Show resolved Hide resolved

# Conversation: administrator removal confirmation
conversation_confirm_admin_dismissal = "Admin has been removed"
pzhuk marked this conversation as resolved.
Show resolved Hide resolved

# Conversation: switching to user mode
conversation_switch_to_user_mode = " You are switching to 👤 Customer mode.\n" \
Expand Down Expand Up @@ -296,6 +301,9 @@
"It might take a while... Please be patient!\n" \
"I won't be able to answer you while I'm downloading."

downloading_image_failed = "Something went wrong with the image upload handling" \
"Please, try again"

# Edit product: current value
edit_current_value = "The current value is:\n" \
"<pre>{value}</pre>\n" \
Expand Down
12 changes: 10 additions & 2 deletions strings/it_IT.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,13 @@
conversation_open_help_menu = "Che tipo di assistenza desideri ricevere?"

# Conversation: confirm promotion to admin
conversation_confirm_admin_promotion = "Sei sicuro di voler promuovere questo utente a 💼 Gestore?\n" \
"E' un'azione irreversibile!"
conversation_confirm_admin_promotion = "Sei sicuro di voler promuovere questo utente a 💼 Gestore?\n"

# Conversation: remove administrator
conversation_admin_dismissal_menu = "❌ Elimina amministratore"

# Conversation: administrator removal confirmation
conversation_confirm_admin_dismissal = "Admin eliminato"

# Conversation: switching to user mode
conversation_switch_to_user_mode = "Stai passando alla modalità 👤 Cliente.\n" \
Expand Down Expand Up @@ -297,6 +302,9 @@
"Potrei metterci un po'... Abbi pazienza!\n" \
"Non sarò in grado di risponderti durante il download."

downloading_image_failed = "Si è verificato un errore durante il caricamento dell'immagine" \
"Per favore riprova"

# Edit product: current value
edit_current_value = "Il valore attuale è:\n" \
"<pre>{value}</pre>\n" \
Expand Down
12 changes: 10 additions & 2 deletions strings/ru_RU.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,13 @@
conversation_open_help_menu = "Чем могу Вам помочь?"

# Conversation: confirm promotion to admin
conversation_confirm_admin_promotion = "Вы уверены, что хотите повысить этого пользователя до 💼 Менеджера?\n" \
"Это действие невозможно отменить!"
conversation_confirm_admin_promotion = "Вы уверены, что хотите повысить этого пользователя до 💼 Менеджера?\n"

# Conversation: remove administrator
conversation_admin_dismissal_menu = "❌ Удалить администратора"

# Conversation: administrator removal confirmation
conversation_confirm_admin_dismissal = "Администратор удален"

# Conversation: switching to user mode
conversation_switch_to_user_mode = " Вы перешли в режим 👤 Покупателя.\n" \
Expand Down Expand Up @@ -294,6 +299,9 @@
"Это может занять некоторое время...!\n" \
"Я не смогу отвечать, пока идет загрузка."

downloading_image_failed = "Ошибка при загрузке изображения" \
"Попробуйте еще раз..."

# Edit product: current value
edit_current_value = "Текущее значение:\n" \
"<pre>{value}</pre>\n" \
Expand Down
12 changes: 10 additions & 2 deletions strings/uk_UA.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,13 @@
conversation_open_help_menu = "Як можемо Вам допомогти?"

# Conversation: confirm promotion to admin
conversation_confirm_admin_promotion = "Ви впевнені, що хочете підвищити цього користувача до 💼 Менеджера?\n" \
"Цю дію неможливо відмінити!"
conversation_confirm_admin_promotion = "Ви впевнені, що хочете підвищити цього користувача до 💼 Менеджера?\n"

# Conversation: remove administrator
conversation_admin_dismissal_menu = "❌ Видалити адміністратора"

# Conversation: administrator removal confirmation
conversation_confirm_admin_dismissal = "Администратора видалено"

# Conversation: switching to user mode
conversation_switch_to_user_mode = " Ви перейшли в режим 👤 Замовника.\n" \
Expand Down Expand Up @@ -294,6 +299,9 @@
"Може зайняти деякий час... Майте терпіння!\n" \
"Я не зможу відповідати, поки йде завантаження."

downloading_image_failed = "Помилка при завантаженні зображення" \
"Спробуйте ще раз..."

# Edit product: current value
edit_current_value = "Поточне значення:\n" \
"<pre>{value}</pre>\n" \
Expand Down
12 changes: 7 additions & 5 deletions utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import importlib
import os
import sys
import time
import typing

import telegram
import telegram.error
import time

from configloader import config
import typing
import os
import sys
import importlib

language = config["Config"]["language"]
try:
Expand Down
Loading