Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, server_default=0)

# 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 Manager"

# Conversation: administrator removal confirmation
conversation_confirm_admin_dismissal = "🗑 User was successfully removed from the Managers!"

# 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
13 changes: 11 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 Gestore"

# Conversation: administrator removal confirmation
conversation_confirm_admin_dismissal = "🗑 Gestore eliminato con successo!"

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

# There was an error reading the image the user sent
downloading_image_failed = "Si è verificato un errore durante il download dell'immagine...\n" \
"Riprova, per favore!"

# Edit product: current value
edit_current_value = "Il valore attuale è:\n" \
"<pre>{value}</pre>\n" \
Expand Down
14 changes: 11 additions & 3 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 @@ -265,7 +270,7 @@
# Edit credit: notes?
ask_transaction_notes = " Добавьте сообщение к транзакции.\n" \
" Сообщение будет доступно 👤 Покупателю после пополнения/списания средств" \
" и 💼 Администратору в логах транзакций."
" и 💼 Менеджеру в логах транзакций."

# Edit credit: amount?
ask_credit = "Вы хотите изменить баланс Покупателя?\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
14 changes: 11 additions & 3 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 @@ -265,7 +270,7 @@
# Edit credit: notes?
ask_transaction_notes = " Додайте повідомлення до транзакції.\n" \
"👤 Повідомлення буде доступне замовнику після поповнення/списання" \
" і 💼 Адміністратору в логах транзакцій."
" і 💼 Менеджеру в логах транзакцій."

# Edit credit: amount?
ask_credit = "Як ви хочете змінити баланс замовника?\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