Esempio n. 1
0
    async def on_message(self, message):
        if message.author.id == self.user.id:
            return

        if message.content.startswith('..addtodo'):
            await message.channel.send(
                add_todo(makeStr(message.content.split()[1:])))

        if message.content.startswith('..todos'):
            if get_todos() == ['']:
                print('no todos')
                await message.channel.send('todos: ``` ```')
            else:
                await message.channel.send('todos: ```{}```'.format(
                    makeStr(get_todos(), '\n')))

        if message.content.startswith('..deltodo'):
            await message.channel.send(
                del_todo(makeStr(message.content.split()[1:])))

        if message.content.startswith('..cleartodos'):
            todofile = open('todos.txt', 'w')
            todofile.write('')
            todofile.close()
            await message.channel.send('cleared todos')
Esempio n. 2
0
def is_it_a_word(word):
    # this is supposed to filter out words that are @ing people or something
    # so structured like <@43985623487> or something

    word = list(word)

    hasLetter = False
    for char in word:
        if char.lower() == char and char.upper() == char: # a == a and A == a, this is only true for non-letter chars like , . ! etc
            word.remove(char)
        else: # it is a letter
            hasLetter = True

    if not hasLetter:
        return False

    if word[0] == '<' and word[len(word) - 1] == '>': # if it's tagging someone
        return False

    if makeStr(word[0:7]) == 'https://' or makeStr(word[0:6]) == 'http://': # if it's a link like https://youtu.be.something
        return False

    if len(word) > 199: # 199 characters is too long already but this ensures it'll never send something over the message limit
        return False

    return True
Esempio n. 3
0
    async def on_message(self, message):
        if message.content.startswith('..adminspam'):
            if message.author.id != 262637906865291264:
                await message.channel.send(
                    'you don\'t have permission to do that')
                return

            msg = message.content.split()
            msg.pop(0)

            # 40 <message>

            if len(msg) == 1:
                await message.channel.send(msg[0])
                return

            if len(msg) > 1:
                try:
                    number = int(msg[0])
                except:
                    await message.channel.send(
                        'incorrect syntax: should be `..adminspam <number> <msg>`'
                    )

                spamstr = makeStr(msg[1:])
                for i in range(number):
                    await message.channel.send(spamstr)
Esempio n. 4
0
    async def on_message(self, message):
        if message.author.id == self.user.id:
            return
        
        if message.content.startswith('..clearfile'):
            clear_file()
            print('cleared word file')
            await message.channel.send('cleared word file')

        if message.content.startswith('..addword'):
            with open('words.txt','a') as word_file:
                word = ' '.join(message.content.split()[1:])
                word_file.write(' ' + word)
            await message.channel.send('added word `' + word + '` to file')

        if message.content.startswith('..words'):
            with open('words.txt','r') as word_file:
                words = word_file.read()
                await message.channel.send('words in file: ```' + words + '```')

        if message.content.startswith('..delword'):
            words = []
            with open('words.txt','r') as word_file:
                words = word_file.read().split()
            to_delete = message.content.split()[1]
            deleted = False
            found = False
            while not deleted:
                if to_delete in words:
                    words.remove(to_delete)
                    found = True
                else:
                    break

            with open('words.txt','w') as word_file:
                word_file.write(makeStr(words))
            
            if found:
                await message.channel.send('deleted word ' + to_delete)
            else:
                await message.channel.send(to_delete + ' wasnt in the word file')

        if do_i_get_word():
            msg = message.content.split()
            if len(msg) > 1:
                word_to_get = msg[random.randint(0, (len(msg) - 1))]
            else:
                return
            if is_it_a_word(word_to_get):
                print('new word: ' + word_to_get)
                add_word(word_to_get)
            else:
                print('it wasnt a word: ' + word_to_get)
        
        if re.search('<@493938037189902358>', message.content):
            await message.channel.send(message.author.mention + ' ' + say_something())
Esempio n. 5
0
def del_todo(todo, file='todos.txt'):
    todofile = open(file, 'r')

    current_todos = todofile.read().split('\n')
    todofile.close()

    removed = False

    for thing in current_todos:
        print('comparing {} and {}.'.format(thing, todo))
        if str(thing) == str(todo):
            print('they are equal, removing {}'.format(todo))
            current_todos.remove(todo)
            removed = True

    if not removed:
        return ('`{}` isn\'t in the todos file'.format(todo))

    todofile = open(file, 'w')
    todofile.write(makeStr(current_todos, '\n'))
    todofile.close()
    return ('successfully delted todo `{}`'.format(todo))
Esempio n. 6
0
    async def on_message(self, message):
        if message.author.id == self.user.id:
            return

        if message.content.startswith('..banned'):
            await message.channel.send('channels banned: ' +
                                       ' '.join(banned_channels))
            return

        if message.content.startswith('..ban'):
            if not message.content.split()[1] in banned_channels:
                banned_channels.append(message.content.split()[1])
                await message.channel.send(
                    'added channel **{}** to ban list'.format(
                        message.content.split()[1]))
            else:
                await message.channel.send(
                    'channel **{}** already banned'.format(
                        message.content.split()[1]))

        if message.content.startswith('..unban'):
            if not message.content.split()[1] in banned_channels:
                await message.channel.send('channel **{}** not banned'.format(
                    message.content.split()[1]))
            else:
                banned_channels.remove(message.content.split()[1])
                await message.channel.send('channel **{}** unbanned'.format(
                    message.content.split()[1]))

        if message.channel.name in banned_channels:
            return

        if message.content.startswith('..spamall'):
            await message.channel.send('f**k no')
            return
            channels = message.guild.channels
            print(channels)

            try:
                times = int(
                    message.content.split()[len(message.content.split) - 1])
            except:
                times = 5
            print(times)

            for channel in channels:
                print('trying channel ' + str(channel))
                if channel in banned_channels:
                    print('channel is banned, skipping')
                    continue
                try:
                    for i in range(times):
                        await channel.send(' '.join(
                            message.content.split()[1:-1]))
                except:
                    print('failed')
            print('done')
            return

        if message.content.startswith('..spam'):
            if message.author.id == 493938037189902358:
                return
            if message.author.id == minh_id:
                await message.channel.send('no minh you dont get to spam')
                return
            if re.search('@everyone', message.content):
                await message.channel.send('no pinging everyone')
                return

            msg = message.content.split()
            if len(msg) < 2:
                await message.channel.send('you need to put a message to spam')
            if len(msg) > 2:
                try:
                    number = int(msg[len(msg) - 1])
                except:
                    for i in range(0, 5):
                        await message.channel.send(makeStr(msg[1:]))
                    return
                msg.pop(len(msg) - 1)
                msg.pop(0)
                pstr = ''
                for item in msg:
                    pstr += item + ' '
                for i in range(0, number):
                    await message.channel.send(pstr)

        if message.content.startswith('..dmspam'):
            if message.author.id != owner:
                await message.channel.send(
                    'you don\'t have permission to do that!')
                return

            msg = message.content.split()
            msg.pop(0)

            # ..dmspam -u @user -m <message>

            if len(msg) < 2:
                await message.channel.send(
                    'proper message formatting: `..dmspam @user <message>`')
                return

            if len(msg) == 2:
                amount = 5
            else:
                amount = int(msg[(len(msg) - 1)])
            msg.pop(len(msg) - 1)
            pguild = message.author.guild

            player_tag = list(msg[0])
            fpt = ''
            #print(player_tag)
            for item in player_tag:
                #print('inting ' + item)
                try:
                    #print(int(item))
                    fpt += str(int(item))
                except:
                    fpt += ''
            #print(fpt)
            fpt = int(fpt)

            to_ping = pguild.get_member(fpt)
            to_send = makeStr(msg[1:])

            for i in range(amount):
                await to_ping.send(to_send)