Skip to content

Commit

Permalink
add eventsubs
Browse files Browse the repository at this point in the history
  • Loading branch information
lluisd committed Oct 17, 2024
1 parent de28035 commit b074a81
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
1 change: 0 additions & 1 deletion db.openai.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const mongoose = require("mongoose");
const config = require('./config')


class Mongo {
constructor() {
this.connection = null
Expand Down
53 changes: 45 additions & 8 deletions lib/eventSub.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ class EventSub {
})
}

getMiddleware () {
return this.middleware
}

apply (app) {
this.middleware.apply(app)
}
Expand All @@ -30,13 +26,54 @@ class EventSub {
async subscribeEvent (channelId) {
this.middleware.onChannelFollow(channelId, config.twitch.userId, event => {
console.log(`${event.userDisplayName} just followed ${event.broadcasterDisplayName}!`);
this.bot.say(`#${config.twitch.channels}`, `Gracias por seguirnos ${event.userDisplayName}!`)
});
this.bot.say(`#${config.twitch.channels}`, `Gracias por seguirnos @${event.userDisplayName}!`)
})

this.middleware.onChannelRedemptionAddForReward(channelId, "427b3e63-e6cd-4d36-8954-9c7198af0a1d", event => {
console.log(`${event.userDisplayName} ha canjeado ${event.rewardTitle}!`);
this.bot.say(`#${config.twitch.channels}`, `${event.userDisplayName} ha canjeado ${event.rewardTitle}!`)
});
this.bot.say(`#${config.twitch.channels}`, `@${event.userDisplayName} ha canjeado ${event.rewardTitle}!`)
})

this.middleware.onChannelSubscription(channelId, event => {
console.log(`${event.userDisplayName} just subscribed to ${event.broadcasterDisplayName}!`);
if (!event.isGift) {
this.bot.say(`#${config.twitch.channels}`, `@${event.userDisplayName} se ha suscrito!`)
}
})

this.middleware.onChannelSubscriptionGift(channelId, event => {
console.log(`${event.userDisplayName} just subscribed to ${event.broadcasterDisplayName}!`);
this.bot.say(`#${config.twitch.channels}`, `@${event.gifterDisplayName} ha regalado ${event.amount} subs!`)
})

this.middleware.onChannelRaidTo(channelId, event => {
console.log(`${event.raidingBroadcasterDisplayName} raided to the channel with ${event.viewers} viewers!`);
this.bot.say(`#${config.twitch.channels}`, `Raid con ${event.viewers} viewers de @${event.raidingBroadcasterDisplayName}!`)
})

this.middleware.onChannelRaidFrom(channelId, event => {
console.log(`${event.raidedBroadcasterDisplayName} raiding with ${event.viewers} viewers!`);
this.bot.say(`#${config.twitch.channels}`, `Raid a @${event.raidedBroadcasterDisplayName}!`)
})

this.middleware.onChannelRaidFrom(channelId, event => {
console.log(`${event.raidedBroadcasterDisplayName} raiding with ${event.viewers} viewers!`);
this.bot.say(`#${config.twitch.channels}`, `Raid a @${event.raidedBroadcasterDisplayName}!`)
})

this.middleware.onChannelBan(channelId, event => {
console.log(`${event.moderatorDisplayName} banned ${event.userDisplayName}!`);
if (event.isPermanent) {
this.bot.say(`#${config.twitch.channels}`, `@${event.userDisplayName} ha mordido el polvo!`)
} else {
this.bot.say(`#${config.twitch.channels}`, `Timeout para que @${event.userDisplayName} se calme!`)
}
})

this.middleware.onChannelPollBegin(channelId, event => {
console.log(`Poll ${event.title} has started!`);
this.bot.say(`#${config.twitch.channels}`, `Encuesta iniciada: ${event.title}, vota!`)
})
}
}

Expand Down

0 comments on commit b074a81

Please sign in to comment.