Skip to content

Commit 3a6ed8c

Browse files
committed
money_readme: clarify documentation
1 parent 87fd300 commit 3a6ed8c

1 file changed

Lines changed: 108 additions & 19 deletions

File tree

MONEY_README.md

Lines changed: 108 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,122 @@
1-
hackbot money
2-
------------
1+
# hackbot money
2+
33
A hackbot script to help us check how much money we need.
44

5-
# How to update money for a new year
5+
## Setting up the spreadsheet
6+
7+
First, make a new Google spreadsheet tracking money in whatever way you'd
8+
like.
9+
10+
Next, make two cells in the same row, one with the **total $ committed** and
11+
one with the **total $ received**. Hackbot money requires that they be in the
12+
same row in two different columns, one after the other.
13+
14+
Make sure that these cells display the amounts _without_ a dollar sign (e.g.
15+
`1000`, not `$1000`). See [here][no-dollar] if you're not sure how to do this.
16+
17+
For hackbot to view the sheet, you need to invite our Google Service Account
18+
email to be able to view the sheet. Run `!serviceaccount` in the HackMIT
19+
Slack to see the email.
20+
21+
```bash
22+
!serviceaccount
23+
```
24+
25+
Finally, copy the Google Sheets URL hash -- the thing at
26+
`https://docs.google.com/spreadsheets/d/${URL_HASH}/`.
27+
28+
## Connecting hackbot to the spreadsheet
29+
30+
Hackbot needs five configuration variables for the spreadsheet.
31+
32+
1. `money.spreadsheet.url`: the hash from the spreadsheet URL.
33+
34+
```bash
35+
hackbot conf set money.spreadsheet.url "paste in the hash here"
36+
```
37+
38+
5. `money.spreadsheet.tabname`: the name of the Google Sheets tab that
39+
contains the two cells.
640

7-
1. Make a Google spreadsheet with the $ amounts.
41+
```bash
42+
hackbot conf set money.spreadsheet.tabname "Money"
43+
```
844

9-
1. In #botspam, set `money.spreadsheet.url` to the hash in the Google spreadsheet URL -- it's the thing that goes in `https://docs.google.com/spreadsheets/d/${money.spreadsheet.url}/`.
45+
2. `money.row`: the row you put the "total $ committed" and "total $
46+
received" cells in. The rows are 1-indexed.
1047

11-
1. Put the *total $ received* and *total $ committed* in two colums in the spreadsheet. See [hackbot config variables](#hackbot-config-variables) for rules about placement so you can set `money.row`, `money.received.col`, and `money.outstanding.col`. You can also see what the previous settings were in #botspam for reference. Make sure that Google sheets doesn't append "$" to the column value ([fix here](http://www.solveyourtech.com/remove-dollar-sign-google-sheets/) if that happens).
48+
```bash
49+
hackbot conf set money.row "1"
50+
```
1251

13-
1. In #botspam, set `money.spreadsheet.tabname` to the name of the tab in the Google spreadsheet where the cells are.
52+
3. `money.received.col`: the column you put the "total $ received" cell
53+
in. The columns are 1-indexed.
1454

15-
1. Invite our Google Service Account email to be able to view the sheet -- run `!serviceaccount` in #botspam to see the email.
55+
```bash
56+
hackbot conf set money.received.col "1"
57+
```
1658

17-
1. Now, you should be able to run `hackbot money` or `hackbot $` and see the the numbers!
59+
4. `money.outstanding.col`: the column you put the "total $ committed" cell
60+
in, directly to the right of the "total $ received" cell. The columns are
61+
1-indexed.
1862

63+
```bash
64+
hackbot conf set money.outstanding.col "2"
65+
```
66+
67+
You can also check what the previous settings were for reference.
68+
69+
```bash
70+
> hackbot conf get money.spreadsheet.url
71+
money.spreadsheet.url = "abc123"
72+
> hackbot conf get money.spreadsheet.tabname
73+
money.spreadsheet.tabname = "Companies"
74+
> hackbot conf get money.row
75+
money.row = "1"
76+
> hackbot conf get money.received.col
77+
money.received.col = "4"
78+
> hackbot conf get money.outstanding.col
79+
money.outstanding.col = "5"
80+
```
81+
82+
This script is clearly very restrictive. You're welcome to refactor it to be
83+
more permissive.
84+
85+
Once you've set these variables, run `hackbot money` or `hackbot $` to see
86+
the the numbers!
87+
88+
```bash
89+
> hackbot money
90+
Received: $1K
91+
Outstanding: $99K
92+
Total: $100K
93+
```
94+
95+
Hackbot money checks the money spreadsheet every 10 minutes and updates the
96+
channel topic with new amounts if they've changed. It uses the
97+
`money.channel` config variable to know which channel's topic to update.
98+
99+
```bash
100+
> hackbot conf get money.channel
101+
money.channel = "cr"
102+
```
19103

20104
## Credentials
21-
If the json file on the EC2 instance becomes out of date, follow these steps to get a new one.
22-
* Go to console.developers.google.com and create a project if you do not have one already for hackbot.
105+
106+
Hackbot money requires a Google service account to view the spreadsheet. The
107+
credentials for this service account are in a file called
108+
`hackmit-money-2015-credentials.json`.
109+
110+
If the json file on the EC2 instance becomes out of date, follow these steps
111+
to get a new one.
112+
113+
* Go to console.developers.google.com and create a project if you do not have
114+
one already for hackbot.
23115
* Create a service account
24116
* Enable the Google Drive API
25117
* Download credentials as json.
26-
* Get it onto the EC2 instance using scp or something.
27-
* Invite the service account to the spreadsheet using the @developers.gserviceaccounts.com email
28-
29-
## hackbot config variables
30-
There are some restrictions that this script assumes on where the values will be placed, you can try and refactor this if you want to be more permissive. It assumes also that the values are on the second sheet in the shared Google sheet.
31-
* `money.row` - row that the values are expected to be in, 1-indexed. Both outstanding & received must be in the same row.
32-
* `money.received.col` - column that the amount received is in, 1-indexed. Must be `money.outstanding.col` - 1.
33-
* `money.outstanding.col` - column that the amount outstanding is in, 1-indexed. Must be `money.received.col` + 1.
118+
* Get it onto the EC2 instance using `scp` or something.
119+
* Invite the service account to the spreadsheet using the
120+
@developers.gserviceaccounts.com email as mentioned above
121+
122+
[no-dollar]: http://www.solveyourtech.com/remove-dollar-sign-google-sheets/

0 commit comments

Comments
 (0)