|
|
@ -82,10 +82,10 @@ class DiscordClient(discord.Client):
|
|
|
|
if cmd == message.content:
|
|
|
|
if cmd == message.content:
|
|
|
|
await self.send_message(message.channel, resp.format(user=message.author.mention))
|
|
|
|
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)
|
|
|
|
subs = self.commands.plausible_gifted_subs(time)
|
|
|
|
choices = {i: s['receiver'] for i, s in enumerate(subs)}
|
|
|
|
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 = []
|
|
|
|
result = []
|
|
|
|
for _, score, i in guesses:
|
|
|
|
for _, score, i in guesses:
|
|
|
|
days = (time - dateutil.parser.parse(subs[i]['time'])).days
|
|
|
|
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))
|
|
|
|
user=message.author.mention, info_channel=info_channel.mention))
|
|
|
|
except discord.errors.Forbidden:
|
|
|
|
except discord.errors.Forbidden:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
threshold = self.config['Discord'].getint('gifted_sub_threshold')
|
|
|
|
self.logger.info('Looking for gifted subs matching {0}'.format(message.author.display_name))
|
|
|
|
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:
|
|
|
|
if gifted_subs:
|
|
|
|
await self._process_gifted_subs(message.author, gifted_subs)
|
|
|
|
await self._process_gifted_subs(message.author, gifted_subs)
|
|
|
|
|
|
|
|
|
|
|
|