Skip to content
Extraits de code Groupes Projets
Valider 669b1680 rédigé par Will Hunt's avatar Will Hunt
Parcourir les fichiers

Don't delay messages behind each other by 750ms

parent 4ef07501
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -87,5 +87,9 @@ channel:
# Make all the discord users leave the room.
ghostsLeave: true
limits:
# Delay between discord users joining a room.
# Delay in milliseconds between discord users joining a room.
roomGhostJoinDelay: 6000
# Delay in milliseconds before sending messages to discord to avoid echos.
# (Copies of a sent message may arrive from discord before we've
# fininished handling it, causing us to echo it back to the room)
discordSendDelay: 750
......@@ -89,6 +89,8 @@ properties:
properties:
roomGhostJoinDelay:
type: "number"
discordSendDelay:
type: "number"
channel:
type: "object"
properties:
......
......@@ -119,11 +119,11 @@ export class DiscordBot {
Bluebird.delay(this.config.limits.discordSendDelay),
]).then(() => this.OnMessageUpdate(oldMessage, newMessage));
});
client.on("message", (msg: Discord.Message) => {
this.discordMessageQueue[msg.channel.id] = (async () => {
await (this.discordMessageQueue[msg.channel.id] || Promise.resolve());
client.on("message", async (msg: Discord.Message) => {
// tslint:disable-next-line:await-promise
await Bluebird.delay(this.config.limits.discordSendDelay);
this.discordMessageQueue[msg.channel.id] = (async () => {
await (this.discordMessageQueue[msg.channel.id] || Promise.resolve());
await this.OnMessage(msg);
})();
});
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter