Skip to content

Commit c0767cb

Browse files
authored
Merge pull request #419 from Lichess4545/new-slack-api
New slack api
2 parents 4760b4e + de1c3e0 commit c0767cb

26 files changed

+1469
-366
lines changed

.github/workflows/build.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@
33
name: Build
44

55
on:
6-
push:
7-
branches: [main]
8-
pull_request:
9-
branches: [main]
6+
push:
7+
branches: [main]
8+
pull_request:
9+
branches: [main]
1010

1111
jobs:
12-
build:
13-
runs-on: ubuntu-latest
12+
build:
13+
runs-on: ubuntu-latest
1414

15-
steps:
16-
- uses: actions/checkout@v2
15+
steps:
16+
- uses: actions/checkout@v2
1717

18-
- uses: actions/setup-node@v2
19-
with:
20-
node-version: '12'
18+
- uses: actions/setup-node@v2
19+
with:
20+
node-version: '22'
2121

22-
- name: Install packages
23-
run: yarn install
22+
- name: Install packages
23+
run: yarn install
2424

25-
- name: Build project
26-
run: yarn build
25+
- name: Build project
26+
run: yarn build
2727

28-
- name: Run TSLint
29-
run: yarn lint
28+
- name: Run TSLint
29+
run: yarn lint
3030

31-
- name: Run tests
32-
run: yarn test
31+
- name: Run tests
32+
run: yarn test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ build
2626
.yarnrc
2727
.env
2828
.idea
29+
local.env
30+
copilot-instructions.md

README.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,36 @@
1-
# CHESSTER [![Build Status](https://github.com/Lichess4545/Chesster/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/Lichess4545/Chesster/actions/workflows/build.yml) [![Test Coverage](https://codeclimate.com/github/Lichess4545/Chesster/badges/coverage.svg)](https://codeclimate.com/github/Lichess4545/Chesster/coverage)
1+
# CHESSTER [![Build Status](https://github.com/Lichess4545/Chesster/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/Lichess4545/Chesster/actions/workflows/build.yml) [![Test Coverage](https://codeclimate.com/github/Lichess4545/Chesster/badges/coverage.svg)](https://codeclimate.com/github/Lichess4545/Chesster/coverage)
2+
23
## Introduction
4+
35
This bot was created to help moderate the Lichess45+45 league.
46

57
It has a simple interface that integrates our Slack team, with Lichess and Website HTTP API.
68

79
## Installation
10+
811
0. Clone this repo
912
1. Install vagrant
1013
2. Use the included Vagrantfile to bring up the environment - `vagrant up`, `vagrant ssh`, and `cd chesster`
1114
3. Install the yarn modules - `yarn install --dev`
1215
4. Generate a classic bot token in your Slack Team's Services and Customization.
1316
5. Generate a heltour token from Heltour's Administration interfaces.
14-
6. Add both to your `.env`:
17+
6. Create environment variables. Note that these names are a big mess because they grew organically, we need to standardize them. Add these to your `.env`:
1518
```
16-
CHESSTER_4545_SLACK_TOKEN="xoxb-<token>"
19+
adminSlack app secrets: Make these for your adminSlack bot and add them.
20+
ADMIN_SLACK_APP_TOKEN="xapp-<token>"
1721
CHESSTER_CHESSTER_SLACK_TOKEN="xoxb-<token>"
18-
CHESSTER_HELTOUR_TOKEN="<token>"
22+
ADMIN_SLACK_SIGNING_SECRET="<token>"
23+
ADMIN_SLACK_BOT_TOKEN="xoxb-<token>"
24+
25+
26+
Chesster app stuff: Make these for your Chesster bot and add them.
27+
CHESSTER_HELTOUR_TOKEN="<token>" -- generate this from heltour in the API Keys section
1928
CHESSTER_LICHESS_TOKEN="<token>"
29+
SLACK_APP_TOKEN="xapp-<token>"
30+
SLACK_APP_BOT_TOKEN="xoxb-<token>"
31+
SLACK_SIGNING_SECRET="<token>"s
2032
```
33+
2134
7. Migrate databases: `yarn run migrate config/testconfig.js`
2235
8. Install your bot's token in the start script, start_chesster.
2336
9. Start the bot. `yarn run start`
@@ -26,10 +39,11 @@ It has a simple interface that integrates our Slack team, with Lichess and Websi
2639
2740
Run these before submitting a PR:
2841
29-
- `yarn test`
30-
- `yarn run lint`
42+
- `yarn test`
43+
- `yarn run lint`
3144
3245
## Website Integration
46+
3347
This bot utilizes the heltour api from this repo: https://github.com/cyanfish/heltour/
3448
You will need to create a token from an installation of this app in order to access and manipulate data.
3549

config/config.js

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
// NOTE: None of these files are committed and for good reason.
2-
// You must provide your own.
2+
// You must provide your own.
33
const dotenv = require('dotenv')
44
dotenv.config()
55
let db = require('./db.js')
6-
let _4545_SLACK_TOKEN =
7-
process.env.CHESSTER_4545_SLACK_TOKEN || "It won't work without this token"
8-
let CHESSTER_SLACK_TOKEN =
9-
process.env.CHESSTER_CHESSTER_SLACK_TOKEN ||
6+
7+
let LICHESS_4545_APP_TOKEN =
8+
process.env.LICHESS_4545_APP_TOKEN || "It won't work without this token"
9+
let LICHESS_4545_SIGNING_SECRET =
10+
process.env.LICHESS_4545_SIGNING_SECRET ||
1011
"It won't work without this token"
12+
let LICHESS_4545_BOT_TOKEN =
13+
process.env.LICHESS_4545_BOT_TOKEN || "It won't work without this token"
14+
15+
let FORWARD_APP_TOKEN =
16+
process.env.FORWARD_APP_TOKEN || "It won't work without this token"
17+
let FORWARD_SIGNING_SECRET =
18+
process.env.FORWARD_SIGNING_SECRET || "It won't work without this token"
19+
let FORWARD_BOT_TOKEN =
20+
process.env.FORWARD_BOT_TOKEN || "It won't work without this token"
21+
1122
let HELTOUR_TOKEN =
1223
process.env.CHESSTER_HELTOUR_TOKEN || "It won't work without this token"
24+
1325
let LICHESS_TOKEN =
1426
process.env.CHESSTER_LICHESS_TOKEN || "It won't work without this token"
1527

@@ -21,9 +33,18 @@ var config = {
2133
watcherBaseURL: 'https://lichess.org/api/stream/games-by-users',
2234
watcherToken: LICHESS_TOKEN,
2335

36+
// These are never actually used, the variables are accessed another way
2437
slackTokens: {
25-
lichess4545: _4545_SLACK_TOKEN,
26-
chesster: CHESSTER_SLACK_TOKEN,
38+
lichess4545: {
39+
token: LICHESS_4545_BOT_TOKEN,
40+
signingSecret: LICHESS_4545_SIGNING_SECRET,
41+
appToken: LICHESS_4545_APP_TOKEN,
42+
},
43+
forwarding: {
44+
token: FORWARD_BOT_TOKEN,
45+
signingSecret: FORWARD_SIGNING_SECRET,
46+
appToken: FORWARD_APP_TOKEN,
47+
},
2748
},
2849
winston: {
2950
domain: 'chesster',
@@ -278,7 +299,7 @@ var config = {
278299
chess960scheduling: 'chess960',
279300
},
280301
messageForwarding: {
281-
channelId: 'G3D6N2HNF',
302+
channelId: 'C08HZL49YH0',
282303
},
283304
pingMods: {
284305
C0VCCPMJ8: ['U0J2J60F8'],

config/db.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var config = {
33
name: 'chesster',
44
username: 'chesster',
55
password: 'scrappypulpitgourdehinders',
6+
database: 'chesster',
67
host: 'localhost',
78
dialect: 'postgres',
89
logging: false,

config/testconfig.js

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,28 @@
33
const UNSTABLE_BOT_ID = 'C016G6T5QTW'
44
const UNSTABLE_BOT_LONEWOLF_ID = 'C015V92UJUX'
55

6+
const LONEWOLF_GAMES_CHANNEL_ID = 'C08JZJNU8UC'
7+
const LONEWOLF_SCHEDULING_CHANNEL_ID = 'C08K6E8MJNM'
8+
9+
const CHESS960_GAMES_CHANNEL_ID = 'C08KHN4FTUY'
10+
const CHESS960_SCHEDULING_CHANNEL_ID = 'C08JPSKRF2S'
11+
12+
// This is in the glbert-test slack
13+
const TEAM_GAMES_CHANNEL_ID = 'C08HXSVUH26'
14+
615
let config = require('./config.js')
7-
config['watcherBaseURL'] = 'https://lichess.dev/api/stream/games-by-users'
16+
17+
config['watcherBaseURL'] = 'https://lichess.org/api/stream/games-by-users'
818
config['winston']['channel'] = '#modster-logging'
919
config['winston']['handleExceptions'] = false
1020

1121
config['welcome']['channel'] = 'dev-testing-lonewolf'
1222

23+
const heltourToken = config['heltour']['token']
24+
1325
let heltour = {
14-
baseEndpoint: 'http://localhost:8000/api/',
15-
token: config['heltour']['token']
26+
baseEndpoint: 'http://127.0.0.1:8000/api/',
27+
token: config['heltour']['token'],
1628
}
1729
let leagues = ['45+45', 'lonewolf', 'blitzbattle', 'chess960']
1830
config['heltour'] = heltour
@@ -23,30 +35,41 @@ leagues.map((k) => {
2335
}
2436
})
2537

26-
config['leagues']['45+45']['scheduling']['channel'] = 'dev-testing'
27-
config['leagues']['45+45']['results']['channel'] = 'dev-testing'
28-
config['leagues']['45+45']['results']['channelId'] = UNSTABLE_BOT_ID
29-
config['leagues']['45+45']['gamelinks']['channel'] = 'dev-testing'
30-
config['leagues']['45+45']['gamelinks']['channelId'] = UNSTABLE_BOT_ID
38+
config['leagues']['45+45']['scheduling']['channel'] = 'team-scheduling'
39+
// TODO events API: This was 'dev-testing' in the original config
40+
config['leagues']['45+45']['results']['channel'] = 'team-games'
41+
config['leagues']['45+45']['results']['channelId'] = TEAM_GAMES_CHANNEL_ID
42+
// TODO events API: This was 'dev-testing' in the original config
43+
config['leagues']['45+45']['gamelinks']['channel'] = 'team-games'
44+
config['leagues']['45+45']['gamelinks']['channelId'] = TEAM_GAMES_CHANNEL_ID
3145
config['leagues']['45+45']['alternate']['channelId'] = UNSTABLE_BOT_ID
32-
config['leagues']['lonewolf']['scheduling']['channel'] = 'dev-testing-lonewolf'
33-
config['leagues']['lonewolf']['results']['channel'] = 'dev-testing-lonewolf'
34-
config['leagues']['lonewolf']['results']['channelId'] = UNSTABLE_BOT_LONEWOLF_ID
35-
config['leagues']['lonewolf']['gamelinks']['channel'] = 'dev-testing-lonewolf'
36-
config['leagues']['lonewolf']['gamelinks'][
37-
'channelId'
38-
] = UNSTABLE_BOT_LONEWOLF_ID
46+
config['leagues']['lonewolf']['scheduling']['channel'] = 'lonewolf-scheduling'
47+
config['leagues']['lonewolf']['results']['channel'] = 'lonewolf-games'
48+
config['leagues']['lonewolf']['results']['channelId'] =
49+
LONEWOLF_GAMES_CHANNEL_ID
50+
config['leagues']['lonewolf']['gamelinks']['channel'] = 'lonewolf-games'
51+
config['leagues']['lonewolf']['gamelinks']['channelId'] =
52+
LONEWOLF_GAMES_CHANNEL_ID
53+
// Events API todo: I added this in becaue there was nothing for 960, not sure if it's needed
54+
config['leagues']['chess960']['scheduling']['channel'] = 'chess960scheduling'
55+
config['leagues']['chess960']['scheduling']['channelId'] =
56+
CHESS960_SCHEDULING_CHANNEL_ID
57+
config['leagues']['chess960']['results']['channel'] = 'chess960games'
58+
config['leagues']['chess960']['results']['channelId'] =
59+
CHESS960_GAMES_CHANNEL_ID
60+
config['leagues']['chess960']['gamelinks']['channel'] = 'chess960games'
3961

4062
config['channelMap'][UNSTABLE_BOT_ID] = '45+45'
4163
config['channelMap']['dev-testing'] = '45+45'
4264
config['channelMap']['dev-testing-lonewolf'] = 'lonewolf'
4365
config['channelMap']['dev-testing-blitz'] = 'blitz'
4466
config['channelMap'][UNSTABLE_BOT_LONEWOLF_ID] = 'lonewolf'
4567

46-
config['messageForwarding']['channelId'] = 'G3FJXJ0C9'
68+
config['messageForwarding']['channelId'] = 'C08HZL49YH0'
4769
config['pingMods'] = {
48-
"C016G6T5QTW": [ // #dev-testing
49-
"U0164C6FXLK" // @lakinwecker
70+
C016G6T5QTW: [
71+
// #dev-testing
72+
'U0164C6FXLK', // @lakinwecker
5073
],
5174
}
5275

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
"test": "test"
88
},
99
"dependencies": {
10+
"@slack/bolt": "^4.2.0",
1011
"@slack/rtm-api": "^5.0.3",
11-
"@slack/web-api": "^5.8.0",
12+
"@slack/web-api": "^7.9.1",
1213
"@types/fast-levenshtein": "^0.0.1",
1314
"async": "^3.2.2",
1415
"chai": "^4.2.0",
@@ -21,7 +22,7 @@
2122
"logform": "^2.1.2",
2223
"moment": "^2.29.4",
2324
"moment-timezone": "^0.5.35",
24-
"pg": "^7.8.2",
25+
"pg": "^8.11.3",
2526
"pg-hstore": "^2.3.3",
2627
"q": "^1.5.1",
2728
"sequelize": "^5.21.5",
@@ -42,7 +43,7 @@
4243
"@types/chai": "^4.2.10",
4344
"@types/lodash": "^4.14.149",
4445
"@types/mocha": "^7.0.2",
45-
"@types/node": "^13.9.0",
46+
"@types/node": "^22.13.14",
4647
"@types/q": "^1.5.2",
4748
"@types/triple-beam": "^1.3.0",
4849
"@types/validator": "^12.0.1",
@@ -52,7 +53,7 @@
5253
"newtype-ts": "^0.3.4",
5354
"nyc": "^15.1.0",
5455
"ts-node": "^8.8.1",
55-
"typescript": "^3.8.3"
56+
"typescript": "^5.8.2"
5657
},
5758
"scripts": {
5859
"build": "node_modules/typescript/bin/tsc",

0 commit comments

Comments
 (0)