Browse Source

bot: update README and tests

traumschule 4 years ago
parent
commit
9e026e12c5

+ 13 - 6
community-contributions/joystreamtelegrambot/README.md

@@ -2,7 +2,7 @@
 
 This bot notifies a Telegram chat about events on the Joystream chain.
 
-Demo: https://t.me/jsforumnotification
+Demo: https://t.me/JoyStreamOfficial
 
 Many thanks to [imOnlineMonitor](https://github.com/fkbenjamin/imOnlineMonitor) for providing example with polkadot chain (Kusama).
 
@@ -12,16 +12,23 @@ Many thanks to [imOnlineMonitor](https://github.com/fkbenjamin/imOnlineMonitor)
 [npm/Nodejs](https://github.com/Joystream/helpdesk/tree/master/roles/storage-providers#install-yarn-and-node-on-linux)
 
 ```
-git clone https://github.com/bitoven-dev/joystreamtelegrambot
-cd joystreamtelegrambot
-npm install
+git clone https://github.com/joystream/community-repo
+cd community-repo/community-contributions/joystreamtelegrambot
+yarn
 ```
 
 ## Configuration
 
-Open `config.ts` and set `token` and `chatid`. To get a bot token talk to @botfather on Telegram.
+Open `config.ts` and fill in the variables:
 
-Run `npm run build` to apply changes. After building \*.js files are available in `dist/` and you can run for example `node dist/bot.js --verbose --channel --council --forum --proposals`. For other options see below.
+- `token`: To get a bot token talk to @botfather on Telegram.
+- `chatid`: See below to find id of your group.
+
+Then run `npm run start` or `yarn run start`.
+Alternatively you can manually build with `npm run build` and run for example `node dist/src/bot.js --verbose --channel --council --forum --proposals`.
+For other options see below.
+
+To test status of storage providers, add their domains to to `storageProviders.ts`.
 
 ### Get chatid
 

+ 5 - 3
community-contributions/joystreamtelegrambot/src/tests.ts

@@ -2,7 +2,7 @@
 import { wsLocation } from "../config";
 
 // types
-import { Proposals } from "./types";
+import { Council, Proposals } from "./types";
 import { types } from "@joystream/types";
 import { ApiPromise, WsProvider } from "@polkadot/api";
 import { Header } from "@polkadot/types/interfaces";
@@ -26,7 +26,8 @@ const main = async () => {
   ]);
   log(`Connected to ${chain} on ${node} v${version}`);
 
-  let lastBlock = 0;
+  let council: Council = { round: 0, last: "" };
+  let lastBlock: number = 0;
   let proposals: Proposals = {
     last: 1,
     current: 2,
@@ -45,7 +46,8 @@ const main = async () => {
       lastBlock = block.number.toNumber();
       const currentBlock = block.number.toNumber();
       log("current council");
-      announce.councils(api, currentBlock, sendMessage);
+      council = await announce.council(api, council, currentBlock, sendMessage);
+      lastBlock = currentBlock;
 
       log("first proposal");
       announce.proposals(api, proposals, sendMessage);