This commit is contained in:
wt committed 2022-10-21 16:18:49 +07:00
1 parent f9bda14dc9
commit 0bd622750f
5 files changed
+40 -18

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
import telebot
TOKEN = '5123679189:AAHTMxCyOUwPSbaeof31m8SjRHVs4qKZci8'
TOKEN = '5123679189:AAHPLBfbPfuCiNK9qCcykcB2pRG-J4OEyrw'
bot = telebot.TeleBot(TOKEN)
+4
View File
@@ -0,0 +1,4 @@
currensyes = {
'ru-ruble': '₽',
'us-dollar': '$'
}
+8 -1
View File
@@ -28,11 +28,18 @@ class Transaction(BaseModel):
user = ForeignKeyField(User, unique=False)
date = DateField(column_name='Date', default=datetime.datetime.today())
time = TimeField(column_name='time', default=datetime.datetime.now())
category = TextField(column_name='category', default='none category')
category = TextField(column_name='category', default='None category')
class Meta:
table_name = 'Transaction'
class Check(BaseModel):
id = AutoField(column_name='id')
name = CharField(column_name='name', max_length=50, null=False, default='check')
balance = FloatField(column_name='balance', null=False, default=0)
user = ForeignKeyField(User, unique=False)
# создаю таблицы
conn.create_tables([User, Transaction])
+16 -16
View File
@@ -1,10 +1,10 @@
import datetime
from termcolor import cprint
from bot import bot
import locales
from changelocale import change_locale
from database.models import User, Transaction
from currencyes import currensyes
# функция ограничения количества знаков после запятой
@@ -32,7 +32,7 @@ def main_bot(messages):
mes = 'Баланс: '
elif locales.LOCALE == 'en':
mes = 'Balance: '
mes += to_fixed(user.balance, 2) + '₽'
mes += to_fixed(user.balance, 2) + currensyes['ru-ruble']
bot.send_message(message.chat.id, mes)
elif message.text.split(' ')[0] == '/add' or message.text.split(' ')[0] == '+':
if len(message.text.split(' ')) < 2:
@@ -59,7 +59,7 @@ def main_bot(messages):
type='incom',
user=User.get(username=message.chat.id)
)
bot.send_message(message.chat.id, to_fixed(user.balance, 2) + '₽')
bot.send_message(message.chat.id, to_fixed(user.balance, 2) + currensyes['ru-ruble'])
elif message.text.split(' ')[0] == '/rm' or message.text.split(' ')[0] == '-':
if len(message.text.split(' ')) < 2:
mes = None
@@ -85,7 +85,7 @@ def main_bot(messages):
type='consuption',
user=User.get(username=message.chat.id)
)
bot.send_message(message.chat.id, to_fixed(user.balance, 2) + '₽')
bot.send_message(message.chat.id, to_fixed(user.balance, 2) + currensyes['ru-ruble'])
elif message.text.split(' ')[0] == '/addtoday':
transactions = Transaction.select().where(
Transaction.type == 'incom',
@@ -105,8 +105,8 @@ def main_bot(messages):
mes += 'No incomes today'
for i in transactions:
mes += '-------------------------------------\n'
mes += str(iteration) + ' || +' + str(i.sum) + '₽ || ' + i.category + ' || ' + str(i.date) \
+ ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n'
mes += str(iteration) + ' || +' + str(i.sum) + currensyes['ru-ruble'] + ' || ' + i.category \
+ ' || ' + str(i.date) + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n'
iteration += 1
mes += '-------------------------------------\n'
bot.send_message(message.chat.id, mes)
@@ -129,8 +129,8 @@ def main_bot(messages):
mes += 'No consuptions today'
for i in transactions:
mes += '-------------------------------------\n'
mes += str(iteration) + ' || -' + str(i.sum) + '₽ || ' + i.category + ' || ' + str(i.date) \
+ ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n'
mes += str(iteration) + ' || -' + str(i.sum) + currensyes['ru-ruble'] + ' || ' + i.category \
+ ' || ' + str(i.date) + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n'
iteration += 1
mes += '-------------------------------------\n'
bot.send_message(message.chat.id, mes)
@@ -152,8 +152,8 @@ def main_bot(messages):
mes += 'No consuptions for all time'
for i in transactions:
mes += '-------------------------------------\n'
mes += str(iteration) + ' || -' + str(i.sum) + '+ || ' + i.category + ' || ' + str(i.date) \
+ ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n'
mes += str(iteration) + ' || -' + str(i.sum) + currensyes['ru-ruble'] + ' || ' + i.category \
+ ' || ' + str(i.date) + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n'
iteration += 1
mes += '-------------------------------------\n'
bot.send_message(message.chat.id, mes)
@@ -175,8 +175,8 @@ def main_bot(messages):
mes += 'No incomes for all time'
for i in transactions:
mes += '-------------------------------------\n'
mes += str(iteration) + ' || +' + str(i.sum) + '₽ || ' + i.category + ' || ' + str(i.date) \
+ ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n'
mes += str(iteration) + ' || +' + str(i.sum) + currensyes['ru-ruble'] + ' || ' + i.category \
+ ' || ' + str(i.date) + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n'
iteration += 1
mes += '-------------------------------------\n'
bot.send_message(message.chat.id, mes)
@@ -200,8 +200,8 @@ def main_bot(messages):
for i in transactions:
if str(i.date).split('-')[1] == datetime.datetime.today().strftime('%m'):
mes += '-------------------------------------\n'
mes += str(iteration) + ' || -' + str(i.sum) + '₽ || ' + i.category + ' || ' + str(i.date) \
+ ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n'
mes += str(iteration) + ' || -' + str(i.sum) + currensyes['ru-ruble'] + ' || ' + i.category \
+ ' || ' + str(i.date) + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n'
iteration += 1
mes += '-------------------------------------\n'
bot.send_message(message.chat.id, mes)
@@ -225,8 +225,8 @@ def main_bot(messages):
for i in transactions:
if str(i.date).split('-')[1] == datetime.datetime.today().strftime('%m'):
mes += '-------------------------------------\n'
mes += str(iteration) + ' || +' + str(i.sum) + '₽ || ' + i.category + ' || ' + str(i.date) \
+ ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n'
mes += str(iteration) + ' || +' + str(i.sum) + currensyes['ru-ruble'] + ' || ' + i.category \
+ ' || ' + str(i.date) + ' || ' + i.time.strftime('%H:%M:%S') + ' ||\n'
iteration += 1
mes += '-------------------------------------\n'
bot.send_message(message.chat.id, mes)
+11
View File
@@ -1,8 +1,19 @@
certifi==2022.9.24
charset-normalizer==2.1.1
contourpy==1.0.5
cycler==0.11.0
fonttools==4.37.4
idna==3.4
kiwisolver==1.4.4
matplotlib==3.6.1
numpy==1.23.4
packaging==21.3
peewee==3.15.3
Pillow==9.2.0
pyparsing==3.0.9
pyTelegramBotAPI==4.7.0
python-dateutil==2.8.2
requests==2.28.1
six==1.16.0
termcolor==2.0.1
urllib3==1.26.12