Skip to content

Commit 22b22e8

Browse files
author
Murilo Alves
committed
feat(discord): add slash commands to ban/timeout users of twitch from discord
* fix(CustomAuthProvider); use correct clientIds * feat: update typeorm to latest package * chore(locales): crowdin update (sogebot#5614) * fix(panel): health check return version * fix(CustomAuthProvider): fix incorrent tokenService name * fix(refresh): add ECONNRESET catch * feat(validate): add async-mutex to acquire locks * fix(refresh): use node-fetch with higher timeout * fix(google): fix multiplication of intervals FIxes sogebot#5618 * fix(obswebsocket): fix typeorm find Fixes sogebot#5617 * fix: update websocket entity * fix(google): attempt to fix incorrect time marks * fix(google): fix incorrect game check * fix(sendMessage): fix incorrect setting of messageId on filters Fixes sogebot#5619 * chore: declare for kids * chore: add google debug * chore: ui-admin version update * chore: fix socket.d.ts * fix(main): show versions on one line * chore: deps update * feat(sendMessage): add support for /announce and color variations * chore: fix incorrect findOneBy for permission command * feat: use official chatters endpoint * feat: use eventsub-ws * chore: update ui-admin * fix: fix several menu links * chore: remove unused table * chore: (revert)remove unused table This reverts commit af1c22b. * chore: update custom variable entity (sogebot#5624) * chore: import only defaultPermissions * chore: remove index.ts loading all folder * chore: fix path * chore: add customvariable validator * fix: add custom variables validation on save * chore(locales): crowdin update (sogebot#5625) Co-authored-by: Crowdin Bot <[email protected]> * chore: remove custom variable unused variables (sogebot#5627) * chore(locales): crowdin update (sogebot#5626) Co-authored-by: Crowdin Bot <[email protected]> * chore: force runEvery 0 if type isUsed * chore(locales): crowdin update (sogebot#5628) Co-authored-by: Crowdin Bot <[email protected]> * fix(discord): add error logging * chore: update ui-admin * build: 16.9.0 * build: 16.10.0-SNAPSHOT * feat(runScript): add axios to runScript node * fix(refresh): revert removal of token string check * build: 16.10.0 * build: 16.11.0-SNAPSHOT * fix(twitch): check null recipient and correctly populate by Id * build: 16.10.1 * build: 16.11.0-SNAPSHOT * fix(refresh): mutex refreshing of token with timeout fallback * build: 16.10.2 * build: 16.11.0-SNAPSHOT * fix(changelog): update changelog and fix workflow * fix(twitch): change initiation on token validity * chore: fix chat join on startup * fix(spotify): log proper error if spotify API is temporarily unavailable * fix(getChannelChatters): fix empty parted even * feat: add tags to title cache and change to updateChannelInfo (sogebot#5630) * fix(discord): fix empty tags * build: 16.10.3 * build: 16.11.0-SNAPSHOT * fix(general): fix !_debug command using old typeorm command * fix(changelog): fix generator not setting correct build * chore: randomizer to entity * fix(panel): add missing plugins endpoint * build: 16.10.4 * build: 16.11.0-SNAPSHOT * fix(sendMessage): fix sending /announce message twice * build: 16.10.5 * build: 16.11.0-SNAPSHOT * fix(eventsub): show proper error during init * fix(eventsub): disable eventsub on dev mode * chore(locales): crowdin update (sogebot#5631) Co-authored-by: Crowdin Bot <[email protected]> * fix(users): remove all anonymous users and set inactive duplicates * chore: deps update * fix(eventlist): eventlist should properly show events even with banned users * build: 16.10.6 * build: 16.11.0-SNAPSHOT * fix(twitch): fix setting up own app generator * build: 16.10.7 * build: 16.11.0-SNAPSHOT * fix(songs): fix incorrectly sending rows from db FIxes sogebot#5634 * build: 16.10.8 * build: 16.11.0-SNAPSHOT * fix(getChannelInformation): update tags cache when changed outside of a bot * fix(twitch): init chat only if tokens are valid * chore(locales): crowdin update (sogebot#5635) Co-authored-by: Crowdin Bot <[email protected]> * refactor: overlays to groups only (sogebot#5636) * chore: fix migration * fix(eventlist): show properly overlay if user is banned * chore: add missing entity isVisible property * feat: remove Twitter integration as API to be paid * docs: update pg version * chore: fix events emitter * chore(locales): crowdin update (sogebot#5637) Co-authored-by: Crowdin Bot <[email protected]> * fix(countdown): add missing default value for showMilliseconds * fix(overlays): return data on save * chore: remove cache clean * fix(eventlist): hide event if username is unknown * chore: use npm install instead of ci * chore: remove incorrect default values keys * chore: add spacebetween attr * chore: package update * chore: downgrade to npm8 npm/cli#5889 * fix(validate): update broadcaster type on forced validation * chore: add eventlist overlay font support * chore: add more attributes to eventlist * chore: add space between * chore: add eventlist fadeout * feat: add ui-admin and ui-overlay to packages dir * chore: update ui-admin * fix: command of docker.sh to run with debug mode * fix: migration of hltbtimestamps * feat: update packages and add patchs * feat: add discord ban user integration * fix: get user to check is moderator * feat: improve embed message of banned user * fix: add help of ban command to reply user * fix: remove missed spaced on command ban * feat: add discord slash commands * fix: add moderator discord announce channel * fix: add catch error of linked account on user slash commands * feat: add discord attachment to ban slash command * feat: add discord timeout slash command * ci: customize docker image on gh actions * fix: add command timeout trigger fn * feat: add choices do timeout duration * discord: add ban user modal and confirm * chore: update dependencies * build: 15.5.0-SNAPSHOT * fix(entity): expand varchar to 30 chars to handle more precise dates (sogebot#5390) * chore(locales): crowdin update (sogebot#5391) Co-authored-by: Crowdin Bot <[email protected]> * chore: remove retyping in migration as it is not needed * chore: remove not needed sqlite migration * fix(entity): expand varchar to 30 chars to handle more precise dates (sogebot#5390) * feat: update OBS Websocket to version 5 (sogebot#5396) BREAKING CHANGE: This will work only with OBS +28, also we needed to remove simple tasks and only coding with OBS websockets are allowed * feat: add Price validation and rest access * feat: remove followers permission (sogebot#5400) BREAKING CHANGE: followers permissions are not supported anymore. Instead consider use of viewers permission or subscriber permission. We are not tracking follower status anymore, every follower based permissions, etc. were deleted. * chore(locales): crowdin update (sogebot#5401) Co-authored-by: Crowdin Bot <[email protected]> * chore: fix incorrect obs call * chore: set obswebsocket to wss by default * chore: remove protocol * chore: update dependency * chore: add missing wss * fix(updater): don't crash bot if ui is being updated * resolve migration values structure * chore: some updates from master branch * fix: add packages to makefile * fix: add builder stage to dockerfile * fix: timerAttrChange migration * fix: remove npm cache clean * fix: add compatibility to postgres 14 date * fix: remove always compact * fix: remove ui's patch packages * fix: generate default uuid with node uuid package * ci: add luacomtio branch to trigger pipelines * ci: improve build-and-push speed by remove unused platforms * fix: remove copying of .env files on pack * feat: add to docker-compose nginx and certbot * fix: add depends on to nginx docker-compose service step * fix: update custom variables migration order of operations * fix: use generated id instead default * fix: remove default v4 uuid --------- Co-authored-by: Michal Orlik <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Crowdin Bot <[email protected]> fix(discord): remove commands and use only one to ban and timeout
1 parent 5f307e5 commit 22b22e8

File tree

9 files changed

+560
-66
lines changed

9 files changed

+560
-66
lines changed

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: "CodeQL"
22

33
on:
44
push:
5-
branches: [ "master" ]
5+
branches: [ "master", "luacomtio" ]
66
pull_request:
77
branches: [ "master" ]
88
schedule:

.github/workflows/dockerimage-release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ jobs:
4141

4242
- uses: actions/upload-artifact@v3
4343
with:
44-
name: sogeBot
44+
name: luacomtio-sogeBot
4545
path: ${{ github.workspace }}/*.zip
4646

4747
- name: Create Release
4848
uses: ncipollo/release-action@v1
4949
with:
50-
name: SOGEBOT ${{ github.ref_name }}
50+
name: LUACOMTIO ${{ github.ref_name }}
5151
artifacts: "*.zip"
5252
bodyFile: "body.md"
5353
makeLatest: true
@@ -79,18 +79,18 @@ jobs:
7979

8080
- uses: actions/download-artifact@master
8181
with:
82-
name: sogeBot
82+
name: luacomtio-sogeBot
8383
path: ${{ github.workspace }}/*.zip
8484

8585
-
8686
name: Build and push
8787
uses: docker/build-push-action@v3
8888
with:
8989
context: .
90-
platforms: linux/amd64,linux/arm/v7,linux/arm64
90+
platforms: linux/amd64 #,linux/arm/v7,linux/arm64
9191
push: true
9292
tags: |
93-
sogebot/release:latest
94-
sogebot/release:${{ steps.get_version.outputs.VERSION }}
93+
omurilo/luacomtio-bot:latest
94+
omurilo/luacomtio-bot:${{ steps.get_version.outputs.VERSION }}
9595
cache-from: type=gha
9696
cache-to: type=gha,mode=max

.github/workflows/dockerimage.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
push:
99
branches:
1010
- master
11+
- luacomtio
1112

1213
jobs:
1314
artifact:
@@ -43,7 +44,7 @@ jobs:
4344

4445
- uses: actions/upload-artifact@v3
4546
with:
46-
name: sogeBot-${{ steps.slug.outputs.SHA }}
47+
name: luacomtio-bot-${{ steps.slug.outputs.SHA }}
4748
path: ${{ github.workspace }}/*.zip
4849

4950
build:
@@ -72,7 +73,7 @@ jobs:
7273

7374
- uses: actions/download-artifact@master
7475
with:
75-
name: sogeBot-${{ steps.slug.outputs.SHA }}
76+
name: luacomtio-bot-${{ steps.slug.outputs.SHA }}
7677
path: ${{ github.workspace }}/*.zip
7778

7879
-
@@ -83,7 +84,7 @@ jobs:
8384
platforms: linux/amd64,linux/arm/v7,linux/arm64
8485
push: true
8586
tags: |
86-
sogebot/nightly:latest
87-
sogebot/nightly:${{ github.sha }}
88-
cache-from: type=gha
87+
omurilo/luacomtio-bot-nightly:latest
88+
omurilo/luacomtio-bot-nightly:${{ github.sha }}
89+
cache-from: type=gha
8990
cache-to: type=gha,mode=max

.github/workflows/tests-postgres.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
push:
99
branches:
1010
- 'master'
11+
- 'luacomtio'
1112
pull_request:
1213

1314
jobs:

Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ endif
4444
@npx tsc-alias
4545

4646
pack:
47-
@echo -ne "\n\t ----- Packing into sogeBot-$(VERSION).zip\n"
48-
@cp ./src/data/.env* ./
49-
@cp ./src/data/.env.sqlite ./.env
50-
@npx --yes bestzip sogeBot-$(VERSION).zip .commit .npmrc .env* package-lock.json patches/ dest/ locales/ LICENSE package.json docs/ AUTHORS tools/ bin/ bat/ fonts.json assets/ favicon.ico
47+
@echo -ne "\n\t ----- Packing into luacomtio-bot-$(VERSION).zip\n"
48+
@npx --yes bestzip luacomtio-bot-$(VERSION).zip .npmrc package-lock.json patches/ dest/ locales/ LICENSE package.json docs/ AUTHORS tools/ bin/ bat/ fonts.json assets/ favicon.ico
5149

5250
prepare:
5351
@echo -ne "\n\t ----- Cleaning up node_modules\n"
@@ -56,4 +54,4 @@ prepare:
5654
clean:
5755
@echo -ne "\n\t ----- Cleaning up compiled files\n"
5856
@rm -rf public/dist/bootstrap* public/dist/carousel/* public/dist/gallery/* public/dist/jquery public/dist/lodash public/dist/velocity-animate public/dist/popper.js public/dist/flv.js
59-
@rm -rf dest
57+
@rm -rf dest

docker-compose.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
version: "3.2"
2+
3+
services:
4+
nginx:
5+
image: nginx:1.15-alpine
6+
ports:
7+
- "80:80"
8+
- "443:443"
9+
volumes:
10+
- ../proxy/nginx:/etc/nginx/conf.d
11+
- ../proxy/certbot/conf:/etc/letsencrypt
12+
- ../proxy/certbot/www:/var/www/certbot
13+
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
14+
depends_on:
15+
- sogebot
16+
- certbot
17+
- pgadmin
18+
19+
certbot:
20+
image: certbot/certbot
21+
volumes:
22+
- ../proxy/certbot/conf:/etc/letsencrypt
23+
- ../proxy/certbot/www:/var/www/certbot
24+
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
25+
26+
sogebot:
27+
image: omurilo/luacomtio-bot:latest
28+
restart: always
29+
volumes:
30+
- $PWD/shared:/app/shared/
31+
- $PWD/logs:/app/logs/
32+
ports:
33+
- 20000:20000 # change your output port
34+
# - 443:20443
35+
- 9229:9229 # uncomment to use --inspect port
36+
env_file:
37+
- ./.env
38+
environment:
39+
# ensure locale exists in container, you may need to install it
40+
LANG: pt_BR.UTF-8
41+
NODE_OPTIONS: --max_old_space_size=1024 # uncomment to set max 4GB RAM usage (default 2GB)
42+
#PROFILER: y # uncomment to enable --inspect
43+
depends_on:
44+
- db
45+
46+
db:
47+
image: postgres
48+
restart: always
49+
ports:
50+
- 5432:5432
51+
env_file:
52+
- ./.env
53+
environment:
54+
POSTGRES_PASSWORD: ${TYPEORM_PASSWORD}
55+
POSTGRES_USER: ${TYPEORM_USERNAME}
56+
POSTGRES_DB: ${TYPEORM_DATABASE}
57+
volumes:
58+
- pgdata:/var/lib/postgresql/data
59+
60+
pgadmin:
61+
image: dpage/pgadmin4
62+
restart: always
63+
ports:
64+
- 8080:80
65+
env_file:
66+
- ./.env
67+
environment:
68+
PGADMIN_DEFAULT_EMAIL: ${PG_ADMIN_EMAIL}
69+
PGADMIN_DEFAULT_PASSWORD: ${PG_ADMIN_PSSWD}
70+
PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION: 'True'
71+
PGADMIN_CONFIG_LOGIN_BANNER: '"Authorized users only!"'
72+
PGADMIN_CONFIG_CONSOLE_LOG_LEVEL: 10
73+
depends_on:
74+
- db
75+
76+
volumes:
77+
pgdata:

src/expects.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ class Expects {
113113
+ (param.opts.optional ? ']' : ''),
114114
);
115115
break;
116+
case 'reason':
117+
expectedParameters.push(
118+
(param.opts.optional ? '[' : '')
119+
+ `<reason>`
120+
+ (param.opts.optional ? ']' : ''),
121+
);
122+
break;
116123
case 'argument':
117124
expectedParameters.push(
118125
(param.opts.optional ? '[' : '')
@@ -440,7 +447,7 @@ class Expects {
440447
this.checkText();
441448
}
442449

443-
const regexp = XRegExp(`@?(?<username>[A-Za-z0-9_]+)`, 'ix');
450+
const regexp = XRegExp(`${opts.prefix ?? ''}@?(?<username>[A-Za-z0-9_]+)`, 'ix');
444451
const match = XRegExp.exec(`${this.text}`, regexp);
445452
if (match && match.groups) {
446453
this.match.push(match.groups.username.toLowerCase());
@@ -612,6 +619,34 @@ class Expects {
612619
}
613620
return this;
614621
}
622+
623+
reason (opts?: any) {
624+
opts = opts || {};
625+
defaults(opts, {
626+
exec: false, optional: false, default: null,
627+
});
628+
if (!opts.exec) {
629+
this.toExec.push({ fnc: 'reason', opts });
630+
return this;
631+
}
632+
if (!opts.optional) {
633+
this.checkText();
634+
}
635+
636+
const regexp = XRegExp(`${opts.prefix ?? ''}(?<reason>.+)`, 'ix');
637+
const match = XRegExp.exec(`${this.text}`, regexp);
638+
if (match && match.groups) {
639+
this.match.push(match.groups.reason.toLowerCase());
640+
this.text = this.text.replace(match.groups.reason, ''); // remove from text matched pattern
641+
} else {
642+
if (!opts.optional) {
643+
throw new ParameterError('Reason not found');
644+
} else {
645+
this.match.push(opts.default);
646+
}
647+
}
648+
return this;
649+
}
615650
}
616651

617652
module.exports = Expects;

src/helpers/commons/announce.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { variables } from '~/watchers';
1212
*
1313
* announce('Lorem Ipsum Dolor', 'timers);
1414
*/
15-
export const announceTypes = ['bets', 'duel', 'heist', 'timers', 'songs', 'scrim', 'raffles', 'polls', 'general'] as const;
15+
export const announceTypes = ['bets', 'duel', 'heist', 'timers', 'songs', 'scrim', 'raffles', 'polls', 'general', 'moderator'] as const;
1616
export async function announce(messageToAnnounce: string, type: typeof announceTypes[number], replaceCustomVariables = true) {
1717
const botUsername = variables.get('services.twitch.botUsername') as string;
1818
const botId = variables.get('services.twitch.botId') as string;
@@ -39,4 +39,4 @@ export async function announce(messageToAnnounce: string, type: typeof announceT
3939
}
4040
}
4141
}
42-
}
42+
}

0 commit comments

Comments
 (0)