Simp-O-Matic

Dumb Discord bot in TS.
git clone git://git.knutsen.co/Simp-O-Matic
Log | Files | Refs | README | LICENSE

commit a38e1b5fb46f8a773756b40b8a901643cf738fb2
parent 4fcb2cbddd3fa731a8b43e0c7b4328b43553ab53
Author: Demonstrandum <moi@knutsen.co>
Date:   Wed, 18 Mar 2020 14:02:23 +0000

Fix dict. pronunciations

Diffstat:
Mlib/format_oed.ts | 26+++++++++++++-------------
Mlib/main.ts | 6++++--
2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/lib/format_oed.ts b/lib/format_oed.ts @@ -43,29 +43,29 @@ export default (res, message) => { msg += '\n'; } } - if (!!lex_entry.pronunciations) { + if (!!lex_entry.pronunciations && !has_sent_audio) { const prons = Object.values(lex_entry.pronunciations) as any; - if (!!prons && prons.length > 0 - && !!prons.dialects && prons.dialects.length > 0) { + if (!!prons && prons.length > 0) { msg += "\nPronunciations:\n" for (const pron of prons) { - msg += ` Dialects of ${pron.dialects.join(', ')}:\n`; + if (!!pron.dialects) { + const dialects = Object.values(pron.dialects); + msg += ` Dialects of ${dialects.join(', ')}:\n`; + } msg += ` ${pron.phoneticNotation}: [${pron.phoneticSpelling}]\n`; if (pron.audioFile) { msg += ` Audio file: ${pron.audioFile}\n`; - if (!has_sent_audio) { - has_sent_audio = !has_sent_audio; - const attach = new Attachment( - pron.audioFile, - pron.audioFile.split('/').slice(-1)[0] - ); - message.channel.send('', attach); - } + has_sent_audio = !has_sent_audio; + const attach = new Attachment( + pron.audioFile, + pron.audioFile.split('/').slice(-1)[0] + ); + message.channel.send('', attach); } } } } } - + console.log('Became:', msg); return msg; } diff --git a/lib/main.ts b/lib/main.ts @@ -111,9 +111,11 @@ export class SimpOMatic { const current_command = this._COMMAND_HISTORY.last(); // Try and slow the fellas down a little. - if (last_command.channel === current_command.channel) { + if (!!last_command + && last_command.channel === current_command.channel + && last_command.author.id === current_command.author.id) { // Only give spam warning if commands are coming - // fast _in the same channel_. + // in fast _in the same channel_ and by the same user. const delta = current_command.createdTimestamp - last_command.createdTimestamp; if (last_command.content === current_command.content && delta <= 1400) {