import telebot
from telebot import types
import json
TOKEN = "YOUR_BOT_TOKEN"
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(commands=['start'])
def start(message):
markup = types.InlineKeyboardMarkup()
btn1 = types.InlineKeyboardButton("???? Создать проект", callback_data='new_project')
btn2 = types.InlineKeyboardButton("???? Рассчитать NPV", callback_data='npv')
btn3 = types.InlineKeyboardButton("???? Анализ безубыточности", callback_data='break_even')
btn4 = types.InlineKeyboardButton("???? Сформировать отчёт", callback_data='report')
markup.add(btn1, btn2, btn3, btn4)
bot.send_message(message.chat.id, "Добро пожаловать в Project Expert! Выберите действие:", reply_markup=markup)
@bot.callback_query_handler(func=lambda call: True)
def callback(call):
if call.data == 'new_project':
bot.send_message(call.message.chat.id, "Введите название проекта:")
bot.register_next_step_handler(call.message, get_project_name)
elif call.data == 'npv':
bot.send_message(call.message.chat.id, "Введите инвестиции, денежный поток, срок и ставку (через запятую):")
bot.register_next_step_handler(call.message, calculate_npv)
def get_project_name(message):
project_name = message.text
bot.send_message(message.chat.id, f"Проект '{project_name}' создан! Теперь введите инвестиции:")
def calculate_npv(message):
try:
inv, flow, period, rate = map(float, message.text.split(','))
npv = -inv + sum([flow / (1 + rate/100) ** i for i in range(1, int(period)+1)])
bot.send_message(message.chat.id, f"NPV = {npv:.2f}")
except:
bot.send_message(message.chat.id, "Ошибка ввода!")
if __name__ == '__main__':
bot.polling()