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