Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
1fe0b31
rafactor: Modularize code.py and Indentation fix
sak007 Oct 19, 2021
56ff2e3
chore: updated setup.py
sak007 Oct 19, 2021
9213d22
delete expense_record.json
sak007 Oct 19, 2021
475482d
fix: Issue while adding and loading from expence_report
sak007 Oct 20, 2021
7bb7dd7
Added exception message code and set logging to info
sak1997 Oct 20, 2021
8022e48
Created add.md - readme for add.py feature
sak1997 Oct 20, 2021
12597ee
Removed extra lines in example in add.md
sak1997 Oct 20, 2021
25a29c8
Created add.md - readme for delete.py feature
sak1997 Oct 20, 2021
dd9248a
Merge branch 'backlogs' of https://github.com/sak007/MyDollarBot into…
sak1997 Oct 20, 2021
2f129dd
fix: delete.py now works correctly
sak1997 Oct 20, 2021
44e0b08
docs: added code.md
sak1997 Oct 20, 2021
9590c70
feat: Simplify installation
sak007 Oct 20, 2021
6904af6
fixed indendation and added style checks
wizard-31 Oct 21, 2021
e105a52
Update run.sh
wizard-31 Oct 21, 2021
6763972
added display.md docs
sak1997 Oct 21, 2021
2927dcf
Update requirements.txt
wizard-31 Oct 21, 2021
a24df24
added docs: edit.md
sak1997 Oct 21, 2021
938da5a
added docs: history.md
sak1997 Oct 21, 2021
1d79837
added docs: helper.md
sak1997 Oct 21, 2021
17087ab
Updated travis.yml with codecoverage
wizard-31 Oct 21, 2021
ed61930
Update .travis.yml
wizard-31 Oct 21, 2021
4d2f3b2
Added CodeCov
wizard-31 Oct 21, 2021
b0baea3
updated travis.yml and requirements for codecov
wizard-31 Oct 21, 2021
d76f4cb
Merge remote-tracking branch 'origin/main' into backlogs
wizard-31 Oct 21, 2021
aef8fac
Edit functionality working now
zedunaid Oct 22, 2021
40b5072
Updated the badges
rjain09 Oct 23, 2021
6941898
Edit functionality - build issue fix
zedunaid Oct 23, 2021
6ce4d6f
Edit functionality - build issue fix
zedunaid Oct 23, 2021
6a324e7
Updated with more info
sak1997 Oct 27, 2021
cfa385f
Corrected display issues
sak1997 Oct 27, 2021
4e25b94
test: testcases for helper.py
sak007 Oct 29, 2021
a185904
chore: add pytest-mock in requirements
sak007 Oct 29, 2021
1148f81
added test for add.py
sak1997 Oct 27, 2021
d80d064
added test_add.py test cases
sak1997 Oct 29, 2021
2c2bd88
cleaned up test_add.py
sak1997 Oct 29, 2021
668268c
Added Test Cases for Delete.py and History.py. Updated History.py wit…
wizard-31 Oct 30, 2021
e957aec
Updated Styling issues wrt flake8 - Issue #15
wizard-31 Oct 30, 2021
014632a
Updated Local Pth Issue. Fixed Issue #15
wizard-31 Oct 30, 2021
134544d
Fixed E231 Styling Issue in #15
wizard-31 Oct 30, 2021
0d9671b
Adding test cases for eedit functionality
zedunaid Oct 31, 2021
a1bb0d0
Adding test cases for eedit functionality
zedunaid Oct 31, 2021
c806db7
Adding test cases for edit functionality build fix
zedunaid Oct 31, 2021
67d9958
Test cases for edit functionality build fix
zedunaid Oct 31, 2021
4c205c6
Edit functionality - Code coverage issue fix
zedunaid Oct 31, 2021
6bfb0fc
Edit functionality - Code coverage issue fix
zedunaid Oct 31, 2021
24fdf41
Update build badge
sak007 Oct 31, 2021
08d2b3e
added a test to test_add.py
sak1997 Nov 1, 2021
c4ecdef
added test in test_add for add record
sak1997 Nov 1, 2021
5b4c315
fixed flake8 issue added test_add test case
sak1997 Nov 1, 2021
9ece4b1
fixed flake8 issue
sak1997 Nov 1, 2021
b54aaad
fixed tests in test_add.py
sak1997 Nov 1, 2021
901360f
fixed flake8 issues
sak1997 Nov 1, 2021
6918c86
Updated README.md with the latest run instructions
sak1997 Nov 1, 2021
010a463
Added Test for display
rjain09 Nov 2, 2021
3561d81
Fixed the build error
rjain09 Nov 2, 2021
c9b0681
Fixed the build issue
rjain09 Nov 4, 2021
861194c
Improved coverage to fix build
rjain09 Nov 4, 2021
5a21c12
Added coverage to display.py
rjain09 Nov 4, 2021
0a66b9c
Improved coverage for test_display.py
rjain09 Nov 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,9 @@ dmypy.json

# Pyre type checker
.pyre/

# Mac Sys files
.DS_Store

# Generated files
expense_record.json
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ python:
install:
- pip install .
- pip install -r requirements.txt
- pip install coverage
- pip install codecov
script:
- pytest test/

- flake8 --ignore=E501,W605
- coverage run -m pytest -q test/
after_success:
- bash <(curl -s https://codecov.io/bash) -t c18f2a5b-6240-4bec-a551-b427163f05b8
51 changes: 27 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# TrackMyDollar
<hr>
<p align="center">
<a><img height=560 width=1000
<a><img height=360 width=550
src="https://github.com/deekay2310/MyDollarBot/blob/c56b4afd4fd5bbfffea0d0a4aade58596a5cb678/docs/0001-8711513694_20210926_212845_0000.png" alt="Expense tracking made easy!"></a>
</p>
<hr>

![MIT license](https://img.shields.io/badge/License-MIT-green.svg)
[![Platform](https://img.shields.io/badge/Platform-Telegram-blue)](https://desktop.telegram.org/)
![GitHub](https://img.shields.io/badge/Language-Python-blue.svg)
![GitHub contributors](https://img.shields.io/github/contributors/deekay2310/SE21_HW2B_Group6)

![GitHub contributors](https://img.shields.io/github/contributors/sak007/project-X)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5542548.svg)](https://doi.org/10.5281/zenodo.5542548)
[![Platform](https://img.shields.io/badge/Platform-Telegram-blue)](https://desktop.telegram.org/)
[![Build Status](https://app.travis-ci.com/deekay2310/MyDollarBot.svg?branch=main)](https://app.travis-ci.com/github/deekay2310/MyDollarBot)

[![Build Status](https://app.travis-ci.com/sak007/MyDollarBot.svg?branch=backlogs)](https://app.travis-ci.com/github/sak007/MyDollarBot)
[![codecov](https://codecov.io/gh/sak007/MyDollarBot/branch/main/graph/badge.svg?token=5AYMR8MNMP)](https://codecov.io/gh/sak007/MyDollarBot)
[![GitHub issues](https://img.shields.io/github/issues/sak007/MyDollarBot)](https://github.com/sak007/MyDollarBot/issues?q=is%3Aopen+is%3Aissue)
[![GitHub closed issues](https://img.shields.io/github/issues-closed/sak007/MyDollarBot)](https://github.com/sak007/MyDollarBot/issues?q=is%3Aissue+is%3Aclosed)
![Lines of code](https://img.shields.io/tokei/lines/github/sak007/MyDollarBot)

<hr>

Expand All @@ -32,46 +38,43 @@ https://user-images.githubusercontent.com/15325746/135395315-e234dc5e-d891-470a-

The below instructions can be followed in order to set-up this bot at your end in a span of few minutes! Let's get started:

1. This installation guide assumes that you have already installed Python (Python3 would be preferred)

2. Clone this repository to your local system at a suitable directory/location of your choice

3. Start a terminal session, and navigate to the directory where the repo has been cloned
1. This installation guide assumes that you have already installed Python (Python3 would be preferred) and Telegram web or Desktop. Clone this repository to your local system.

4. Run the following command to install the required dependencies:
2. Start a terminal session in the directory where the project has been cloned. Run the following command to install the required dependencies:
```
pip install -r requirements.txt
```
5. Download and install the Telegram desktop application for your system from the following site: https://desktop.telegram.org/

6. Once you login to your Telegram account, search for "BotFather" in Telegram. Click on "Start" --> enter the following command:
3. In Telegram, search for "BotFather". Click on "Start", and enter the following command:
```
/newbot
```
7. Follow the instructions on screen and choose a name for your bot. Post this, select a username for your bot that ends with "bot" (as per the instructions on your Telegram screen)
Follow the instructions on screen and choose a name for your bot. After this, select a username for your bot that ends with "bot".

8. BotFather will now confirm the creation of your bot and provide a TOKEN to access the HTTP API - copy this token for future use.
4. BotFather will now confirm the creation of your bot and provide a TOKEN to access the HTTP API - copy and save this token for future use.

9. In the directory where this repo has been cloned, navigate to the "code" folder and open the "code.py" file. This file consists of a variable by the name "api_token". Paste the token copied in step 8 in the placeholder provided for this variable:
5. In the directory where this repo has been cloned, please run the below command to execute a bash script to run the Telegram Bot:
```
api_token = "INSERT API KEY HERE"
./run.sh
```
10. In the Telegram app, search for your newly created bot by entering the username and open the same. Once this is done, go back to the terminal session. Navigate to the directory containing the "code.py" file and run the following command:
(OR)
```
python code.py
bash run.sh
```
11. A successful run will generate a message on your terminal that says "TeleBot: Started polling."
12. Post this, navigate to your bot on Telegram, enter the "/start" or "/menu" command, and you are all set to track your expenses!
Please note that it will ask you to paste the API token you received from Telegram in step 4.
A successful run will generate a message on your terminal that says "TeleBot: Started polling."

6. In the Telegram app, search for your newly created bot by entering the username and open the same. Now, on Telegram, enter the "/start" or "/menu" command, and you are all set to track your expenses!


# Notes:
You can download and install the Telegram desktop application for your system from the following site: https://desktop.telegram.org/



<hr>
<p>--------------------------------------------------------------------------------------------------</p>
<p>Title:'Track My Dollar'</p>
<p>Version: '1.0'</p>
<p>Version: '1.5'</p>
<p>Description: 'An easy to use Telegram Bot to track everyday expenses'</p>
<p>Authors:'Dev, Prakruthi, Radhika, Rohan, Sunidhi'</p>
<p>--------------------------------------------------------------------------------------------------</p>
<p>Authors(Iteration 1.5):'Athithya, Subramanian, Ashok, Zunaid, Rithik'</p>
<p>Authors(Iteration 1):'Dev, Prakruthi, Radhika, Rohan, Sunidhi'</p>
11 changes: 3 additions & 8 deletions code/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 29 17:10:59 2021

@author: deekay
"""

import os
import sys
sys.path.insert(0, os.getcwd() + "/code")
69 changes: 69 additions & 0 deletions code/add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import helper
import logging
from telebot import types
from datetime import datetime


option = {}


def run(message, bot):
helper.read_json()
chat_id = message.chat.id
option.pop(chat_id, None) # remove temp choice
markup = types.ReplyKeyboardMarkup(one_time_keyboard=True)
markup.row_width = 2
for c in helper.getSpendCategories():
markup.add(c)
msg = bot.reply_to(message, 'Select Category', reply_markup=markup)
bot.register_next_step_handler(msg, post_category_selection, bot)


def post_category_selection(message, bot):
try:
chat_id = message.chat.id
selected_category = message.text
if selected_category not in helper.getSpendCategories():
bot.send_message(chat_id, 'Invalid', reply_markup=types.ReplyKeyboardRemove())
raise Exception("Sorry I don't recognise this category \"{}\"!".format(selected_category))

option[chat_id] = selected_category
message = bot.send_message(chat_id, 'How much did you spend on {}? \n(Enter numeric values only)'.format(str(option[chat_id])))
bot.register_next_step_handler(message, post_amount_input, bot)
except Exception as e:
logging.exception(str(e))
bot.reply_to(message, 'Oh no! ' + str(e))
display_text = ""
commands = helper.getCommands()
for c in commands: # generate help text out of the commands dictionary defined at the top
display_text += "/" + c + ": "
display_text += commands[c] + "\n"
bot.send_message(chat_id, 'Please select a menu option from below:')
bot.send_message(chat_id, display_text)


def post_amount_input(message, bot):
try:
chat_id = message.chat.id
amount_entered = message.text
amount_value = helper.validate_entered_amount(amount_entered) # validate
if amount_value == 0: # cannot be $0 spending
raise Exception("Spent amount has to be a non-zero number.")

date_of_entry = datetime.today().strftime(helper.getDateFormat() + ' ' + helper.getTimeFormat())
date_str, category_str, amount_str = str(date_of_entry), str(option[chat_id]), str(amount_value)
helper.write_json(add_user_record(chat_id, "{},{},{}".format(date_str, category_str, amount_str)))
bot.send_message(chat_id, 'The following expenditure has been recorded: You have spent ${} for {} on {}'.format(amount_str, category_str, date_str))

except Exception as e:
logging.exception(str(e))
bot.reply_to(message, 'Oh no. ' + str(e))


def add_user_record(chat_id, record_to_be_added):
user_list = helper.read_json()
if str(chat_id) not in user_list:
user_list[str(chat_id)] = []

user_list[str(chat_id)].append(record_to_be_added)
return user_list
Loading