项目作者: fmitra

项目描述 :
A pet project to learn Go, Dennis is a Telegram bot that uses public-key cryptography to track your foreign expenses
高级语言: Go
项目地址: git://github.com/fmitra/dennis-bot.git
创建时间: 2017-11-11T10:57:23Z
项目社区:https://github.com/fmitra/dennis-bot

开源协议:

下载


Build Status Report Card codecov

Dennis

A pet project to learn Go, Dennis is a privacy friendly Telegram bot to manage expense tracking. Talk to him here

dennis

Overview

Dennis was written as a way to track international expenses in a single currency. He keeps an encrypted log
of international expenses and returns the total (daily, weekly, monthly) in the user’s preferred currency.
At the moment, he suppoorts the following commands:

  • Track an expense
  1. format: <integer_amount><currency_iso> for <description>
  2. example: 200RUB for Lunch
  • Get expense history
  1. format: how much did I spend <time_period> (today, this week, this month)
  2. example: How much did I spend today?

Privacy Friendly But Be Warned

While Dennis respects your privacy, he’s not intented to store confidential data. His primary
use case is to offer a convenient way to follow up on your day to day spending. In short,
he protects you from himself - the bot owner cannot access your detailed expenditures, or
use your information for advertising. Anyone with access to your device however can easily
access or request this info.

Data protection

Dennis creates a private/public key pair for all users to encrypt most details of their expenses
(note: timestamps are unencrypted). Your private key is protected with a password of your choice.
This ensures the admin running the bot has no zero access to your expenditures.

While this protect’s user data from the bot owner, keep in mind passwords are visible in
plaintext right inside of the Telegram application. Anyone who has access to your chats for
instance, can grab hold of your expense history.

Logging

With the exception of error logging, there are no logs set up to identify incoming or outgoing
chat history between the user and Dennis.

Developer Dependencies

Getting Started

You will need API key’s for the following services to get started.

1. Set up development environment

The test suite requires Postgres and Redis to be set up as well as a valid
configuraiton file. The config.example.json file is already prepared to use the
default settings in the sample docker-compose.example.yml.

The command below will generate a test config and spin up docker and redis

  1. make develop
  2. docker-compose up -d

This project uses Dep for dependency mangagement and Megacheck and golint as a linter.
If these packages are not installed on your system, run:

  1. make dev_dependencies

Otherwise just install the app’s third party packages.

  1. dep ensure -vendor-only -v

2. Confirm tests are passing

Note, test packages are dependent on a local shared DB. They must be run sequentially
with -p=1 to prevent race conditions during teardown methods.

  1. go test -p=1 ./...

You can also run vet, golint, megacheck and test (with race check and cache disabled) using the command below.

  1. make test_and_lint

3. Run Ngrok and set up your local config.json

These steps are not necessary if all you want to do is run the test suite.

Expose local port to web
  1. ./ngrok http 8080
Update settings
  • database and reddis - Postgres & Redis settings if you are not using the default test config
  • telegram - Telegram API token to respond to messages
  • wit - Wit.ai auth token to parse user messages
  • alphapoint - Alphapoint API key to convert currency
  • bot_domain - Domain the bot will be receiving webhooks from. In development, this will be the Ngrok URL

5. Run the bot

  1. go build ./cmd/dennis-bot
  2. ./dennis-bot

Developer Notes

Telegram Authentication

Telegram does not send any authentication headers in their requests, and instead recommends
you instead use the token as the path of your webhook.

Docker

Tagged builds are available on docker hub. They sould be configured with an environment variable
DENNIS_BOT_CONFIG that points to a JSON config on a local volume.