GoogleTableSync
You can post, update and read data from GoogleSpreadSheet with this lib.

Setup

1. Please see setup for GoogleApp lib. This lib requires GoogleApp lib.
2. Create blank Google table. You don't need any headers. Headers will be added automatically.
3. Also you need to run code too:
Libs.GoogleApp.setUrl("https://script.google.com/*************/exec");
If you have any problems with this lib - use help from GoogleApp lib.

Demo bot

BB Google Spreadsheet Demo
Telegram

Write or update data

Use index for magic!
With index key exist row will be updated!
You need tableID. You can get it from table url. It is selected here:
1
Bot.sendMessage("Saving...");
2
​
3
var syncOptions = {
4
tableID: "1_NldI2**********ank1B9c",
5
sheetName: "Users",
6
// this column will be used as index for updates or reading
7
index: "id",
8
// store data
9
datas: [],
10
// this command will be runned after sync
11
onRun: "/onSync",
12
​
13
// for debug. Comment this lines
14
// email: "[email protected]",
15
// debug: true
16
}
17
​
18
user.balance = User.getProperty("balance");
19
​
20
syncOptions.datas[0] = user;
21
​
22
// you can add more records with index
23
// syncOptions.datas[1] and etc
24
​
25
Libs.GoogleTableSync.sync(syncOptions);
Copied!
You can store any data like users, chats, products, resources and etc
1
Bot.sendMessage("Saving...");
2
​
3
var syncOptions = {
4
tableID: "1_NldI2**********ank1B9c",
5
sheetName: "Orders",
6
// this column will be used as index for updates or reading
7
index: "orderId",
8
datas: [],
9
// this command will be runned after sync
10
onRun: "/onSync"
11
}
12
​
13
var order = {
14
orderId: 10,
15
title: "Order - " + String(user.id),
16
amount: 15
17
}
18
​
19
syncOptions.datas.push(order);
20
Libs.GoogleTableSync.sync(syncOptions);
Copied!

Read data

1
Bot.sendMessage("Reading...");
2
​
3
var syncOptions = {
4
tableID: "1_NldI2**********ank1B9c",
5
sheetName: "Users",
6
// this column will be used as index for updates or reading
7
index: "id",
8
// reading data
9
datas: [],
10
// this command will be runned after sync
11
onRun: "/onSync",
12
​
13
// for debug. Comment this lines
14
// email: "[email protected]",
15
// debug: true
16
}
17
​
18
syncOptions.datas[0] = user;
19
// also you can use something like:
20
// syncOptions.datas[0] = { id: any_user_id }
21
​
22
// you can add more records with index
23
// syncOptions.datas[1] and etc
24
​
25
​
26
Libs.GoogleTableSync.read(syncOptions)
Copied!
​

Command /onRun

Bot.inspect(options)
​