Skip to content

Commit e9ec25f

Browse files
committed
Merge branch 'v1.3.x' of github.com:EllenFawkes/PurrplingBot into v1.3.x
2 parents 38cf650 + 1df39d7 commit e9ec25f

6 files changed

Lines changed: 36 additions & 13 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ A discordbot written primary for server PurrplingCat
88

99
### Regular download
1010

11-
* Latest stable version 1.3.0: [Release v1.3.0 'Carmilla'](https://github.com/EllenFawkes/PurrplingBot/releases/tag/1.3.0)
11+
* Latest stable version 1.3.2: [Release v1.3.2 'Carmilla'](https://github.com/EllenFawkes/PurrplingBot/releases/tag/1.3.2)
1212
* Develop version: `git clone https://github.com/EllenFawkes/PurrplingBot.git`
1313

1414
### Get image from DockerHub
1515

1616
```bash
17-
docker pull purrplingcat/purrplingbot:1.3.0 # Latest stable version 1.3.0 'Carmilla'
17+
docker pull purrplingcat/purrplingbot:1.3.2 # Latest stable version 1.3.2 'Carmilla'
1818
docker pull purrplingcat/purrplingbot:latest # Latest development version
1919
```
2020

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "purrplingbot",
3-
"version": "1.3.1-dev",
3+
"version": "1.3.2",
44
"codename": "Carmilla",
55
"description": "A discordbot written primary for server PurrplingCat",
66
"main": "purrplingbot.js",

plugins/Announcer/announcer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ purrplingBot.on('message', function(message){
5656
if (message.author.id == bot.user.id) return;
5757
let antispam = announcerConf.antispam || true;
5858
if (antispam) {
59-
repeater.processQueue();
59+
repeater.processQueue(message.channel);
6060
}
6161
});
6262

@@ -126,7 +126,7 @@ function cancelAnnounce(name) {
126126
}
127127
}
128128

129-
function resumeAnnounce(name, interval) {
129+
function resumeAnnounce(name, interval, neverHandledFlag = false) {
130130
var announce = announces[name];
131131
if (!announce) {
132132
logger.info(`Announce '${name}' not exists - Can't resume!`);
@@ -151,7 +151,7 @@ function resumeAnnounce(name, interval) {
151151
var runner = bot.setInterval(handleAnnounce, duration, name, INTERVAL_TRIGGER);
152152
announceRunners[name] = runner;
153153
announce.active = true;
154-
announce.neverHandled = true;
154+
if (neverHandledFlag) announce.neverHandled = true;
155155
purrplingBot.logEvent(`Resumed announce '${announce.name}', Interval: ${announce.interval}, NeverHandled: ${announce.neverHandled}`, "Announce:Resume");
156156
logger.info(`Resumed announce: ${announce.name} (Interval: ${announce.interval})`);
157157
return announce;
@@ -272,7 +272,7 @@ function execSubCommand(scmd, args, message) {
272272
}
273273
var name = args[0];
274274
var interval = args[1];
275-
var announce = resumeAnnounce(name, interval);
275+
var announce = resumeAnnounce(name, interval, true);
276276
if (!announce) {
277277
message.reply(`Can't resume Announce '${name}' - Unknown error`)
278278
.catch(logger.error);

plugins/Announcer/repeater.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Repeater extends EventEmiter {
3737
return this;
3838
}
3939

40-
processQueue() {
40+
processQueue(channel) {
4141
if (!this.options.enabled) {
4242
this._logger.log("Repeater is DISABLED!");
4343
return;
@@ -53,12 +53,17 @@ class Repeater extends EventEmiter {
5353
let announce = this.announces[announceName];
5454
let expires = durationParse(announce.interval) * this.options.expirePercentTime || 0.25;
5555
if ((currentTime.getTime() - announce.lastTry.getTime() < expires)) {
56-
queue.push(announce);
56+
if (announce.channel == channel.id) {
57+
queue.push(announce);
58+
this._queue.splice(this._queue.indexOf(announceName));
59+
}
5760
this._logger.log("Added %s to process queue", announce.name);
58-
} else this._logger.log("%s expired - Not added to queue", announce.name);
61+
} else {
62+
this._logger.log("%s expired - Not added to queue", announce.name);
63+
this._queue.splice(this._queue.indexOf(announceName));
64+
}
5965
this.emit('process', announce, queue);
6066
});
61-
this._queue = [];
6267
setTimeout(_repeatAnnounce, durationParse(this.options.handleWait || "5m"), queue, this);
6368
this._logger.info("Repeater started! Announces in queue: ", queue.length);
6469
return queue;

plugins/Nextstream/nextstream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function streamLiveNowAnnounce() {
6868
} else {
6969
logger.error("An error occured while fetching stream status! %s", error);
7070
logger.dir(body);
71-
PurrplingBot.logEvent("An error occured while fetching stream status! Status code: " + response.statusCode, "StreamCheck", "ERROR");
71+
PurrplingBot.logEvent("An error occured while fetching stream status! " + error, "StreamCheck", "ERROR");
7272
}
7373
});
7474
}

plugins/Twitchcord/twitchcord.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const CONFIG = PurrplingBot.getConfiguration();
44
const TWITCHORD_CONFIG = CONFIG.twitchcord || {};
55

66
var logger;
7+
var hostingChannel;
78

89
var tmi = require("tmi.js");
910
var tmiClient = new tmi.client({
@@ -60,9 +61,26 @@ tmiClient.on("hosting", function (source, target, viewers) {
6061
logger.error("[TWITCH -> DISCORD] Can't send info about hosting. Channel not found!");
6162
return;
6263
}
64+
if (hostingChannel == target) {
65+
logger.info("[TWITCH -> DISCORD] Info about hosting '%s' already sent!", target);
66+
return;
67+
}
68+
hostingChannel = target;
6369
channel.send(`*Channel ${source} now hosting ${target} - <https://www.twitch.tv/${target}>*`)
64-
.then(logger.info("[TWITCH -> DISCORD] Message forwarded to: #%s", channel.name))
70+
.then(logger.info("[TWITCH -> DISCORD] Message about hosting '%s' forwarded to: #%s", target, channel.name))
71+
.catch(logger.error);
72+
});
73+
74+
tmiClient.on("unhost", function (channel, viewers) {
75+
var channel = client.channels.find('id', TWITCHORD_CONFIG.discordChannelId || "");
76+
if (!channel) {
77+
logger.error("[TWITCH -> DISCORD] Can't send info about hosting. Channel not found!");
78+
return;
79+
}
80+
channel.send(`*Channel ${source} ends hosting ${hostingChannel}*`)
81+
.then(logger.info("[TWITCH -> DISCORD] Message about stop hosting '%s' forwarded to: #%s", hostingChannel, channel.name))
6582
.catch(logger.error);
83+
hostingChannel = null;
6684
});
6785

6886
PurrplingBot.on("message", function(message, isCmd) {

0 commit comments

Comments
 (0)