Skip to content

Commit 68db2e6

Browse files
committed
fix permit command to actually work
1 parent d829f20 commit 68db2e6

2 files changed

Lines changed: 31 additions & 16 deletions

File tree

src/bot/bot.ts

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,21 +200,21 @@ export class Bot {
200200
const eventSub =
201201
process.env.NODE_ENV === 'development'
202202
? new EventSubHttpListener({
203-
apiClient: apiClient,
204-
adapter: new NgrokAdapter({
205-
ngrokConfig: {
206-
authtoken: process.env.NGROK_AUTH_TOKEN ?? '',
207-
},
208-
}),
209-
logger: { minLevel: 'debug' },
210-
secret:
211-
process.env.EVENTSUB_SECRET ??
212-
'thisShouldBeARandomlyGeneratedFixedString',
213-
})
203+
apiClient: apiClient,
204+
adapter: new NgrokAdapter({
205+
ngrokConfig: {
206+
authtoken: process.env.NGROK_AUTH_TOKEN ?? '',
207+
},
208+
}),
209+
logger: { minLevel: 'debug' },
210+
secret:
211+
process.env.EVENTSUB_SECRET ??
212+
'thisShouldBeARandomlyGeneratedFixedString',
213+
})
214214
: new EventSubWsListener({
215-
apiClient: apiClient,
216-
logger: { minLevel: 'info' },
217-
})
215+
apiClient: apiClient,
216+
logger: { minLevel: 'info' },
217+
})
218218

219219
return new Bot(chatClient, authProvider, apiClient, eventSub)
220220
}
@@ -330,8 +330,17 @@ export class Bot {
330330
command.execute(event, commandNames, this.apiClient)
331331
break
332332
case 'permit':
333+
// if not a broadcaster or mod, do nothing
334+
if (!isMod && !isBroadcaster) {
335+
return
336+
}
337+
333338
// add to permit list ahead of time
334-
const username = args[0]
339+
let username = args[0]
340+
if (username.startsWith('@')) {
341+
username = username.slice(1)
342+
args[0] = username
343+
}
335344
const permitId = setTimeout(() => {
336345
this.permitList.delete(username)
337346
log.bot.info(`Removed ${username} from permit list`)
@@ -394,7 +403,12 @@ export class Bot {
394403
isBot,
395404
)
396405
} else if (findUrl(event.messageText).length > 0) {
397-
if (isBroadcaster || isMod || isBot) {
406+
if (
407+
isBroadcaster ||
408+
isMod ||
409+
isBot ||
410+
this.permitList.has(authorInfo.displayName)
411+
) {
398412
return
399413
}
400414

src/bot/commands/permit.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const permit: Command = {
1010
event.chatterId,
1111
)
1212
const isBroadcaster = event.chatterId === process.env.TWITCH_ID
13+
// by this point this shouldn't fire but just in case, we have a second check
1314
if (!isMod && !isBroadcaster) {
1415
return
1516
}

0 commit comments

Comments
 (0)