Skip to content
This is a messenger bot that records the ledger of users.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
img
.gitignore
README.md
app.py
db.py
fsm.py
func.py
requirements.txt
tables.py

README.md

Owe-me-bot

The is a messenger bot that helps records the debt for users. Besides this function, this bot also prevent the embarassment of continuous asking for paybacks.

Prerequisite

  • python >= 3.6
  • graphviz
  • mysql

Installation

  • Clone the repository

    git clone https://github.com/afcidk/Owe-me-bot.git

  • Install the requirements

    pip install -r requirements.txt

  • Create database

    python3 tables.py

  • Run the server

    python3 app.py

Finite state machine diagram

fsm diagram

States

start

The initial state of every user.

got_id

This state means that the server has received a ID from user, which identifies the debitor (another user).

got_item

This state means that the server has received the item from user.

wait_confirm

This state means that the server has received the lend or pay command, and is waiting for the debitor's or creditor's response. Once they response OK, the state will transfer to start

Triggers

  • del_id

    Transfers the state from got_id to start.

  • to_start

    Transfers the state from any state to start.

  • got_item_back

    Transfers the state from got_item to got_id.

  • check_ledger

    The machine checks the database, and returns the user his/her ledger. Need to input another user's ID

  • get_my_id

    Return user's ID.

  • show_alias

    Return the alias set by user.

    The format is alias=>id, e.g. john=>2013595015663623

  • set_alias

    After the user input the ID, they can set an alias for the ID rather than typing 16 characters. (Which is also more human-readable!)

  • input_item

    The machine will accept next input as the item, no matter the operation is lend or pay.

  • input_id

    Upon receiving this trigger, the machine will accept next input as id.

  • lend

    The machine identifies the user operation as lend, and will accept next input as the quantity.The machine will transfer to wait_confirm to wait for the debitor's acceptance

  • pay

    The machine identifies the user operation as pay, and will accept next input as the quantity. The machine will transfer to wait_confirm to wait for the creditor's acceptance

  • tx_retry

    Sometimes the quick_reply button will not appear due to connection problem, or the poped up button might be flushed by other messages.

    In this case, user can send the tx_retry to send the request again.

  • tx_fail

    The creditor or debitor may response no when then receiving the confirmation. This message will trigger other one's tx_fail.

Interaction with Owe-me-bot

The demonstration contains lots of images, and are separated in different files for better reading experience.

State-related transitions

Reflexive transitions

You can’t perform that action at this time.