Skip to content

Commit

Permalink
fix: No more "hello" matches or non-emote matches.
Browse files Browse the repository at this point in the history
  • Loading branch information
KararTY committed Aug 17, 2021
1 parent 6cd6c60 commit b4b1bc4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/Handlers/RollMatchHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default class RollMatchHandler extends DefaultHandler {
const foundUserRoll = this.twitch.getUserInstance(msg)

if (foundUserRoll !== undefined) {
await this.twitch.sendWhisper(responseMessage.userTwitch, this.i18n(this.messagesText.alreadyRolling))
return
}

Expand Down Expand Up @@ -64,26 +65,14 @@ export async function matchText ({ channelTwitch, userTwitch }: ROLLMATCH, { log
return
}

if (foundUserRoll.type === foundUserRoll.lastType) {
twitch.sendMessage(channelTwitch, userTwitch, i18n(this.messagesText.ood))
return
}

const { profile, user } = foundUserRoll.data

// Skip some stuff if user doesn't define anything.
if (profile.bio === 'Hello!') {
foundUserRoll.type = More.FAVORITEEMOTES
}

if (foundUserRoll.type === More.BIO && profile.bio.length < 32) {
if (foundUserRoll.type === More.BIO && profile.bio.length < 33) {
foundUserRoll.type = More.FAVORITEEMOTES
}

if (foundUserRoll.type === More.FAVORITEEMOTES && profile.favorite_emotes.length === 0) {
foundUserRoll.type = More.FAVORITESTREAMERS
}

const emotes = await getEmotes()
const bio = profile.bio.split(' ').map(word => emotes.findIndex(ee => ee.name === word) > -1 ? word : noPingsStr(word)).join(' ')

Expand Down Expand Up @@ -112,6 +101,11 @@ export async function matchText ({ channelTwitch, userTwitch }: ROLLMATCH, { log
message += ` ${firstTimeText}`
}

if (foundUserRoll.type === foundUserRoll.lastType) {
twitch.sendMessage(channelTwitch, userTwitch, i18n(this.messagesText.ood))
return
}

foundUserRoll.nextType()

twitch.setUserInstance({
Expand Down
1 change: 1 addition & 0 deletions src/messagesText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const messagesText = {
alreadyRegistered: 'You\'re already registered! You can now peruse the bot and website.',
whispersOnly: 'this command can only be used via whispers!',
ood: 'that\'s all that\'s written.',
alreadyRolling: 'you\'re already rolling for a match! Reply with %prefix%more, %prefix%match, %prefix%no',
helpText: {
help: 'rubber ducky 🦆 Never lucky.',
emotes: 'sets your favorite emotes for your profile. Add "global" in the beginning to change your global profile\'s bio. Only Twitch emotes work for now.',
Expand Down

0 comments on commit b4b1bc4

Please sign in to comment.