diff --git a/clients/discord.py b/clients/discord.py index 0050fca..4c2ea3b 100644 --- a/clients/discord.py +++ b/clients/discord.py @@ -82,10 +82,10 @@ class DiscordClient(discord.Client): if cmd == message.content: await self.send_message(message.channel, resp.format(user=message.author.mention)) - def _guess_gifted_subs(self, nick, time): + def _guess_gifted_subs(self, nick, time, threshold): subs = self.commands.plausible_gifted_subs(time) choices = {i: s['receiver'] for i, s in enumerate(subs)} - guesses = fuzzywuzzy.process.extractWithoutOrder(nick, choices, score_cutoff=50) + guesses = fuzzywuzzy.process.extractWithoutOrder(nick, choices, score_cutoff=threshold) result = [] for _, score, i in guesses: days = (time - dateutil.parser.parse(subs[i]['time'])).days @@ -125,8 +125,9 @@ class DiscordClient(discord.Client): user=message.author.mention, info_channel=info_channel.mention)) except discord.errors.Forbidden: pass + threshold = self.config['Discord'].getint('gifted_sub_threshold') self.logger.info('Looking for gifted subs matching {0}'.format(message.author.display_name)) - gifted_subs = self._guess_gifted_subs(message.author.display_name, datetime.datetime.utcnow()) + gifted_subs = self._guess_gifted_subs(message.author.display_name, datetime.datetime.utcnow(), threshold) if gifted_subs: await self._process_gifted_subs(message.author, gifted_subs) diff --git a/settings.cfg.example b/settings.cfg.example index 7fe3c5d..022871f 100644 --- a/settings.cfg.example +++ b/settings.cfg.example @@ -19,6 +19,7 @@ announcer = 369539730989252609 announcement_channels = 383778221004554249,352145992256061440 # #gifted_alerts gifted_sub_notice_channel = 479792436080672789 +gifted_sub_threshold = 60 [Twitter] consumer_key = __TWITTER_CONSUMER_KEY__