Exemple #1
0
 async def cleverbot_session(self, message):
     if message.channel.id in (730486269468999741, 730570845013147708,
                               750404241566335088):
         if message.author.bot:
             return
         async with message.channel.typing():
             if len(message.content) < 2 or len(message.content) > 100:
                 return await message.channel.send(
                     f"**{message.author.name}**, text must be below 100 characters and over 2."
                 )
             resp = await self.clever.ask(message.content,
                                          message.author.id)
             r = str(resp) if str(resp).startswith("I") else minimalize(
                 str(resp))
             if str(r)[-1] not in ['.', '?', '!']:
                 suff = "?" if any(s in str(r) for s in [
                     'who', 'what', 'when', 'where', 'why', 'how'
                 ]) else "."
             else:
                 suff = "\u200b"
             send = hyper_replace(str(r),
                                  old=[' i ', "i'm", "i'll"],
                                  new=[' I ', "I'm", "I'll"])
             await message.channel.send(
                 f"**{message.author.name}**, {send}{suff}")
Exemple #2
0
 async def cleverbot(self, ctx, *, text: str):
     """
     Ask the clever bot a question.
     """
     async with ctx.typing():
         if len(ctx.message.content) < 2 or len(ctx.message.content) > 60:
             return await ctx.send(
                 f"**{ctx.author.name}**, text must be below 60 characters and over 2.")
         resp = await self.clever.ask(text, ctx.author.id)
         r = str(resp) if str(resp).startswith("I") else cyberformat.minimalize(str(resp))
         if str(r)[-1] not in ['.', '?', '!']:
             suff = "?" if any(s in str(r) for s in ['who', 'what', 'when', 'where', 'why', 'how']) else "."
         else:
             suff = "\u200b"
         send = cyberformat.hyper_replace(str(r), old=[' i ', "i'm", "i'll"], new=[' I ', "I'm", "I'll"])
         await ctx.send(f"**{ctx.author.name}**, {send}{suff}")