initial commit
This commit is contained in:
commit
76709cbdc7
7 files changed
+88
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
*venv
|
||||||
|
*__pycache__
|
||||||
|
*.idea
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import telebot
|
||||||
|
|
||||||
|
TOKEN = '5123679189:AAHTMxCyOUwPSbaeof31m8SjRHVs4qKZci8'
|
||||||
|
|
||||||
|
bot = telebot.TeleBot(TOKEN)
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
from bot import bot
|
||||||
|
import locale
|
||||||
|
|
||||||
|
|
||||||
|
def change_locale(message):
|
||||||
|
if message.text.split(' ')[0] == '/ru':
|
||||||
|
locale.LOCALE = 'ru'
|
||||||
|
bot.send_message(message.chat.id, 'Выбран русский язык')
|
||||||
|
elif message.text.split(' ')[0] == '/en':
|
||||||
|
locale.LOCALE = 'en'
|
||||||
|
bot.send_message(message.chat.id, 'Selected language: english')
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
LOCALE = 'ru'
|
||||||
|
|
||||||
|
ru = {
|
||||||
|
'help_message':
|
||||||
|
'''
|
||||||
|
Привет я бот для управления твоими финансами и вот что я умею:
|
||||||
|
/help - показать этот список.
|
||||||
|
/ru - русский язык
|
||||||
|
/en - английский язык
|
||||||
|
''',
|
||||||
|
'error404_message': 'Я не могу это сделать.'
|
||||||
|
}
|
||||||
|
|
||||||
|
en = {
|
||||||
|
'help_message':
|
||||||
|
'''
|
||||||
|
Hi i am finance bot and i can do this:
|
||||||
|
/help - open this list
|
||||||
|
/ru - russian language
|
||||||
|
/en - english language
|
||||||
|
''',
|
||||||
|
'error404_message': 'I can\'t do this.'
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
from termcolor import cprint
|
||||||
|
from bot import bot
|
||||||
|
import locale
|
||||||
|
from changelocale import change_locale
|
||||||
|
|
||||||
|
|
||||||
|
def main_bot(messages):
|
||||||
|
for message in messages:
|
||||||
|
if message.text.split(' ')[0] == '/start' or message.text.split(' ')[0] == '/help':
|
||||||
|
mes = None
|
||||||
|
if locale.LOCALE == 'ru':
|
||||||
|
mes = locale.ru['help_message']
|
||||||
|
elif locale.LOCALE == 'en':
|
||||||
|
mes = locale.en['help_message']
|
||||||
|
bot.send_message(message.chat.id, mes)
|
||||||
|
elif message.text.split(' ')[0] == '/ru' or message.text.split(' ')[0] == '/en':
|
||||||
|
change_locale(message)
|
||||||
|
else:
|
||||||
|
mes = None
|
||||||
|
if locale.LOCALE == 'ru':
|
||||||
|
mes = locale.ru['error404_message']
|
||||||
|
elif locale.LOCALE == 'en':
|
||||||
|
mes = locale.en['error404_message']
|
||||||
|
bot.send_message(message.chat.id, mes)
|
||||||
|
|
||||||
|
|
||||||
|
bot.set_update_listener(main_bot)
|
||||||
|
|
||||||
|
try:
|
||||||
|
bot.polling(none_stop=True)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
exit('byby\n')
|
||||||
|
except Exception as e:
|
||||||
|
cprint(str(e), 'red')
|
||||||
|
bot.polling(none_stop=True)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
pass
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
certifi==2022.9.24
|
||||||
|
charset-normalizer==2.1.1
|
||||||
|
idna==3.4
|
||||||
|
pyTelegramBotAPI==4.7.0
|
||||||
|
requests==2.28.1
|
||||||
|
termcolor==2.0.1
|
||||||
|
urllib3==1.26.12
|
||||||
Reference in new issue
Block a user