Skip to content

Commit

Permalink
Added website command to refactored code
Browse files Browse the repository at this point in the history
  • Loading branch information
maya-dc-patel committed Dec 4, 2022
1 parent 094c95b commit a841c14
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
6 changes: 6 additions & 0 deletions code/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from command.limit import command_limit
from command.limit_cat import command_limitcategory
from command.settle import command_settle
from command.website import command_website


load_dotenv()
Expand Down Expand Up @@ -109,6 +110,11 @@ def smart_limit_cat(message):
def smart_settle(message):
command_settle(message, bot)

# Handling /settle command
@bot.message_handler(commands=['website'])
def smart_website(message):
command_website(message, bot)

async def main():
try:
bot.polling(none_stop=True)
Expand Down
3 changes: 2 additions & 1 deletion code/command/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
'limit': 'Add daily/monthly/yearly limits for spending',
'limitcategory': 'Add daily/monthly/yearly limits for spending in a specific category',
'search':'Search a product and compare prices',
'settle': 'Settle an expense shared with you'
'settle': 'Settle an expense shared with you',
'website': 'Website'
}

bot = telebot.TeleBot(api_token)
Expand Down
60 changes: 60 additions & 0 deletions code/command/website.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import logging
import re
import os
import pymongo
import telebot
import time
from telebot import types
from datetime import datetime, date, timedelta
from telegram import ParseMode
from telethon import TelegramClient
import asyncio
from pymongo import MongoClient, ReturnDocument
import os
from dotenv import load_dotenv
import argparse
import Scraped_data
import formatter
from tabulate import tabulate
load_dotenv()

api_token = os.getenv('TELEGRAM_BOT_TOKEN')
api_id = os.getenv('TELEGRAM_API_ID')
api_hash = os.getenv('TELEGRAM_API_HASH')
api_username = os.getenv('TELEGRAM_USERNAME')
cluster = os.getenv('MONGO_DB_URL')

mongo_client = MongoClient(cluster)
db = mongo_client.smartSpendDB

#global variables to store user choice, user list, spend categories, etc
user_bills = {}
user_limits = {}
count_ = 0
spend_categories = ['Food', 'Groceries', 'Utilities', 'Transport', 'Shopping', 'Miscellaneous', 'Others (Please Specify)']
spend_display_option = ['Day', 'Month', 'All']
timestamp_format = '%b %d %Y %I:%M%p'
limit_categories = ['daily', 'monthly', 'yearly', 'View Limits']

#set of implemented commands and their description
commands = {
'menu': 'Display this menu',
'add': 'Record/Add a new spending',
'display': 'Show sum of expenditure for the current day/month',
'history': 'Display spending history',
'delete': 'Clear/Erase all your records',
'edit': 'Edit/Change spending details',
'limit': 'Add daily/monthly/yearly limits for spending',
'search':'Search a product and compare prices',
'settle': 'Settle an expense shared with you'
}

def command_website(message, bot):
chat_id = message.chat.id
# print(cluster)
# print('https://localhost:4200/{}'.format(chat_id))
url = 'https://localhost:4200/{}'.format(chat_id)
bot.send_message(chat_id, text="Check out the website:\n http://localhost:4200/{}".format(chat_id),parse_mode=ParseMode.MARKDOWN)
return True


0 comments on commit a841c14

Please sign in to comment.