This repository has been archived by the owner on May 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
169 additions
and
3,354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const Command = require('./Command'); | ||
const CommandResponse = require('./CommandResponse'); | ||
const TwitchConnectorIO = require('../Connector/TwitchConnectorIO'); | ||
|
||
module.exports = class UsersCommand extends Command { | ||
constructor (logger) { | ||
super('mods', logger); | ||
} | ||
|
||
usage () { | ||
return `${this.name}`; | ||
} | ||
|
||
validate (commandExchange) { | ||
return commandExchange.args._.length === 0; | ||
} | ||
|
||
getAvailableConnectors () { | ||
return [TwitchConnectorIO]; | ||
} | ||
|
||
async handle (commandExchange) { | ||
this.logger.info('received'); | ||
|
||
const chatters = await commandExchange.connector.getChatters().catch(err => { | ||
this.logger.error(`failed to get chatters : ${err}`); | ||
}); | ||
|
||
let response = ''; | ||
if (chatters && chatters.moderators) { | ||
response = chatters.moderators.join('\n'); | ||
} else { | ||
response = "La liste des modos n'est pas disponible."; | ||
} | ||
|
||
commandExchange.connector.write( | ||
new CommandResponse( | ||
response, | ||
'whisper', | ||
commandExchange.context.userstate.username, | ||
commandExchange.context | ||
) | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const Command = require('./Command'); | ||
const CommandResponse = require('./CommandResponse'); | ||
const TwitchConnectorIO = require('../Connector/TwitchConnectorIO'); | ||
const moment = require('moment'); | ||
|
||
module.exports = class UptimeCommand extends Command { | ||
constructor (logger) { | ||
super('uptime', logger); | ||
} | ||
|
||
usage () { | ||
return `${this.name}`; | ||
} | ||
|
||
validate (commandExchange) { | ||
return commandExchange.args._.length === 0; | ||
} | ||
|
||
getAvailableConnectors () { | ||
return [TwitchConnectorIO]; | ||
} | ||
|
||
async handle (commandExchange) { | ||
this.logger.info('received'); | ||
|
||
const streamInfo = await commandExchange.connector.getStreamInfo(process.env.TWITCH_CHANNEL_ID).catch(err => { | ||
this.logger.error(`failed to get stream info : ${err}`); | ||
}); | ||
|
||
let response = ''; | ||
if (streamInfo && streamInfo.started_at) { | ||
const milliseconds = moment(new Date()).valueOf() - moment(streamInfo.started_at).valueOf(); | ||
response = `${Math.round(milliseconds / 1000 / 60)} minutes`; | ||
} else { | ||
response = "L'uptime n'est pas disponible."; | ||
} | ||
|
||
commandExchange.connector.write( | ||
new CommandResponse( | ||
response, | ||
commandExchange.sourceType, | ||
commandExchange.recipient, | ||
commandExchange.context | ||
) | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const Command = require('./Command'); | ||
const CommandResponse = require('./CommandResponse'); | ||
const TwitchConnectorIO = require('../Connector/TwitchConnectorIO'); | ||
|
||
module.exports = class UsersCommand extends Command { | ||
constructor (logger) { | ||
super('users', logger); | ||
} | ||
|
||
usage () { | ||
return `${this.name}`; | ||
} | ||
|
||
validate (commandExchange) { | ||
return commandExchange.args._.length === 0; | ||
} | ||
|
||
getAvailableConnectors () { | ||
return [TwitchConnectorIO]; | ||
} | ||
|
||
async handle (commandExchange) { | ||
this.logger.info('received'); | ||
|
||
const chatters = await commandExchange.connector.getChatters().catch(err => { | ||
this.logger.error(`failed to get chatters : ${err}`); | ||
}); | ||
|
||
let response = ''; | ||
if (chatters && chatters.viewers) { | ||
response = chatters.viewers.join('\n'); | ||
} else { | ||
response = "La liste des viewers n'est pas disponible."; | ||
} | ||
|
||
commandExchange.connector.write( | ||
new CommandResponse( | ||
response, | ||
'whisper', | ||
commandExchange.context.userstate.username, | ||
commandExchange.context | ||
) | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.