示例#1
0
    def need_to_strip(self, message):

        except_roles = self.config.get('except_roles', [])

        # Do nothing if bot cannot find user
        if self.IsValid(message.author) is False:
            return False
        # Do nothing if bot is the sender in the message
        if message.author == self.client.user:
            return False
        # Do nothing if bot cannot find attribute roles
        try:
            if message.author.roles is None:
                return False
        except AttributeError:
            return False
        except discord.Forbidden:
            return False
        """
        Ignore if message from except roles
        """
        for role in message.author.roles:
            if role.name in except_roles:
                return False

        """
        Check if message contains unicode name
        """
        # Manage channel nickname filter
        if message.channel.name in self.config.get('channels', []):
            random_nicknames = ['Carla', 'Price', 'Angelo', 'Cook', 'Charlene', 'Schwartz', 'Angel', 'Weber', 'Frederick', 'Daniel', 'Mack', 'Berry', 'Bobby', 'Guerrero', 'Willard', 'Allen', 'Krista', 'Walsh', 'Melanie', 'Perkins', 'Rickey', 'Carlson', 'Francis', 'Norman', 'Wilbert', 'Bowen', 'Gwen', 'Brewer', 'Stanley', 'Conner', 'Judy', 'Miller', 'Eduardo', 'Yates', 'Laverne', 'Morton', 'Julia', 'Foster', 'Leland', 'Steele', 'Dominic', 'Allison', 'Jason', 'Gray', 'Evan', 'Ortiz', 'Sheri', 'Rhodes', 'Kristy', 'Craig', 'Mamie', 'Glover', 'Marcella', 'Chapman', 'Allan', 'Ray', 'Erin', 'Lawrence', 'Robin', 'Reyes', 'Malcolm', 'Thornton', 'Maggie', 'Riley', 'Pat', 'Burns', 'Shelley', 'Soto', 'Lana', 'Harper', 'Leah', 'Harrington', 'Juana', 'Parker', 'Lindsay', 'Robbins', 'Bill', 'Simon', 'Jacquelyn', 'Cole', 'Laurence', 'Rios', 'Ralph', 'Garza', 'Marlon', 'Strickland', 'Minnie', 'Hammond', 'Ramon', 'Massey', 'Scott', 'Reid', 'Ray', 'Wagner', 'Stacy', 'Morales', 'Jan', 'Schultz', 'Spencer', 'Watson', 'WinnyDapooh', 'PigletDaPooh']
            authorname = message.author.name
            encoded_authorname = authorname.encode('unicode_escape')
            stripped_authorname = encoded_authorname.decode('unicode_escape').encode('ascii','ignore').decode("utf-8")
            if (len(str(message.author.name.replace(" ", ""))) <= 3) and (message.author.nick is None) and not (message.author.nick in random_nicknames):
                log_message = 'User has less than 3 chars.. needs to be changed for: ' + message.author.name
                logger.log(log_message)
                logging.warning(log_message)
                return True
			#If name is fine return false, otherwise return True
            if (message.author.name == stripped_authorname):
                return False
            if ((message.author.name != stripped_authorname) or not (message.author.nick in random_nicknames)) and (message.author.nick is None):
                log_message = 'Unicode Name needs to be stripped for: '+message.author.name
                logger.log(log_message)
                logging.warning(log_message)
                return True
            else:
                return False
示例#2
0
 async def on_message(message):
     if message.content.startswith('!resetnick'):
         try:
             except_roles = bot.config.get('except_roles', [])
             for role in message.author.roles:
                 if role.name in except_roles:
                     await client.send_message(message.author, "[EXCEPTION ROLES] You may not reset your nickname!")
                     await client.delete_message(message)
                     return
             if message.author.nick is None:
                 await client.send_message(message.author, "`You have already reset your nickname!`")
                 await client.delete_message(message)
                 return
             await client.change_nickname(message.author, "")
             await client.send_message(message.author, "You have successfully reset your name back to `%s`!\n```Please consider changing your username to an appropriate name that does not include unicode special characters.```" % message.author.name)
             await client.delete_message(message)
             log_message = 'Executed Reset Name for User: '******'I do not have required permissions to do this on ' + message.author.name
             logger.log(log_message)
             logging.warning(log_message)
             return
         except AttributeError:
             log_message = 'I cannot grab roles for ' + message.author.name
             logger.log(log_message)
             logging.warning(log_message)
             return
     if bot.on_message(message):
         authorname = message.author.name
         encoded_authorname = authorname.encode('unicode_escape')
         stripped_authorname = encoded_authorname.decode('unicode_escape').encode('ascii','ignore').decode("utf-8")
         if (len(str(stripped_authorname.replace(" ", ""))) <= 3):
             stripped_authorname = random.choice(['Carla', 'Price', 'Angelo', 'Cook', 'Charlene', 'Schwartz', 'Angel', 'Weber', 'Frederick', 'Daniel', 'Mack', 'Berry', 'Bobby', 'Guerrero', 'Willard', 'Allen', 'Krista', 'Walsh', 'Melanie', 'Perkins', 'Rickey', 'Carlson', 'Francis', 'Norman', 'Wilbert', 'Bowen', 'Gwen', 'Brewer', 'Stanley', 'Conner', 'Judy', 'Miller', 'Eduardo', 'Yates', 'Laverne', 'Morton', 'Julia', 'Foster', 'Leland', 'Steele', 'Dominic', 'Allison', 'Jason', 'Gray', 'Evan', 'Ortiz', 'Sheri', 'Rhodes', 'Kristy', 'Craig', 'Mamie', 'Glover', 'Marcella', 'Chapman', 'Allan', 'Ray', 'Erin', 'Lawrence', 'Robin', 'Reyes', 'Malcolm', 'Thornton', 'Maggie', 'Riley', 'Pat', 'Burns', 'Shelley', 'Soto', 'Lana', 'Harper', 'Leah', 'Harrington', 'Juana', 'Parker', 'Lindsay', 'Robbins', 'Bill', 'Simon', 'Jacquelyn', 'Cole', 'Laurence', 'Rios', 'Ralph', 'Garza', 'Marlon', 'Strickland', 'Minnie', 'Hammond', 'Ramon', 'Massey', 'Scott', 'Reid', 'Ray', 'Wagner', 'Stacy', 'Morales', 'Jan', 'Schultz', 'Spencer', 'Watson', 'WinnyDapooh', 'PigletDaPooh'])
         try:
             await client.change_nickname(message.author, stripped_authorname)
             await client.send_message(message.author, "```"+"Your nickname was changed to "+stripped_authorname+"\nThis could've happened for a couple reasons:\n1.) Your name is 3 characters or less\n2.) Your name contained Unicode\nIf you wish to have a different name on our Discord, please change your username and use the !resetnick command in #lounge```")
             await client.delete_message(message)
         except discord.Forbidden:
             return
示例#3
0
 async def on_ready():
     """ Connected to bot """
     logger.log('Logged in as')
     logger.log(client.user.name)
     logger.log(client.user.id)
     logger.log('------')