예제 #1
0
 async def epicroast(self, ctx):
     roast_word = urbandictionary.random()
     words = []
     for i in roast_word:
         words.append(i.word)
     await ctx.send('The epic store can ' + random.choice(words) + ' mah ' +
                    random.choice(words))
예제 #2
0
파일: urban.py 프로젝트: cazagen/botbot
def udrandom(bot, channel, sender, args):
    """ Defines you a random word from urban dictonary"""
    definition = urbandictionary.random()
    bot.message(channel, "{}: {}".format(
        definition[0].word,
        definition[0].definition
    ))
예제 #3
0
파일: Fun.py 프로젝트: jbsparrow/b1nzyBotPy
    async def ud(self, ctx, *, query='random'):
        """Searches urban dictionary for your input."""
        if query == 'random':
            ran = urbandictionary.random()
            limit = 1
            for r in ran:
                while limit != 0:
                    definition = r.definition
                    example = r.example

                    #   Remove all square brackets as they only have an effect on the urban dictionary website
                    definition = definition.replace('[', '')
                    definition = definition.replace(']', '')
                    example = example.replace('[', '')
                    example = example.replace(']', '')

                    #   Make an embed because all things are better in an embed
                    embed = discord.Embed(colour=randomhex(hex), title=r.word)
                    embed.add_field(name='Definition:',
                                    value=definition,
                                    inline=False)
                    embed.add_field(name='Example:',
                                    value=example,
                                    inline=False)

                    #   Send the embed.
                    await ctx.send(embed=embed)
                    limit -= 1
        else:
            #   replace spaces with %20's to function as a proper link
            query = query.replace(' ', '%20')
            await ctx.send(
                f'https://urbandictionary.com/define.php?term={query}')
예제 #4
0
    def on_urban(self, event, phrase=None):
        self.client.api.channels_typing(event.msg.channel_id)

        urban_entry = None

        if phrase is None:
            urban_entry = random.choice(
                ud.random())  # grab some random words | list of urbandef
        else:
            defs = ud.define(phrase)

            if len(defs) > 0:
                urban_entry = defs[0]

        if urban_entry is None:
            event.msg.reply('Failed to find a definition for that!')
        else:
            definition = urban_entry.definition
            # Let's do a little... checking!
            if len(definition) >= 2000:
                definition = definition[:1950] + '...'

            # Let's construct an embed :)
            embed = MessageEmbed()
            embed.title = f"**Defintion of {urban_entry.word}**"
            embed.description = definition

            embed.add_field(name='Example', value=urban_entry.example)
            embed.add_field(
                name='Rating',
                value=f"{urban_entry.upvotes} 👍 | {urban_entry.downvotes} 👎")

            embed.color = '5824574'

            event.msg.reply(embed=embed)
예제 #5
0
def randomItem(name, location):
    i = random.randrange(0, 6 + 1)

    equiptext = "\n(you can equip this item with !fish equip)"

    if i <= 1:
        visit = random.choice(premadelocations)
        #print(f"randomly selected {visit}")
        retry = 0
        while f"Visited {visit}" in data[name]["flags"].keys() and retry < 50:
            retry += 1
            visit = random.choice(premadelocations)
            #print(f"randomly selected {visit}")

        if "Mead and Madness" in visit and "Dwarven Hold" not in location:
            return f"a flyer, but the water has damaged it to the point where you can't read what the runes say any more"
        if "Cafe" in visit and "leslie" not in location.lower(
        ) and "saiyuri" not in location.lower():
            return f"a flyer, but the water has damaged it to the point where all you can see is a smudged kawaii picture"
        if f"Visited {visit}" in data[name]["flags"]:
            return f"a flyer for '{visit}'"

        return f"a flyer for '{visit}', maybe you should visit sometime"

    if i <= 2:
        word = randomUser()
        data[name]["last_item"] = f"{word}'s wellington boot"
        return f"{word}'s wellington boot!{equiptext}"
    if i <= 3:
        word = urbandictionary.random()[0].word
        data[name][
            "last_item"] = f"a keyring with a tag that says '{word}' in worn letters"
        return f"a keyring with a tag that says '{word}' in worn letters!{equiptext}"
    if i <= 4:
        randpoke = random.choice(sosfish_constants.pokemon['ALL'])
        randmat = random.choice(["plastic", "metal", "cloth", "wooden"])
        data[name][
            "last_item"] = f"a keyring with a little {randmat} {randpoke}"
        return f"a keyring with a little {randmat} {randpoke}!{equiptext}"
    if i <= 5:
        word = urbandictionary.random()[0].word
        data[name][
            "last_item"] = f"a hat with '{word}' emblazoned across the front"
        return f"a hat with '{word}' emblazoned across the front!{equiptext}"
    if i <= 6:
        return f"a bottle containing a message that reads '{sosmarkov.sentence(sosmarkov.models['general'])} '"
예제 #6
0
파일: main.py 프로젝트: bevanator/Word_Bot
async def send_interval_message_specific():                 # sends to a specific channel
  while switch == 1:
      await asyncio.sleep(delay)
      rand = ud.random()
      for w in rand[:1]:
        channel = client.get_channel(id = 840663367781842965)
        await channel.send(w.word)
        await channel.send(w.definition)
예제 #7
0
def _get_slang(args):
    if len(args) != 0:
        slang_name = str(" ".join(args))
        slang = ud.define(slang_name, embedd_link=True)[0]
    else:
        random_slangs = ud.random(embedd_link=True)
        slang = random.choice(random_slangs)
    return slang.word + "\n" + slang.definition + "\n"
예제 #8
0
async def urbanrandom(ctx):
    logging.debug('Executing command {}urbanrandom'.format(prefix))

    definition = ud.random()[
        0]  # selecting first definition from the list of random definitions
    response = '***{0.word}***\n\n`{0.definition}\n\n{0.example}`'.format(
        definition)

    await ctx.send(response)
예제 #9
0
    def urban_bag(self):
        """
        Returns parsed list of random words from urban dictionary.
        """
        words = self._parse([word.word for word in urbandictionary.random()])

        self.cached_words = words

        return words
예제 #10
0
 async def urbanBoi(self, context, rest: str = None):
     if rest:
         word = ud.define(rest)[0]
         await self.bot.send_message(context.message.channel,
                                     word.word + " " + word.definition)
     else:
         rando = ud.random()[0]
         await self.bot.send_message(context.message.channel,
                                     rando.word + " " + rando.definition)
예제 #11
0
 def generate_random_word(self):
     udword = ud.random()[0]
     self._word = udword.word
     self._word_lower_case = self._word.lower()
     self._word_definition = udword.definition
     if ' ' in self._word:
         self._guessed_letters_correct.append(' ')
     if '-' in self._word:
         self._guessed_letters_correct.append('-')
예제 #12
0
파일: bot.py 프로젝트: sharp360/sharpbot2
async def urbandic(ctx):
    ran = urbandictionary.random()
    limit = 1
    print("Random definition from urbandictionary.com")
    for r in ran:
        while limit != 0:
            await ctx.send("Слово: " + r.word + " | " + "Значение: " +
                           r.definition)
            limit -= 1
예제 #13
0
 async def udr(self, ctx):
     """Returns a random urban dictionary article"""
     sys.stdout.write(f'{ctx.message.author} ran command "udr"\n')
     sys.stdout.flush()
     logging.info(f'{ctx.message.author} ran command "udr"')
     defs = ud.random()
     em = discord.Embed(title=defs[0].word,
                        description=defs[0].definition,
                        colour=0x7eff00)
     await ctx.send(embed=em)
예제 #14
0
파일: bot.py 프로젝트: ItsRohan0165/udtest1
async def ud_random_handler(m):
    location = None
    if not m.guild:
        location = "priv-" + m.author.name
    else:
        location = m.guild.name
    d = ud.random()[0]
    logging.info('ud_random_handler,{},{},{},success'.format(
        m.author.name, location, d.word))
    await ud_response(m, d)
예제 #15
0
def random(self):
    """
    Get a random word for urbandictionary.
    """

    rand = ud.random()[1:]
    for d in rand:
        word = (d.word)
        defs = (d.definition)

    text = "{}\n\n{}"
    self.message(text.format(word, defs))
예제 #16
0
def respond(message):
    searchTerm = str(message.content).lower().split("define", 1)[1].strip()

    definitions = urbandictionary.define(searchTerm)

    if len(definitions) < 1:
        definitions = urbandictionary.random()

    output = definitions[0].definition.replace("[", "").replace("]", "")

    output = ireplace(definitions[0].word, searchTerm, output)

    return (output[:998] + '..') if len(output) > 1000 else output
예제 #17
0
def Leeg(user):

    random.seed(numberFromString(user, 32000))

    output = describeAccount(user)
    output += f"Money spent on skins: €{number()}\n"

    if random.randint(1, 4) > 1:
        output += "\n"
        definitions = urbandictionary.random()
        output += f"\nALTERNATE ACCOUNT DETECTED FOR {user.upper()}:\n"
        output += describeAccount(definitions[0].word, True)

    return output
예제 #18
0
파일: main.py 프로젝트: bevanator/Word_Bot
async def send_interval_message_all():                      # sends to all servers' first text channel it's able to
  while switch == 1:
      await asyncio.sleep(delay)
      for guild in client.guilds:
        for channel in guild.text_channels:
          try:
            # print(channel.id)
            rand = ud.random()
            for w in rand[:1]:
              await channel.send(w.word)
              await channel.send(w.definition)
          except Exception:
            continue
          else:
            break
예제 #19
0
 async def define(self, ctx, *search):
     await ctx.message.delete()
     wurd = ' '.join(search)
     wurd.replace(',', '')
     #If no word is given, it will return a random search.
     if wurd == '':
         rand = ud.random()
         w_definition = f"""\n>>> **{rand[0].word}**\n\nDefinition:\n```{rand[0].definition}``` \nExample:\n```{rand[0].example}```\n⬆️ {rand[0].upvotes}     ⬇️ {rand[0].downvotes}\n"""
         await ctx.send(w_definition)
     #If there is something to search for it will try to find it
     else:
         rand = ud.define(str(wurd))
         if not rand:
             print("list is empty")
         w_definition = f"""\n>>> **{rand[0].word}**\n\nDefinition:\n```{rand[0].definition}``` \nExample:\n```{rand[0].example}```\n⬆️ {rand[0].upvotes}     ⬇️ {rand[0].downvotes}\n"""
         await ctx.send(w_definition)
     message = message = 'I found an urban definition for ' + str(
         ctx.message.author.name) + ' using ***' + str(
             wurd) + '*** as a search!'
     if ctx.guild.id in spam_channels.keys():
         channel = spam_channels[ctx.guild.id]
         await channel.send(message)
예제 #20
0
 async def random(self):
     """Returns te definitions of a random word from Urban Dictionary"""
     word = ud.random()[0]
     await self.bot.say("**%s**"%word.word + "\n" + word.definition)
예제 #21
0
async def on_message(message):
    #Event for when message gets recieved
    if not message.server: #DMs
        if message.author == client.user:
            return
        if message.content.startswith(COMMAND_PREFIX):
            command = message.content.split(' ' , maxsplit=1)
            
            if command[0] == COMMAND_PREFIX+'mute':
                await cog_notifications.mute(client, message)

            if command[0] == COMMAND_PREFIX+'unmute':
                await cog_notifications.unmute(client, message)
        else:
            print('({1.hour:02d}:{1.minute:02d}){0.author.name} send us a message in DM.'.format(message, datetime.now()))
            print('\"{0.author.name}:{0.clean_content}\"'.format(message))
            #await client.send_message(client.get_channel('303603185514184705'), '{0.author.name}(`{0.author.id}`) send me a message in DM. He said:\n"{0.clean_content}"'.format(message))
    if message.server: #not DMs
        if message.server.id in authorized_servers:
            #Accessing global variables with ability to write
            global DERPIBOORU_ENABLED
            global EQD_FEED_ENABLED
            global MEME_ENABLED
            global ME_ENABLED
            global MENTION_ENABLED
            global undo_posts
            global derpi_undo_posts
            global meme_timer
            global mention_timer
            global derpi_timer

            if message.channel.id in meme_commands: #For commands in meme channel
                if message.content.startswith(COMMAND_PREFIX):
                    command = message.content.split(' ' , maxsplit=1)

                    if command[0] == COMMAND_PREFIX+'undo': #Pmeme undo command. Deletes last pmeme message sender got
                        print('({1.hour:02d}:{1.minute:02d}) undo command by {0}'.format(message.author.name, datetime.now()))
                        for msg, user in reversed(undo_posts):
                            if user == message.author:
                                await client.delete_message(msg)
                                undo_posts.remove((msg, user))
                                #print([i[1] for i in undo_posts])
                                return
                        await client.send_message(message.channel, 'Nothing to undo for you, silly')
                        print('nothing to undo')
                            
                    if command[0] == COMMAND_PREFIX+'pmeme': #Pmeme command. Gets a random derpi image tagged "meme"
                        if not MEME_ENABLED:
                            await client.send_message(message.channel, random.choice(command_off_quotes))
                            return
                        if len(command) == 1:
                            meme_query = ''
                        else:
                            meme_query = command[1]
                        print('({1.hour:02d}:{1.minute:02d}) pmeme command by {0} with tags "{2}"'.format(message.author.name, datetime.now(), meme_query))
                        if meme_timer.is_alive():
                            await client.send_message(message.channel, random.choice(cooldown_quotes))
                            print('pmeme cooldown'.format(datetime.now()))
                            return
                        if message.channel.id not in commands_channels:
                            meme_timer = Timer(MEME_COOLDOWN, empty) #cooldown
                            meme_timer.start()
                        for image in Search().sort_by(sort.RANDOM).query(meme_query).filter(DERPI_MEME_FILTER):
                            msg = await client.send_message(message.channel, image.url)
                            undo_posts.append((msg, message.author))
                            if len(undo_posts) > 10:
                                undo_posts.pop(0)
                            #print(undo_posts)
                            return
                        await client.send_message(message.channel, "I can't find anything")
                        meme_timer.cancel()
                        print('nothing found')
            
            if message.channel.id in art_commands: #For commands in art channel
                if message.content.startswith(COMMAND_PREFIX):
                    command = message.content.split(' ' , maxsplit=1)

                    if command[0] == COMMAND_PREFIX+'undo': #pony undo command. Deletes last ponyr or pony message sender got
                        print('({1.hour:02d}:{1.minute:02d}) undo command by {0}'.format(message.author.name, datetime.now()))
                        for msg, user in reversed(derpi_undo_posts):
                            if user == message.author:
                                await client.delete_message(msg)
                                derpi_undo_posts.remove((msg, user))
                                #print(derpi_undo_posts)
                                return
                        await client.send_message(message.channel, 'Nothing to undo for you, silly')
                        print('nothing to undo')
            
                    if command[0] == COMMAND_PREFIX+'ponyr': #Ponyr command. Gets a random derpi image with or without user tags.
                        if not DERPIBOORU_ENABLED:
                            await client.send_message(message.channel, random.choice(command_off_quotes))
                            return
                        derpi_filter = DERPI_GENERAL_FILTER
                        if len(command) == 1:
                            derpi_query = ''
                        else:
                            derpi_query = command[1]
                            if command[1].find('artist:') != -1:
                                derpi_filter = DERPI_GENERAL_ARTIST_FILTER
                        print('({1.hour:02d}:{1.minute:02d}) Pony with tags:"{0}"'.format(derpi_query, datetime.now()))
                        if derpi_timer.is_alive():
                            await client.send_message(message.channel, random.choice(cooldown_quotes))
                            print('ponyr cooldown'.format(datetime.now()))
                            return
                        if message.channel.id not in commands_channels:
                            derpi_timer = Timer(DERPI_COOLDOWN, empty)
                            derpi_timer.start()
                        for image in Search().sort_by(sort.RANDOM).query(derpi_query).filter(filter_id=derpi_filter):
                            msg = await client.send_message(message.channel, image.url)
                            derpi_undo_posts.append((msg, message.author))
                            if len(derpi_undo_posts) > 10:
                                derpi_undo_posts.pop(0)
                            #print(derpi_undo_posts)
                            return                        
                        await client.send_message(message.channel, "I can't find anything")
                        derpi_timer.cancel()
                        print('nothing found')
                        
                    if command[0] == COMMAND_PREFIX+'pony': #Pony command. Gets newest derpi image with or without user tags.
                        if not DERPIBOORU_ENABLED:
                            await client.send_message(message.channel, random.choice(command_off_quotes))
                            return
                        derpi_filter = DERPI_GENERAL_FILTER
                        if len(command) == 1:
                            derpi_query = ''
                        else:
                            derpi_query = command[1]
                            if command[1].find('artist:') != -1:
                                derpi_filter = DERPI_GENERAL_ARTIST_FILTER
                        print('({1.hour:02d}:{1.minute:02d}) Pony with tags:"{0}"'.format(derpi_query, datetime.now()))
                        if derpi_timer.is_alive():
                            await client.send_message(message.channel, random.choice(cooldown_quotes))
                            print('pony cooldown'.format(datetime.now()))
                            return
                        if message.channel.id not in commands_channels:
                            derpi_timer = Timer(DERPI_COOLDOWN, empty)
                            derpi_timer.start()
                        for image in Search().query(derpi_query).filter(filter_id=derpi_filter):
                            msg = await client.send_message(message.channel, image.url)
                            derpi_undo_posts.append((msg, message.author))
                            if len(derpi_undo_posts) > 10:
                                derpi_undo_posts.pop(0)
                            #print([v.name for v in derpi_undo_posts.values()])
                            return
                        await client.send_message(message.channel, "I can't find anything")
                        derpi_timer.cancel()
                        print('nothing found')
            
            if message.channel.id in commands_channels: #For general (staff) commands. Preferably to add mod user filter
                if message.content.startswith(COMMAND_PREFIX):
                    command = message.content.split(' ' , maxsplit=1)


                    if command[0] == COMMAND_PREFIX+'mute': #Mute command. Mutes sub notifications
                        await cog_notifications.mute(client, message)

                    if command[0] == COMMAND_PREFIX+'unmute': #Unmute command. Unmutes sub notifications
                        await cog_notifications.unmute(client, message)

                    if command[0] == COMMAND_PREFIX+'subscribe': #Subscribe command. Adds your id to the list of recievers of something.
                        await cog_notifications.subscribe(client, message, command)

                    if command[0] == COMMAND_PREFIX+'unsubscribe': #Unsubscribe command. Removes your id form the list of recievers of something.
                        await cog_notifications.unsubscribe(client, message, command)
                        
                    if command[0] == COMMAND_PREFIX+'names': #Names command. Prints the last recorded 20 names and nicknames of a user.
                        await cog_commands.names(client, message, command)
                    
                    if command[0] == COMMAND_PREFIX+'togglemention': #Togglemention command. Enables/disables responce to a mention
                        MENTION_ENABLED = not MENTION_ENABLED
                        if MENTION_ENABLED:
                            await client.send_message(message.channel, 'Reaction to mentions is now enabled')
                        else:
                            await client.send_message(message.channel, 'Reaction to mentions is now disabled')

                    if command[0] == COMMAND_PREFIX+'togglememe': #Togglememe command. Enables/disables pmeme
                        MEME_ENABLED = not MEME_ENABLED
                        if MEME_ENABLED:
                            await client.send_message(message.channel, 'Meme commands are now enabled')
                        else:
                            await client.send_message(message.channel, 'Meme commands are now disabled')

                    if command[0] == COMMAND_PREFIX+'toggleme': #Togglememe command. Enables/disables me
                        ME_ENABLED = not ME_ENABLED
                        if ME_ENABLED:
                            await client.send_message(message.channel, 'Me command is now enabled')
                        else:
                            await client.send_message(message.channel, 'Me command is now disabled')


                    if command[0] == COMMAND_PREFIX+'me': #Me command. Makes bot say the message given in specified channel
                        if not ME_ENABLED:
                            return
                        if len(command) > 1:
                            me_command = command[1].split(' ', maxsplit=1)
                            print('({1.hour:02d}:{1.minute:02d}) me command with args {0}'.format((message.clean_content.split(' ' , maxsplit=1))[1], datetime.now()))
                            me_channel_id = me_command[0].strip('<>#!')
                            if len(me_command) > 1 and me_channel_id.isdecimal() and client.get_channel(me_channel_id) and me_channel_id not in serious_channels:
                                try:
                                    await client.send_typing(client.get_channel(me_channel_id))
                                    await asyncio.sleep(min(len(me_command[1])*0.05*random.uniform(0.8,1.1), 6)) #"Typing..." length formula
                                    await client.send_message(client.get_channel(me_channel_id), stop_mass_mentions(me_command[1]))
                                except discord.errors.Forbidden as e:
                                    await client.send_message(message.channel, 'I can\'t post there')
                                return
                        await client.send_message(message.channel, '```\n'+command[0]+' #channel <text_you_want_me_to_say>\n```')

                    if command[0] == COMMAND_PREFIX+'togglederpi': #Togglederpi command. Enables/disables pony and ponyr
                        DERPIBOORU_ENABLED = not DERPIBOORU_ENABLED
                        if DERPIBOORU_ENABLED:
                            await client.send_message(message.channel, 'Derpibooru commands are now enabled')
                        else:
                            await client.send_message(message.channel, 'Derpibooru commands are now disabled')

                    if command[0] == COMMAND_PREFIX+'togglefeed': #Togglefeed command. Enables/disables feed
                        EQD_FEED_ENABLED = not EQD_FEED_ENABLED
                        if EQD_FEED_ENABLED:
                            await client.send_message(message.channel, 'EQD feed is now enabled')
                        else:
                            await client.send_message(message.channel, 'EQD feed is now disabled')

                    if command[0] == COMMAND_PREFIX+'urban': #Urban command. Gets Urbandictionary definition for the word
                        if len(command) == 1:
                            return
                        print('({0.hour:02d}:{0.minute:02d}){1.author.name} used urban for word "{2}"'.format(datetime.now(), message, command[1]))
                        defs = ud.define(command[1])
                        if not defs:
                            print('Nothing found')
                            await client.send_message(message.channel, 'Nothing found')
                            return
                        n = 0
                        em = discord.Embed(title=defs[n].word, description=defs[n].definition.replace('[', '').replace(']', ''), colour=0x134FE6)
                        em.add_field(name='Example:', value=defs[n].example.replace('[', '').replace(']', ''))
                        em.set_footer(text='{0} at UTC/GMT+0'.format(datetime.utcnow()))
                        await client.send_message(message.channel, embed=em)

                    if command[0] == COMMAND_PREFIX+'urbanr': #UrbanR command. Gets random Urbandictionary word and its definition
                        defs = ud.random()
                        if not defs:
                            print('Urbanr Nothing found')
                            await client.send_message(message.channel, 'Nothing found')
                            return
                        n = 0
                        print('({0.hour:02d}:{0.minute:02d}){1.author.name} used urbanr and got the word "{2}"'.format(datetime.now(), message, defs[n].word))
                        em = discord.Embed(title=defs[n].word, description=defs[n].definition.replace('[', '').replace(']', ''), colour=0x134FE6)
                        em.add_field(name='Example:', value=defs[n].example.replace('[', '').replace(']', ''))
                        em.set_footer(text='{0} at UTC/GMT+0'.format(datetime.utcnow()))
                        await client.send_message(message.channel, embed=em)

                    if command[0] == COMMAND_PREFIX+'ping': #Ping command. Simply replies with pong. Used to check if bot is alive
                        print('({0.hour:02d}:{0.minute:02d}) pong'.format(datetime.now()))
                        await client.send_message(message.channel, 'pong')
                        
                    if command[0] == COMMAND_PREFIX+'reason': #Reason command. Logs the ban in ban channel with given case and reason.
                        await cog_banning.reason(client, message, command)
                            
                    if command[0] == COMMAND_PREFIX+'userinfo': #Userinfo command. Prints information about given user or sender, if no user given
                        if len(command) == 1:
                            userinfo_command = message.author.id
                        else:
                            userinfo_command = command [1]
                        print('({1.hour:02d}:{1.minute:02d}){0.author.name} used `userinfo command'.format(message, datetime.now()))
                        print('\"{0.author.name}:{0.content}\"'.format(message))
                        if userinfo_command.isdecimal():                        #by id
                            user = message.server.get_member(userinfo_command)
                        elif (userinfo_command.strip('<>@!')).isdecimal():      #by ping
                            user = message.server.get_member(userinfo_command.strip('<>@!'))
                        else:                                                   #by name
                            user = message.server.get_member_named(userinfo_command)
                        if not user:
                            await client.send_message(message.channel, 'User not found.\nUse \`userinfo <id/mention/name> to get info about user.')
                            return
                        if user.avatar_url:
                            user_avatar_url = user.avatar_url
                        else:
                            user_avatar_url = user.default_avatar_url
                        em = discord.Embed(title=':information_source: User info', colour=user.colour)
                        em.set_author(name='User: @{0.name}#{0.discriminator} - {0.id}'.format(user))
                        em.set_thumbnail(url=user_avatar_url)
                        em.add_field(name='User:'******'Nickname:', value=user.nick, inline=True)
                        em.add_field(name="User created on:", value=user.created_at.strftime("%d %b %Y %H:%M") + ' ({} days ago)  '.format((message.timestamp - user.created_at).days), inline=False)
                        em.add_field(name="User joined on:", value=user.joined_at.strftime("%d %b %Y %H:%M") + ' ({} days ago)'.format((message.timestamp - user.joined_at).days), inline=False)
                        if len(user.roles) > 1:
                            em.add_field(name="Roles:", value=", ".join([x.name for x in user.roles if x.name != "@everyone"]), inline=False)
                        em.set_footer(text='{0} at UTC/GMT+0'.format(datetime.utcnow()))
                        await client.send_message(message.channel, embed=em)
                        
                    if command[0] == COMMAND_PREFIX+'serverinfo': #Serverinfo command. Prints information about current server
                        print('({1.hour:02d}:{1.minute:02d}){0.author.name} used `serverinfo command'.format(message, datetime.now()))
                        print('\"{0.author.name}:{0.content}\"'.format(message))
                        em = discord.Embed(title=':information_source: Server info', colour=0x80A0EE)
                        em.set_author(name=message.server.name + ' - ' + message.server.id)
                        em.set_thumbnail(url=message.server.icon_url)
                        em.add_field(name='Members:', value=message.server.member_count)
                        em.add_field(name='Owner:', value=message.server.owner.mention)
                        ver_levels = {discord.VerificationLevel.none:'None - No criteria set.',
                                      discord.VerificationLevel.low:'Low - Member must have a verified email on their Discord account.',
                                      discord.VerificationLevel.medium:'Medium - Member must have a verified email and be registered on Discord for more than five minutes.',
                                      discord.VerificationLevel.high:'High - Member must have a verified email, be registered on Discord for more than five minutes, and be a member of the server itself for more than ten minutes.',
                                      discord.VerificationLevel.table_flip:'High - Member must have a verified email, be registered on Discord for more than five minutes, and be a member of the server itself for more than ten minutes.'}
                        em.add_field(name='Verification level:', value=ver_levels.get(message.server.verification_level, 'None'), inline=False)
                        em.add_field(name='Created on:', value=message.server.created_at.strftime("%d %b %Y %H:%M") + ' ({} days ago)'.format((message.timestamp - message.server.created_at).days), inline=False)
                        em.set_footer(text='{0} at UTC/GMT+0'.format(datetime.utcnow()))
                        await client.send_message(message.channel, embed=em)


            if message.server.me in message.mentions: #If someone mentions the bot
                if not MENTION_ENABLED:
                    return
                print('({1.hour:02d}:{1.minute:02d}){0.author.name} mentioned bot in {0.channel.name} at {0.server.name}.'.format(message, datetime.now()))
                print('\"{0.author.name}:{0.clean_content}\"'.format(message))
                if mention_timer.is_alive():
                    return
                if message.channel.id not in commands_channels:
                    mention_timer = Timer(MENTION_COOLDOWN, empty) #mention cooldown
                    mention_timer.start()

                rand = random.randint(5,15)
                if '?' in message.content:
                    rand_q = emojify(random.choice(ball8_quotes), message.server)
                elif ':boop:' in message.content:
                    rand_q = emojify(':boop:', message.server) + message.author.mention
                    print(rand_q)
                elif ':hugs:' in message.content:
                    rand_q = emojify(':hugs:', message.server) + message.author.mention
                else:
                    rand_q = emojify(random.choice(mention_quotes), message.server)
                print('And we answered in {0} sec with \"{1}\"'.format(rand, rand_q))
                await asyncio.sleep(rand)
                await client.send_message(message.channel, rand_q)
                
    if message.server:
        if message.server.id in authorized_servers:
            if message.channel.id not in serious_channels and message.channel.id != '151834220841533440': #staff
                for i in banned_words:
                    if i in message.content.lower():
                        if message.author.nick is None:
                            print('({1.hour:02d}:{1.minute:02d}){0.author.name} said banned word in #{0.channel.name} at {0.server.name}.'.format(message, datetime.now()))
                            print('\"{0.author.name}:{0.content}\"'.format(message))
                            dmsg = '{0.author.name}`({0.author.id})` said banned word in #{0.channel.name} at {0.server.name}.\n\"{0.author.name}:{0.content}\"'.format(message)
                            await cog_notifications.dispatch(client, 'banned words', dmsg)
                        else:
                            print('({1.hour:02d}:{1.minute:02d}){0.author.nick}({0.author.name}) said banned word in #{0.channel.name} at {0.server.name}.'.format(message, datetime.now()))
                            print('\"{0.author.nick}:{0.content}\"'.format(message))
                            dmsg = '{0.author.nick}({0.author.name})`({0.author.id})` said banned word in #{0.channel.name} at {0.server.name}.\n\"{0.author.nick}:{0.content}\"'.format(message)
                            await cog_notifications.dispatch(client, 'banned words', dmsg)
                        break
            
            if message.channel.id in general_channels:
                if message.attachments:
                    for i in message.attachments:
                        if i:
                            try:
                                if(i.get('width') is not None) and (i.get('height') > 128):
                                    if i.get('width') > 400:
                                        if (i.get('height')*0.75) < 128:
                                            break
                                    if message.author.nick is None:
                                        dmsg = '{0.author.name}`({0.author.id})` posted a picture({1}x{2}) in #{0.channel.name} at {0.server.name}.'.format(message, i.get('width'),i.get('height'))
                                        print('({0.hour:02d}:{0.minute:02d})'.format(datetime.now())+dmsg)
                                        await cog_notifications.dispatch(client, 'oversized images', dmsg)
                                    else:
                                        dmsg = '{0.author.nick}({0.author.name})`({0.author.id})` posted a picture({1}x{2}) in #{0.channel.name} at {0.server.name}.'.format(message, i.get('width'),i.get('height'))
                                        print('({0.hour:02d}:{0.minute:02d})'.format(datetime.now())+dmsg)
                                        await cog_notifications.dispatch(client, 'oversized images', dmsg)
                                    break
                            except AttributeError:
                                print('({1.hour:02d}:{1.minute:02d}){0.author.name} posted weird embed in #{0.channel.name} at {0.server.name}.'.format(message, datetime.now()))
                                break
                if message.embeds:
                    for i in message.embeds:
                        if i.get('type') == 'image':
                            if(i.get('thumbnail').get('width')) and (i.get('thumbnail').get('height') > 128):
                                if i.get('thumbnail').get('width') > 400:
                                        if (i.get('thumbnail').get('height')*0.75) < 128:
                                            break
                                if message.author.nick is None:
                                    dmsg = '{0.author.name}`({0.author.id})` posted a picture({1}x{2}) in #{0.channel.name} at {0.server.name}.'.format(message, i.get('thumbnail').get('width'),i.get('thumbnail').get('height'))
                                    print('({0.hour:02d}:{0.minute:02d})'.format(datetime.now())+dmsg)
                                    await cog_notifications.dispatch(client, 'oversized images', dmsg)
                                else:
                                    dmsg = '{0.author.nick}({0.author.name})`({0.author.id})` posted a picture({1}x{2}) in #{0.channel.name} at {0.server.name}.'.format(message, i.get('thumbnail').get('width'),i.get('thumbnail').get('height'))
                                    print('({0.hour:02d}:{0.minute:02d})'.format(datetime.now())+dmsg)
                                    await cog_notifications.dispatch(client, 'oversized images', dmsg)
                                break
예제 #22
0
def UDquestion():
	definitions = urbandictionary.random()
	
	for attempts in range(10):

		for index in range(len(definitions)):
			valid = True

			words = definitions[index].word.lower().split()
			descriptionwords = definitions[index].definition.lower().split()

			if(len(words)>3):
				valid = False
				#print(f"rejected (too long) {definitions[index].word}")
				continue

			elif(len(words)>=len(descriptionwords)):
				valid = False
				#print(f"rejected (too short desc) {definitions[index].word}")
				continue

			elif(len(words)<2):
				for word in words:

					if word.lower() in data["girls"]:
						#print(f"rejected (girl) {definitions[index].word}")
						valid = False
						continue
					if word.lower() in data["boys"]:
						#print(f"rejected (boy) {definitions[index].word}")
						valid = False
						continue

				for personword in people_words:
					if personword in definitions[index].definition:
						#print(f"rejected person ({personword}) {definitions[index].word}")
						valid = False
						continue


			for nonpersonword in nonpeople_words:
				if nonpersonword in definitions[index].definition:
					#print(f"rejected nonperson ({nonpersonword}) {definitions[index].word}")
					valid = False
					continue
			if valid:
				break
		if valid:
			break

	if valid == False:
		return

	definitions[index].definition = definitions[index].definition.replace("[","").replace("]","")

	censoredoutput = sosdefine.ireplace(definitions[index].word, "[X]", definitions[index].definition )

	for word in definitions[index].word.split():
		if len(word)>2:
			censoredoutput = sosdefine.ireplace(word, "[X]", censoredoutput )

	definitions[index].censoreddef = censoredoutput
	definitions[index].questionpreamble = "--- URBAN JEOPARDY ROUND ---\n--- What is the word/phrase described by this definition? ---"
	definitions[index].questiontype = "UD"
	definitions[index].rules = ""
	definitions[index].maxguesses = 9999;
	return definitions[index]
예제 #23
0
async def random(ctx):
    rand = ud.random()
    for things in rand:
        thing = str(things)
        await ctx.send("```" + thing + "```")
        break
예제 #24
0
파일: api.py 프로젝트: angstycoder/Abhi
 async def udran(self):
     """Get a random Urban Dictionary defenition [beta]"""
     rand = ud.random()
     for d in rand:
         await self.bot.say(d)
def get_random_definition():
    random_definitions = ud.random()
    one_definition = random.choice(random_definitions)
    formatted_text = one_definition.definition.replace("[", "")
    formatted_text = formatted_text.replace("]", "")
    return f"{one_definition.word.upper()}: {formatted_text}"
def urbandictionary_random_words(bot, trigger):
    bot.say(', '.join([x.word for x in ud.random()]))
예제 #27
0
파일: main.py 프로젝트: bevanator/Word_Bot
async def randomword(random):             # function name will be used as commands along with bot prefix
    rand = ud.random()
    for w in rand[:3]:
        await random.send(w.word)
        await random.send(w.definition)
        await random.send('-------------------------------------------------------------------------------------------------------------------------------------------------------------------')
def urbandictionary_random(bot, trigger):
    defs = ud.random()
    defs.sort(key=lambda x: x.upvotes, reverse=True)
    return urbandictionary_lookup(bot, trigger.nick, defs[0].word)