Giter Site home page Giter Site logo

sam-bot's Introduction

Sam-Bot

A telegram bot to manage your expenditure, debts etc.

Features

  • Make a payment to your friend, and inform the bot about your transaction.
  • The bot will make a sum of all transactions you made with your friend
  • It will notify you of the final amount you owe your friend

Functionality

  • Add user (your friend)
  • Add transaction (your transaction)
  • View user
  • View transactions
  • Calculate amount owed to friend

sam-bot's People

Contributors

dependabot[bot] avatar gabrielsbarros avatar roerohan avatar thebongy avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

sam-bot's Issues

'message' is not defined, Switch case

Sam-Bot/index.js

Lines 185 to 195 in 027c93d

default:
await api.sendMessage({
chat_id: message.chat.id,
text: customStrings.understandFailure,
reply_markup: JSON.stringify({
keyboard: customStrings.commandList,
one_time_keyboard: true,
resize_keyboard: true
})
});
break;

The default in switch case throws an error:

ReferenceError: message is not defined

Push fix on branch dev.

Make bot conversational

Sam-Bot/index.js

Lines 65 to 88 in 423a5b3

} else if (message.reply_to_message.text === customStrings.askNameTransaction) {
// input
api.sendMessage({
chat_id: message.chat.id,
text: customStrings.askDescription,
reply_markup: JSON.stringify({
force_reply: true
})
});
} else if (message.reply_to_message.text === customStrings.askDescription) {
// input
api.sendMessage({
chat_id: message.chat.id,
text: customStrings.transactionAdded,
});
}
} else {

The Transaction model needs the name of the person, amount transacted and description of the transaction. The bot thus needs to remember the answers of the questions answered and then finally pass them all to the addTransaction() function.

E.G

Add Transaction
- Who did you make the transaction with?
David
- What was the transaction for?
Doritos
- What was the amount spent?
20
- Your transaction has been added

The result of this conversation should be that David, Doritos and 20 are added to the transactions database.

Make the PR on branch dev

Finish add-transaction function

Sam-Bot/commands.js

Lines 69 to 82 in 5cec92f

addTransactions = async (user, message) => {
try {
var doc = await User.find({
username: user.username
});
}
catch (e) {
console.log(`Error: ${e}`)
}
}

Follow coding style established in other functions

  • Proper spacing (tabs not spacing)
  • Comment lines if necessary
  • Description in PR

The PR must be made on the dev branch

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.