Skip to content

Commit

Permalink
feat(discord): add slash commands to ban/timeout users of twitch from…
Browse files Browse the repository at this point in the history
… 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

fix: modify tmiEmitter.emit timeout ismod
  • Loading branch information
Murilo Alves committed Mar 28, 2023
1 parent 5f307e5 commit b63efc9
Show file tree
Hide file tree
Showing 9 changed files with 581 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "CodeQL"

on:
push:
branches: [ "master" ]
branches: [ "master", "luacomtio" ]
pull_request:
branches: [ "master" ]
schedule:
Expand Down
34 changes: 27 additions & 7 deletions .github/workflows/dockerimage-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ jobs:

- uses: actions/upload-artifact@v3
with:
name: sogeBot
name: luacomtio-sogeBot
path: ${{ github.workspace }}/*.zip

- name: Create Release
uses: ncipollo/release-action@v1
with:
name: SOGEBOT ${{ github.ref_name }}
name: LUACOMTIO ${{ github.ref_name }}
artifacts: "*.zip"
bodyFile: "body.md"
makeLatest: true
Expand Down Expand Up @@ -79,18 +79,38 @@ jobs:

- uses: actions/download-artifact@master
with:
name: sogeBot
name: luacomtio-sogeBot
path: ${{ github.workspace }}/*.zip

-
name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64
# platforms: linux/amd64 #,linux/arm/v7,linux/arm64
push: true
tags: |
sogebot/release:latest
sogebot/release:${{ steps.get_version.outputs.VERSION }}
omurilo/luacomtio-bot:latest
omurilo/luacomtio-bot:${{ steps.get_version.outputs.VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max

deployment:
needs: build
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using password
uses: appleboy/[email protected]
with:
host: ${{ secrets.DIGITALOCEAN_HOST }}
username: ${{ secrets.DIGITALOCEAN_USERNAME }}
key: ${{ secrets.DIGITALOCEAN_PRIV_KEY }}
port: ${{ secrets.DIGITALOCEAN_PORT }}
passphrase: ${{ secrets.PASSPHRASE }}
script: |
cd sogebot
docker pull omurilo/luacomtio-bot:latest
docker-compose down
docker-compose up -d
sleep 150
docker-compose logs sogebot
11 changes: 6 additions & 5 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
push:
branches:
- master
- luacomtio

jobs:
artifact:
Expand Down Expand Up @@ -43,7 +44,7 @@ jobs:

- uses: actions/upload-artifact@v3
with:
name: sogeBot-${{ steps.slug.outputs.SHA }}
name: luacomtio-bot-${{ steps.slug.outputs.SHA }}
path: ${{ github.workspace }}/*.zip

build:
Expand Down Expand Up @@ -72,7 +73,7 @@ jobs:

- uses: actions/download-artifact@master
with:
name: sogeBot-${{ steps.slug.outputs.SHA }}
name: luacomtio-bot-${{ steps.slug.outputs.SHA }}
path: ${{ github.workspace }}/*.zip

-
Expand All @@ -83,7 +84,7 @@ jobs:
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
tags: |
sogebot/nightly:latest
sogebot/nightly:${{ github.sha }}
cache-from: type=gha
omurilo/luacomtio-bot-nightly:latest
omurilo/luacomtio-bot-nightly:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
1 change: 1 addition & 0 deletions .github/workflows/tests-postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
push:
branches:
- 'master'
- 'luacomtio'
pull_request:

jobs:
Expand Down
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ endif
@npx tsc-alias

pack:
@echo -ne "\n\t ----- Packing into sogeBot-$(VERSION).zip\n"
@cp ./src/data/.env* ./
@cp ./src/data/.env.sqlite ./.env
@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
@echo -ne "\n\t ----- Packing into luacomtio-bot-$(VERSION).zip\n"
@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

prepare:
@echo -ne "\n\t ----- Cleaning up node_modules\n"
Expand All @@ -56,4 +54,4 @@ prepare:
clean:
@echo -ne "\n\t ----- Cleaning up compiled files\n"
@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
@rm -rf dest
@rm -rf dest
77 changes: 77 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
version: "3.2"

services:
nginx:
image: nginx:1.15-alpine
ports:
- "80:80"
- "443:443"
volumes:
- ../proxy/nginx:/etc/nginx/conf.d
- ../proxy/certbot/conf:/etc/letsencrypt
- ../proxy/certbot/www:/var/www/certbot
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
depends_on:
- sogebot
- certbot
- pgadmin

certbot:
image: certbot/certbot
volumes:
- ../proxy/certbot/conf:/etc/letsencrypt
- ../proxy/certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"

sogebot:
image: omurilo/luacomtio-bot:latest
restart: always
volumes:
- $PWD/shared:/app/shared/
- $PWD/logs:/app/logs/
ports:
- 20000:20000 # change your output port
# - 443:20443
- 9229:9229 # uncomment to use --inspect port
env_file:
- ./.env
environment:
# ensure locale exists in container, you may need to install it
LANG: pt_BR.UTF-8
NODE_OPTIONS: --max_old_space_size=1024 # uncomment to set max 4GB RAM usage (default 2GB)
#PROFILER: y # uncomment to enable --inspect
depends_on:
- db

db:
image: postgres
restart: always
ports:
- 5432:5432
env_file:
- ./.env
environment:
POSTGRES_PASSWORD: ${TYPEORM_PASSWORD}
POSTGRES_USER: ${TYPEORM_USERNAME}
POSTGRES_DB: ${TYPEORM_DATABASE}
volumes:
- pgdata:/var/lib/postgresql/data

pgadmin:
image: dpage/pgadmin4
restart: always
ports:
- 8080:80
env_file:
- ./.env
environment:
PGADMIN_DEFAULT_EMAIL: ${PG_ADMIN_EMAIL}
PGADMIN_DEFAULT_PASSWORD: ${PG_ADMIN_PSSWD}
PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION: 'True'
PGADMIN_CONFIG_LOGIN_BANNER: '"Authorized users only!"'
PGADMIN_CONFIG_CONSOLE_LOG_LEVEL: 10
depends_on:
- db

volumes:
pgdata:
37 changes: 36 additions & 1 deletion src/expects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ class Expects {
+ (param.opts.optional ? ']' : ''),
);
break;
case 'reason':
expectedParameters.push(
(param.opts.optional ? '[' : '')
+ `<reason>`
+ (param.opts.optional ? ']' : ''),
);
break;
case 'argument':
expectedParameters.push(
(param.opts.optional ? '[' : '')
Expand Down Expand Up @@ -440,7 +447,7 @@ class Expects {
this.checkText();
}

const regexp = XRegExp(`@?(?<username>[A-Za-z0-9_]+)`, 'ix');
const regexp = XRegExp(`${opts.prefix ?? ''}@?(?<username>[A-Za-z0-9_]+)`, 'ix');
const match = XRegExp.exec(`${this.text}`, regexp);
if (match && match.groups) {
this.match.push(match.groups.username.toLowerCase());
Expand Down Expand Up @@ -612,6 +619,34 @@ class Expects {
}
return this;
}

reason (opts?: any) {
opts = opts || {};
defaults(opts, {
exec: false, optional: false, default: null,
});
if (!opts.exec) {
this.toExec.push({ fnc: 'reason', opts });
return this;
}
if (!opts.optional) {
this.checkText();
}

const regexp = XRegExp(`${opts.prefix ?? ''}(?<reason>.+)`, 'ix');
const match = XRegExp.exec(`${this.text}`, regexp);
if (match && match.groups) {
this.match.push(match.groups.reason.toLowerCase());
this.text = this.text.replace(match.groups.reason, ''); // remove from text matched pattern
} else {
if (!opts.optional) {
throw new ParameterError('Reason not found');
} else {
this.match.push(opts.default);
}
}
return this;
}
}

module.exports = Expects;
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/commons/announce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { variables } from '~/watchers';
*
* announce('Lorem Ipsum Dolor', 'timers);
*/
export const announceTypes = ['bets', 'duel', 'heist', 'timers', 'songs', 'scrim', 'raffles', 'polls', 'general'] as const;
export const announceTypes = ['bets', 'duel', 'heist', 'timers', 'songs', 'scrim', 'raffles', 'polls', 'general', 'moderator'] as const;
export async function announce(messageToAnnounce: string, type: typeof announceTypes[number], replaceCustomVariables = true) {
const botUsername = variables.get('services.twitch.botUsername') as string;
const botId = variables.get('services.twitch.botId') as string;
Expand All @@ -39,4 +39,4 @@ export async function announce(messageToAnnounce: string, type: typeof announceT
}
}
}
}
}
Loading

0 comments on commit b63efc9

Please sign in to comment.