예제 #1
0
파일: rip.py 프로젝트: mralext20/apex-sigma
class Rip(Plugin):
    is_global = True
    log = create_logger('rip')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'rip'):
            result = ''
            mentioned_avatar = ''
            for user in message.mentions:
                result = result + 'The Avatar of ' + user.display_name + " is " + user.avatar_url
                mentioned_avatar = user.avatar_url
            cmd_name = 'Rest In Peace'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            user_avatar = requests.get(mentioned_avatar).content
            base = Image.open('img/rip/base.png')
            tomb = Image.open('img/rip/tombstone.png')
            avatar_img = Image.open(BytesIO(user_avatar))
            base.paste(avatar_img, (52, 160))
            base.paste(tomb, (0, 0), tomb)
            base.save('cache/rip/rip_' + message.author.id + '.png')
            await self.client.send_file(
                message.channel, 'cache/rip/rip_' + message.author.id + '.png')
예제 #2
0
파일: osu.py 프로젝트: mralext20/apex-sigma
class OSU(Plugin):
    is_global = True
    log = create_logger('osu')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'osu'):
            await self.client.send_typing(message.channel)
            cmd_name = 'Osu'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            try:
                osu_input = message.content[len(pfx) + len('osu') + 1:]
                sig_url = 'https://lemmmy.pw/osusig/sig.php?colour=pink&uname=' + osu_input
                sig = requests.get(sig_url).content
                sig_img = Image.open(BytesIO(sig))
                sig_img.save('cache/img_' + message.author.id + '.png')
                await self.client.send_file(
                    message.channel, 'cache/img_' + message.author.id + '.png')
                os.remove('cache/img_' + message.author.id + '.png')
            except:
                await self.client.send_message(
                    message.channel,
                    'Something went wrong or the user was not found.')
예제 #3
0
class Wikipedia(Plugin):
    is_global = True
    log = create_logger('wikipedia')

    async def on_message(
        self,
        message,
        pfx,
    ):
        if message.content.startswith(pfx + 'wiki' + ' '):
            await self.client.send_typing(message.channel)
            cmd_name = 'Wikipedia Search'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            q = str(message.content[len(pfx) + len('wiki') + 1:]).lower()
            result = wikipedia.summary(q)
            if result is not None:
                out_text = 'Your search for `' + q + '` results:\n```'
                out_text += '\n' + result
                out_text += '\n```'
                if len(out_text) >= 650:
                    out_text = out_text[:650] + '...\n```'
            else:
                out_text = 'Nothing could be found...'
            await self.reply(out_text)
예제 #4
0
class Reddit(Plugin):

    is_global = True
    log = create_logger('reddit')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'reddit '):
            await self.client.send_typing(message.channel)
            cmd_name = 'Reddit'
            try:
                self.log.info('User %s [%s] on server %s [%s], used the ' + cmd_name + ' command on #%s channel',
                              message.author,
                              message.author.id, message.server.name, message.server.id, message.channel)
            except:
                self.log.info('User %s [%s], used the ' + cmd_name + ' command.',
                              message.author,
                              message.author.id)
            q = message.content[len(pfx) + len('reddit') + 1:]
            req = praw.Reddit(user_agent='Apex Sigma')
            try:
                posts = req.get_subreddit(str(q)).get_hot(limit=100)
                url_list = []
                for post in posts:
                    url_list.append(post.url)
                out_tex = random.choice(url_list)
                await self.reply(out_tex)
            except Exception as err:
                await self.reply(str(err))
예제 #5
0
class Table(Plugin):
    is_global = True
    log = create_logger('table')

    async def on_message(self, message, pfx):
        if '(╯°□°)╯︵ ┻━┻' in message.content:
            cmd_name = 'TableFlip'
            table = [
                '┬─┬ ノ( ^_^ノ)', '┬─┬ ノ(° -°ノ)', '┬─┬ ノ(゜-゜ノ)', '┬─┬ ノ(ಠ\_ಠノ)',
                '┻━┻~~~~  ╯(°□° ╯)', '┻━┻====  ╯(°□° ╯)',
                '┣ヘ(^▽^ヘ)Ξ(゚▽゚*)ノ┳━┳ There we go~♪', ' ┬──┬ ¯\_(ツ)',
                '(ヘ・_・)ヘ┳━┳', 'ヘ(´° □°)ヘ┳━┳', '┣ヘ(≧∇≦ヘ)… (≧∇≦)/┳━┳'
            ]
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            await self.client.send_message(message.channel,
                                           random.choice(table))
예제 #6
0
class ITAD(Plugin):
    is_global = True
    log = create_logger('itad')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'itad'):
            await self.client.send_typing(message.channel)
            cmd_name = 'IsThereAnyDeal'
            try:
                self.log.info('User %s [%s] on server %s [%s], used the ' + cmd_name + ' command on #%s channel',
                              message.author,
                              message.author.id, message.server.name, message.server.id, message.channel)
            except:
                self.log.info('User %s [%s], used the ' + cmd_name + ' command.',
                              message.author,
                              message.author.id)
            request = requests.get('https://api.isthereanydeal.com/v01/deals/list/eu2/?key=' + ITADKey + '&country=RS&offset=0&limit=20').json()
            try:
                deal_text = 'Latest 10 Deals:\n```'
                currency = request['.meta']['currency']
                for i in range(0, 10):
                    game_title = request['data']['list'][i]['title']
                    shop_name = request['data']['list'][i]['shop']['name']
                    price_old = str(request['data']['list'][i]['price_old'])
                    price_new = str(request['data']['list'][i]['price_new'])
                    price_cut = str(request['data']['list'][i]['price_cut'])
                    deal_text += '\n#' + str(i+1) + ': ' + game_title + ' on ' + shop_name + ' for ' + price_new + currency + '/' + price_old + ' (' + price_cut + '%)'
                deal_text += '\n```'
                print(deal_text)
                await self.client.send_message(message.channel, deal_text)
            except:
                await self.client.send_message(message.channel, 'We seem to have ran into an error.')
예제 #7
0
class Cleverbot(Plugin):
    is_global = True
    log = create_logger('cleverbot')

    async def on_message(self, message, pfx):
        if message.content.startswith(self.client.user.mention):
            await self.client.send_typing(message.channel)
            cmd_name = 'Kiss Me'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            try:
                clv_input = message.content[len(self.client.user.mention):]
                cb = cleverbot.Cleverbot()
                response = cb.ask(clv_input)
                await asyncio.sleep(len(response) * 0.0145)
                await self.client.send_message(
                    message.channel,
                    '<@' + message.author.id + '> ' + response)
            except:
                await self.client.send_message(
                    message.channel, 'Sorry <@' + message.author.id +
                    '>, my brain isn\'t working at the moment give me some time to catch my breath...'
                )
예제 #8
0
    def __init__(self, client):
        super().__init__(client)

        self.is_global = True
        self.log = create_logger('github')
        self.api_base_url = 'https://api.github.com'
        self.links = {}
        self.webthread = WebServer(self).run()
예제 #9
0
class IMDB(Plugin):
    is_global = True
    log = create_logger('imdb')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'imdb'):
            await self.client.send_typing(message.channel)
            cmd_name = 'Internet Movie DataBase'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            imdb_imput = message.content[len(pfx) + len('imdb') + 1:]
            request = requests.get('http://www.omdbapi.com/?t=' + imdb_imput +
                                   '&y=&plot=short&r=json').json()
            try:
                title = request['Title']
                rated = request['Rated']
                released = request['Released']
                runtime = request['Runtime']
                genre = request['Genre']
                awards = request['Awards']
                score = request['Metascore']
                rating = request['imdbRating']
                language = request['Language']
                country = request['Country']
                writers = request['Writer']
                directors = request['Director']
                actors = request['Actors']
                plot = request['Plot']
                movie_text = ('```\nTitle: ' + title + '\nReleased: ' +
                              released + '\nRated: ' + rated + '\nRuntime: ' +
                              runtime + '\nGenre: ' + genre + '\nCountry: ' +
                              country + '\nLanguage: ' + language +
                              '\nAwards: ' + awards + '\nWriters: ' + writers +
                              '\nDirectors: ' + directors + '\nActors: ' +
                              actors + '\nMetascore: ' + score +
                              '\nIMDB Rating: ' + rating + '```')
                await self.client.send_message(
                    message.channel,
                    movie_text + '\nPlot:\n```\n' + plot + '\n```')
            except:
                if imdb_imput == '':
                    await self.client.send_message(
                        message.channel, 'You need to specify a movie!')
                else:
                    try:
                        await self.client.send_message(
                            message.channel, 'Error: ' + request['Error'])
                    except:
                        await self.client.send_message(
                            message.channel, 'Something went horribly wrong!')
예제 #10
0
class R34(Plugin):
    is_global = True
    log = create_logger('Rule34')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'rule34'):
            await self.client.send_typing(message.channel)
            cmd_name = 'Rule34'

            try:
                self.log.info('User %s [%s] on server %s [%s], used the ' + cmd_name + ' command on #%s channel',
                              message.author,
                              message.author.id, message.server.name, message.server.id, message.channel)
            except:
                self.log.info('User %s [%s], used the ' + cmd_name + ' command.',
                              message.author,
                              message.author.id)

            try:
                ch_id = str(message.channel.id)
                query = 'SELECT PERMITTED FROM NSFW WHERE CHANNEL_ID=?'
                perms = self.db.execute(query, ch_id)

                permed = 'No'
                for row in perms:
                    permed = row[0]
            except DatabaseError:
                permed = 'No'
            except:
                permed = 'No'

            if permed == 'Yes':
                permitted = True
            else:
                permitted = False

            tags = message.content[len(pfx) + len('rule34') + 1:]

            try:
                if tags == '':
                    tags = 'nude'
                else:
                    pass

                r34_url = 'http://rule34.xxx/index.php?page=dapi&s=post&q=index&tags=' + tags.replace(' ', '+')
                data = requests.get(r34_url)
                posts = html.fromstring(data.content)
                choice = random.choice(posts)

                if permitted is True:
                    await self.client.send_message(message.channel,
                                                   str(choice.attrib['file_url']).replace('//img', 'http://img'))
                else:
                    await self.client.send_message(message.channel,
                                                   'This channel does not have the NSFW Module permitted!')
            except:
                await self.client.send_message(message.channel, 'Nothing found...')
예제 #11
0
class BulkMSG(Plugin):
    is_global = True
    log = create_logger('BulkMSG')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'bulkmsg'):
            await self.client.send_typing(message.channel)
            cmd_name = 'Bulk Message'
            # Start Logger
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            # Eng Logger
            input_message = message.content[len(pfx) + len('bulkmsg') + 1:]
            try:
                if message.author.id in permitted_id:
                    await self.client.send_message(
                        message.channel,
                        'Starting bulk sending... Stand by for confirmation')
                    out = ''
                    printer = ''
                    no_s = 0
                    no_f = 0
                    for user in self.client.get_all_members():
                        if user.server.id == message.server.id and user.id != self.client.user.id:
                            try:
                                await self.client.start_private_message(user)
                                await self.client.send_message(
                                    user, input_message)
                                out += '\nSuccess: ' + user.name
                            except Exception as err:
                                out += '\nFailed: ' + user.name
                                printer += '\nFailed: ' + user.name + '\nReason: ' + str(
                                    err)
                                no_f += 1
                    await self.client.send_message(
                        message.channel,
                        'Bulk message sending complete...\n' + out[:1900])
                    print(printer)
                    print('Succeeded: ' + str(no_s))
                    print('Failed: ' + str(no_f))
                else:
                    await self.client.send_message(
                        message.channel,
                        'Not enough permissions, due to security issues, only a permitted user can use this for now...'
                    )
            except:
                print(
                    'Something went wrong. Most likely a basic error with the sending.'
                )
예제 #12
0
class Gelbooru(Plugin):
    is_global = True
    log = create_logger('Gelbooru')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'gelbooru'):
            await self.client.send_typing(message.channel)
            cmd_name = 'Gelbooru'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            try:
                perms = self.db.execute(
                    "SELECT PERMITTED from NSFW where CHANNEL_ID=?;",
                    str(message.channel.id))
                permed = 'No'
                for row in perms:
                    permed = row[0]
            except DatabaseError:
                permed = 'No'
            except SyntaxError:
                permed = 'No'
            if permed == 'Yes':
                permitted = True
            else:
                permitted = False
            tags = message.content[len(pfx) + len('gelbooru') + 1:]
            try:
                if tags == '':
                    tags = 'nude'
                else:
                    pass
                gelbooru_url = 'http://gelbooru.com/index.php?page=dapi&s=post&q=index&tags=' + tags.replace(
                    ' ', '+')
                data = requests.get(gelbooru_url)
                posts = html.fromstring(data.content)
                choice = random.choice(posts)

                if permitted is True:
                    await self.client.send_message(message.channel,
                                                   choice.attrib['file_url'])
                else:
                    await self.client.send_message(
                        message.channel,
                        'This channel does not have the NSFW Module permitted!'
                    )
            except:
                await self.client.send_message(message.channel,
                                               'Nothing found...')
예제 #13
0
class Reminder(Plugin):
    is_global = True
    log = create_logger('remind')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'remind' + ' '):
            await self.client.send_typing(message.channel)
            cmd_name = 'Reminder'
            self.log.info(
                'User %s [%s] on server %s [%s], used the ' + cmd_name +
                ' command on #%s channel', message.author, message.author.id,
                message.server.name, message.server.id, message.channel)
            remind_input = message.content[len(pfx) + len('remind') + 1:]
            try:
                time_q, ignore, remind_text = str(remind_input).partition(' ')
            except:
                remind_text = 'Nothing'
                time_q = '0'
                await self.client.send_message(
                    message.channel,
                    'Input missing parameters.\nThe command format is **' +
                    pfx + 'remind' +
                    '[time in seconds] [message]**\nExample: ' + pfx +
                    'remind' + ' 60 Leeroy jenkins!')
            try:
                time_conv = time.strftime('%H:%M:%S', time.gmtime(int(time_q)))
                if remind_text == '':
                    remind_text = 'Nothing'
                confirm_msg = await self.client.send_message(
                    message.channel,
                    'Okay! Reminder for\n[' + bold(str(remind_text)) +
                    ']\nis set and will be activated in `' + time_conv +
                    '`! :clock:')
                time_num = int(time_q)
                while time_num > 0:
                    time_conv_second = time.strftime(
                        '%H:%M:%S', time.gmtime(int(time_num)))
                    await self.client.edit_message(
                        confirm_msg,
                        'Okay! Reminder for\n[' + bold(str(remind_text)) +
                        ']\nis set and will be activated in `' +
                        time_conv_second + '`! :clock:')
                    await asyncio.sleep(10)
                    time_num -= 10
                await self.client.send_typing(message.channel)
                await self.client.send_message(
                    message.channel, '<@' + message.author.id +
                    '> Time\'s up! Let\'s do this! :clock: \n :exclamation: ' +
                    bold(str(remind_text)) + ' :exclamation: ')
            except:
                await self.client.send_message(
                    message.channel,
                    'Something went wrong with setting the timer, are you sure you inputed a number?'
                )
예제 #14
0
class LastFM(Plugin):
    is_global = True
    log = create_logger('lastfm')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'lastfm' + ' '):
            await self.client.send_typing(message.channel)
            cmd_name = 'LastFM'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            lfm_input = message.content[len(pfx) + len('lastfm') + 1:]
            lfm_user, ignore, no_of_songs = lfm_input.partition(' ')
            lfm_url = 'http://ws.audioscrobbler.com/2.0/?method=user.gettoptracks&user='******'&api_key=' + LastFMAPIKey + '&format=json'
            lfm_data = requests.get(lfm_url).json()
            no_of_songs_in_list = len(lfm_data['toptracks']['track'])
            if no_of_songs == '':
                no_of_songs = 5
            try:
                top_tracks_text = ('Top ' + str(no_of_songs) +
                                   ' Tracks for the user `' + lfm_user +
                                   '`:\n```')
                for i in range(0, int(no_of_songs)):
                    name = lfm_data['toptracks']['track'][i]['name']
                    artist = lfm_data['toptracks']['track'][i]['artist'][
                        'name']
                    top_tracks_text += '\n #' + str(
                        i + 1) + ': ' + name + ' by ' + artist
                top_tracks_text += '\n```'
                await self.client.send_message(message.channel,
                                               top_tracks_text)
            except:
                try:
                    await self.client.send_message(message.channel,
                                                   lfm_data['message'])
                except:
                    if no_of_songs_in_list < int(no_of_songs):
                        await self.client.send_message(
                            message.channel, 'There are only: `' +
                            str(no_of_songs_in_list) + '` in your list.')
                    else:
                        await self.client.send_message(
                            message.channel,
                            'We seem to have ran into an error.')
예제 #15
0
class Steam(Plugin):
    is_global = True
    log = create_logger('steam')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'steam'):
            await self.client.send_typing(message.channel)
            cmd_name = 'Steam'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s] used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            try:
                steamapi = steam(SteamAPI)
                steam_input = message.content[len(pfx) + len('steam') + 1:]
                userID = steamapi.ISteamUser.ResolveVanityURL(
                    vanityurl=steam_input, url_type=1)['response']['steamid']
                summery = steamapi.ISteamUser.GetPlayerSummaries(
                    steamids=userID)['response']['players'][0]
                displayName = str(summery['personaname'])
                currentStamp = int(round(time.time()))
                creation = currentStamp - int(summery['timecreated'])
                lastOnline = currentStamp - int(summery['lastlogoff'])
                creation = int(creation) / 60 / 60 / 24 / 365.25
                lastOnline = time.strftime('%H:%M:%S',
                                           time.gmtime(int(lastOnline)))
                avatar = str(summery['avatarfull'])
                gameCount = str(
                    steamapi.IPlayerService.GetOwnedGames(
                        steamid=userID,
                        include_appinfo=False,
                        include_played_free_games=True,
                        appids_filter=-1)['response']['game_count'])
                await self.client.send_message(
                    message.channel,
                    str('Display name : ' + str(displayName) +
                        '\nTime on steam: ' + str(creation)[-1:] +
                        ' years\nlast Online: ' + str(lastOnline) +
                        ' ago\navatar: ' + str(avatar) +
                        '\nnumber of games: ' + str(gameCount)))
            except:
                await self.client.send_message(
                    message.channel,
                    'an unknown error ocoured. is that your vanity URL?')
예제 #16
0
class RewardOnMessage(Plugin):
    is_global = True
    log = create_logger('Add Point For Activity')

    async def on_message(self, message, pfx):
        if message.server is not None:
            query = "SELECT EXISTS (SELECT LVL, LV_CHECK, POINTS FROM POINT_SYSTEM WHERE USER_ID=?);"
            info_grabber_checker = self.db.execute(query,
                                                   str(message.author.id))

            for info_check in info_grabber_checker:
                if info_check[0] == 0:
                    query = "INSERT INTO POINT_SYSTEM (USER_ID, LVL, LV_CHECK, POINTS) VALUES (?, ?, ?, ?)"
                    self.db.execute(query, str(message.author.id), 0, 0, 0)
                    self.db.commit()
                else:
                    query = "SELECT LVL, LV_CHECK, POINTS FROM POINT_SYSTEM WHERE USER_ID=?"
                    number_grabber = self.db.execute(query,
                                                     str(message.author.id))
                    points = 0
                    level = 0
                    level_check = 0
                    for number in number_grabber:
                        level = number[0]
                        level_check = number[1]
                        points = number[2]

                    points_old = points
                    points_new = points_old + random.randint(1, 10)
                    level_point = format(
                        points_new / (601 + (69 * int(level))), ".0f")
                    level_should = int(level_point)

                    query = "UPDATE POINT_SYSTEM SET POINTS=? WHERE USER_ID=?"
                    self.db.execute(query, str(points_new),
                                    str(message.author.id))

                    if level_should > level_check:
                        query = "UPDATE POINT_SYSTEM SET LVL=? WHERE USER_ID=?"
                        self.db.execute(query, str(level_should),
                                        str(message.author.id))

                        query = "UPDATE POINT_SYSTEM SET LV_CHECK=? WHERE USER_ID=?"
                        self.db.execute(query, str(level_should),
                                        str(message.author.id))
                    else:
                        break

                    self.db.commit()
예제 #17
0
class SetAvatar(Plugin):
    is_global = True
    log = create_logger('Set Avatar')

    async def on_message(self, message, pfx, url=None, loop=None):
        if message.content.startswith(pfx + 'setavatar'):
            cmd_name = 'Set Avatar'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            if message.author.id in permitted_id:
                loop = asyncio.get_event_loop() if loop is None else loop
                aiosession = aiohttp.ClientSession(loop=loop)
                try:
                    if message.attachments:
                        thing = message.attachments[0]['url']
                    else:
                        thing = url.strip('<>')
                    try:
                        with aiohttp.Timeout(10):
                            async with aiosession.get(thing) as res:
                                await self.client.edit_profile(
                                    avatar=await res.read())
                    except:
                        return
                except AttributeError:
                    try:
                        thing = message.content[len(pfx) + len('setavatar') +
                                                1:]
                        try:
                            with aiohttp.Timeout(10):
                                async with aiosession.get(thing) as res:
                                    await self.client.edit_profile(
                                        avatar=await res.read())
                        except:
                            return
                    except ResourceWarning:
                        pass
                    except Exception as err:
                        await self.client.send_message(message.channel,
                                                       str(err))
예제 #18
0
class MakeCommandList(Plugin):
    is_global = True
    log = create_logger('mkcmdlist')

    async def on_message(self, message, pfx):
        if message.content == pfx + 'mkcmdlist':
            cmd_name = 'Make Command List'
            await self.client.send_typing(message.channel)
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            if message.author.id in permitted_id:
                out_text = 'Command |  Description |  Usage'
                out_text += '\n--------|--------------|-------'
                try:
                    import os
                    os.remove('COMMANDLIST.md')
                except:
                    pass
                with open('storage/help.json', 'r',
                          encoding='utf-8') as help_file:
                    help_data = help_file.read()
                    help_data = json.loads(help_data)
                for entry in help_data:
                    out_text += '\n`' + pfx + entry + '`  |  ' + help_data[
                        entry]['description'].replace(
                            '%pfx%', str(pfx)
                        ) + '  |  `' + help_data[entry]['usage'].replace(
                            '%pfx%', str(pfx)) + '`'
                with open("COMMANDLIST.md", "w") as text_file:
                    text_file.write(out_text)
                response = await self.client.send_message(
                    message.channel, 'Done :ok_hand:')
                await asyncio.sleep(5)
                await self.client.delete_message(response)
            else:
                response = await self.client.send_message(
                    message.channel, 'Unpermitted :x:')
                await asyncio.sleep(5)
                await self.client.delete_message(response)
예제 #19
0
class Sonarr(Plugin):
    is_global = True
    log = create_logger('sonarr')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'sonarr' + ' '):
            await self.client.send_typing(message.channel)
            cmd_name = 'Sonarr'
            try:
                self.log.info('User %s [%s] on server %s [%s], used the ' + cmd_name + ' command on #%s channel',
                              message.author,
                              message.author.id, message.server.name, message.server.id, message.channel)
            except:
                self.log.info('User %s [%s], used the ' + cmd_name + ' command.',
                              message.author,
                              message.author.id)
            snr_input = (str(message.content[len('sonarr') + 1 + len(pfx):]))
            snr_url = 'http://localhost:38082/api/' + snr_input + '?apikey=' + apikey
            snr_data = requests.get(snr_url).json()
            out_text = ''
            if snr_input == 'series':
                for entry in snr_data:
                    out_text += '\n' + entry['title'] + '\nDownload Progress: ' + str(round(
                        entry['episodeFileCount'] / entry[
                            'episodeCount'] * 100)) + '%\n[------------------------------]'
                with open("Output.txt", "w") as text_file:
                    text_file.write(out_text)
            elif snr_input == 'calendar':
                out_text += '```\n'
                for entry in snr_data:
                    out_text += '\nSeries: \"' + entry['series']['title'] + '\"\nEpisode Number: ' + str(
                        entry['episodeNumber']) + '\nEpisode Title:\"' + entry['title'] + '\"\nAir Date: ' + entry[
                                    'airDate'] + '\n'
                out_text += '\n```'
            elif snr_input == 'diskspace':
                out_text += '```\n'
                for entry in snr_data:
                    out_text += '\nName: ' + entry['label'] + '\nPath: ' + entry['path'] + '\nSpace: ' + str(
                        size(entry['freeSpace'])) + '(' + str(size(entry['totalSpace'])) + ')\n'
                out_text += '\n```'
            else:
                out_text = 'Invalid Parameter :bug:'
            if snr_input == 'series':
                await self.client.send_file(message.channel, 'Output.txt')
            else:
                await self.client.send_message(message.channel, out_text)
예제 #20
0
class MagicTheGathering(Plugin):

    is_global = True
    log = create_logger('mtg')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'mtg '):
            await self.client.send_typing(message.channel)
            q = message.content[len(pfx) + len('mtg') + 1:]
            cards = requests.get('https://api.magicthegathering.io/v1/cards?name=' + str(q)).json()
            n = 0
            list_text = 'List of cards found for `' + str(q) + '`:\n```'
            if len(cards['cards']) > 1:
                for entry in cards['cards']:
                    n += 1
                    list_text += '\n#' + str(n) + ' ' + entry['name']
                try:
                    await self.client.send_message(message.channel,
                                                   list_text + '\n```\nPlease type the number corresponding to the card of your choice `(1 - ' + str(
                                                       len(cards)) + ')`')
                except:
                    await self.client.send_message(message.channel,
                                                   'The list is way too big, please be more specific...')
                    return
                choice = await self.client.wait_for_message(author=message.author, channel=message.channel, timeout=20)
                await self.client.send_typing(message.channel)
                try:
                    card_no = int(choice.content) - 1
                except:
                    await self.client.send_message(message.channel, 'Not a number or timed out... Please start over')
                    return
                if choice is None:
                    return
            else:
                card_no = 0
            try:
                card_img_url = cards['cards'][card_no]['imageUrl']
                card_img_request = requests.get(card_img_url).content
                card_img = Image.open(BytesIO(card_img_request))
                card_img.save('cache/mtg_' + message.author.id + '.png')
                await self.client.send_file(message.channel, 'cache/mtg_' + message.author.id + '.png')
                os.remove('cache/mtg_' + message.author.id + '.png')
            except Exception as err:
                print(err)
                await self.client.send_message(message.channel, 'Something went wrong...')
예제 #21
0
class HentaiMS(Plugin):
    is_global = True
    log = create_logger('Hentai.MS')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'hentaims'):
            await self.client.send_typing(message.channel)
            cmd_name = 'Hentai.MS'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
예제 #22
0
class NSFWPermission(Plugin):
    is_global = True
    log = create_logger('nsfwpermit')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'nsfwpermit'):
            await self.client.send_typing(message.channel)
            cmd_name = 'NSFW Permit'

            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except Exception:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            admin_check = message.author.permissions_in(
                message.channel).administrator

            if admin_check is True:
                try:
                    query = "INSERT INTO NSFW (CHANNEL_ID, PERMITTED) VALUES (?, ?)"
                    self.db.execute(query, message.channel.id, 'Yes')
                    self.db.commit()
                    await self.client.send_message(
                        message.channel,
                        'The NSFW Module has been Enabled for <#' +
                        message.channel.id + '>! :eggplant:')
                except IntegrityError:
                    query = "DELETE from NSFW where CHANNEL_ID=?;"
                    self.db.execute(query, message.channel.id)
                    self.db.commit()
                    await self.client.send_message(
                        message.channel,
                        'Permission reverted to **Disabled**! :fire:')
            else:
                response = await self.client.send_message(
                    message.channel,
                    'Only an **Administrator** can manage permissions. :x:')
                await asyncio.sleep(10)
                await self.client.delete_message(response)
예제 #23
0
class VindictusScrollSearch(Plugin):
    is_global = True
    log = create_logger('es')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'es'):
            await self.client.send_typing(message.channel)
            cmd_name = 'Vindictus Scroll Search'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            scrl_input = (message.content[len(pfx) +
                                          len('es') + 1:]).lower().replace(
                                              '\'',
                                              '').replace(' ', '').replace(
                                                  ' es',
                                                  '').replace('enchant',
                                                              '').replace(
                                                                  'scroll', '')
            try:
                scrl_name = scrolls[scrl_input]['name']
                scrl_type = scrolls[scrl_input]['type']
                scrl_foreqp = scrolls[scrl_input]['foreqp']
                scrl_rank = scrolls[scrl_input]['rank']
                scrl_stats = ''
                for stats in scrolls[scrl_input]['stats']:
                    scrl_stats += '\n - ' + stats
                await self.client.send_message(
                    message.channel, '```' + '\nName: ' + scrl_name +
                    ' Enchant Scroll' + '\nType: ' + scrl_type +
                    '\nUsable On: ' + scrl_foreqp + '\nRank: ' + scrl_rank +
                    '\nStats: ' + scrl_stats + '\n```')
            except:
                await self.client.send_message(
                    message.channel,
                    'Either the scroll was not found, or the blacksmith guy broke it...\nFerghus, this is the last time you touch a scroll!'
                )
예제 #24
0
class Donators(Plugin):
    is_global = True
    log = create_logger('Donators')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'donors'):
            await self.client.send_typing(message.channel)
            cmd_name = 'Reminder'
            self.log.info(
                'User %s [%s] on server %s [%s], used the ' + cmd_name +
                ' command on #%s channel', message.author, message.author.id,
                message.server.name, message.server.id, message.channel)
            out_text = ''
            for donor in donators:
                out_text += '\n' + bold(str(donor)) + ' :ribbon: '
            await self.client.send_message(
                message.channel, out_text +
                '\nPlease consider donating by hitting the Donate button on this page: <https://auroraproject.xyz/donors/>!'
            )
예제 #25
0
class VoiceChangeDetection(Plugin):
    is_global = True
    log = create_logger('voice state')

    async def on_voice_state_update(self, before, after):
        global karaoke
        global karaoke_mod
        global karaoke_channel
        global karaoke_strict
        log = True
        if karaoke_mod:
            if karaoke:
                # print("karaoke's running")
                if (after.voice.voice_channel == None) or (after.voice.voice_channel.name != karaoke_channel):
                    if after.voice.mute == True:  # if he's muted
                        if log: print('not in karaoke channel, unmuting')
                        await self.client.server_voice_state(after, mute=False)  # unmute him
                try:
                    if after.voice.voice_channel.name == karaoke_channel:
                        if karaoke_strict:
                            for role in after.roles:  # iterate through roles of a user
                                if role.name in karaoke_override:
                                    if log: print('strict, overriden, aborting')
                                    return  # if user has an override role
                            if after.voice.mute == False:  # if user is not muted
                                if log: print('strict, not overriden, muting')
                                await self.client.server_voice_state(after, mute=True)  # otherwise mute the user
                                return

                        else:
                            if after.voice.mute == True:  # if user is muted
                                if log: print('not strict, ummuting')
                                await self.client.server_voice_state(after, mute=False)  # unmute
                                return

                except AttributeError:
                    pass  # catching an exception when user disconnects from voice (switches voice channel to None)

                if (after.voice.voice_channel == None) or (after.voice.voice_channel.name != karaoke_channel):
                    if after.voice.mute == True:  # if he's muted
                        if log: print('not in karaoke channel, unmuting')
                        await self.client.server_voice_state(after, mute=False)  # unmute him
예제 #26
0
class LevelCheck(Plugin):
    is_global = True
    log = create_logger('Level Check')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'level'):
            cmd_name = 'Level Check'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            try:
                user_id = message.mentions[0].id
                mid_msg = ' is'
                end_msg = 'has'
            except:
                user_id = message.author.id
                mid_msg = '. You are'
                end_msg = 'have'
            number_grabber = self.db.execute(
                "SELECT LVL, LV_CHECK, POINTS FROM POINT_SYSTEM WHERE USER_ID=?",
                str(user_id))
            self.db.commit()
            level = 0
            points = 0
            for number in number_grabber:
                level = number[0]
                points = number[2]
            await self.client.send_message(
                message.channel, 'Okay, <@' + user_id + '>' + mid_msg +
                ' **Level ' + str(level) + '** and currently ' + end_msg +
                ' **' + str(points) + ' Points**!')
예제 #27
0
class Echo(Plugin):
    is_global = True
    log = create_logger('echo')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'echo' + ' '):
            cmd_name = 'Echo'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            if message.author.id in permitted_id:
                await self.client.send_message(
                    message.channel, message.content[len('echo') + len(pfx):])
            else:
                await self.client.send_message(
                    message.channel, 'Sorry, <@' + message.author.id +
                    '>, you do not have permission to do that...')
예제 #28
0
class PMRedirect(Plugin):
    is_global = True
    log = create_logger('received pm')

    async def on_message(self, message, pfx):
        cid = self.client.user.id
        cmd_name = 'Private Message'
        if message.server is None:
            if str(message.author.id) == str(cid) or str(
                    message.author.id) in permitted_id:
                return
            else:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
                for user in self.client.get_all_members():
                    if str(user.id) == str(permitted_id[0]):
                        private_msg_to_owner = await self.client.start_private_message(
                            user=user)
                        await self.client.send_message(
                            private_msg_to_owner, '**' + message.author.name +
                            '** (ID: ' + message.author.id + '):\n```' +
                            message.content + '\n```')
                        return
예제 #29
0
파일: bns.py 프로젝트: mralext20/apex-sigma
class BladeAndSoul(Plugin):
    is_global = True
    log = create_logger('bnsstats')

    async def on_message(self, message, pfx):
        # Blade and Soul API
        if message.content.startswith(pfx + 'bnsstats'):
            cmd_name = 'Blade and Soul'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            await self.client.send_typing(message.channel)
            query = message.content[len('bnsstats') + 1 + len(pfx):]
            region = str(query[:query.find(' ')]).lower()
            if not region == 'na' and not region == 'eu':
                error_msg = 'Invalid Region: `' + region + '`\nThe command format is `' + pfx + 'bnsstats [region] [Character Name]`\nThe region can be `NA` or `EU` and the character name **CAN** contain spaces.'
                await self.client.send_message(message.channel, error_msg)
            else:
                error_msg = 'Something went wrong, API is unavailable or character does not exist.'
                username = str(query[query.find(' ') + 1:]).lower()
                profile = fetchStats(region, username)
                try:
                    # Summary
                    username = str(profile['Summary']['Username'])
                    nickname = str(profile['Summary']['Nickname'])
                    level = str(profile['Summary']['Level'])
                    world = str(profile['Summary']['World'])
                    ch_class = str(profile['Summary']['Class'])
                    faction = str(profile['Summary']['Faction'])
                    guild = str(profile['Summary']['Guild'])
                    # Attack Stats Basic
                    att_pwr = str(
                        profile['Attack Stats']['Attack Power']['Total'])
                    ev_att_rate = str(profile['Attack Stats']
                                      ['Evolved Attack Rate']['Total'])
                    pierc = str(profile['Attack Stats']['Piercing']['Total'])
                    pierc_def = str(profile['Attack Stats']['Piercing']
                                    ['Defense Piercing'])
                    pierc_block = str(
                        profile['Attack Stats']['Piercing']['Block Piercing'])
                    acc = str(profile['Attack Stats']['Accuracy']['Total'])
                    acc_hr = str(
                        profile['Attack Stats']['Accuracy']['Hit Rate'])
                    conc = str(
                        profile['Attack Stats']['Concentration']['Total'])
                    crit_hit = str(
                        profile['Attack Stats']['Critical Hit']['Total'])
                    crit_hit_rate = str(profile['Attack Stats']['Critical Hit']
                                        ['Critical Rate'])
                    crit_dmg = str(
                        profile['Attack Stats']['Critical Damage']['Total'])
                    crit_dmg_dmg = str(profile['Attack Stats']
                                       ['Critical Damage']['Increase Damage'])
                    mast = str(profile['Attack Stats']['Mastery']['Total'])
                    add_dmg = str(
                        profile['Attack Stats']['Additional Damage']['Total'])
                    threat = str(profile['Attack Stats']['Threat']['Total'])
                    fire_dmg = str(
                        profile['Attack Stats']['Flame Damage']['Total'])
                    cold_dmg = str(
                        profile['Attack Stats']['Frost Damage']['Total'])
                    # Defense Stats Basic
                    hp = str(profile['Defense Stats']['HP']['Total'])
                    def_tot = str(profile['Defense Stats']['Defense']['Total'])
                    def_dmg_redu = str(profile['Defense Stats']['Defense']
                                       ['Damage Reduction'])
                    ev_def = str(
                        profile['Defense Stats']['Evolved Defense']['Total'])
                    evasion = str(profile['Defense Stats']['Evasion']['Total'])
                    evasion_rate = str(
                        profile['Defense Stats']['Evasion']['Evasion Rate'])
                    block = str(profile['Defense Stats']['Block']['Total'])
                    block_rate = str(
                        profile['Defense Stats']['Block']['Block Rate'])
                    crit_def = str(
                        profile['Defense Stats']['Critical Defense']['Total'])
                    crit_def_rate = str(
                        profile['Defense Stats']['Critical Defense']
                        ['Critical Evasion Rate'])
                    will = str(profile['Defense Stats']['Willpower']['Total'])
                    dmg_redu = str(
                        profile['Defense Stats']['Damage Reduction']['Total'])
                    regen = str(
                        profile['Defense Stats']['Health Regen']['Total'])
                    rec = str(profile['Defense Stats']['Recovery']['Total'])
                    nerf_def = str(
                        profile['Defense Stats']['Debuff Defense']['Total'])
                    # Texts
                    summary_text = (':ticket: Summary:\n```' + '\nUsername: '******'\nNickname: ' + nickname +
                                    '\nLevel: ' + level + '\nWorld: ' + world +
                                    '\nClass: ' + ch_class + '\nFaction: ' +
                                    faction + '\nGuild: ' + guild + '\n```')

                    attack_stats_text = (
                        ':crossed_swords: Attack Stats: \n```' +
                        '\nAttack Power: ' + att_pwr +
                        '\nEvolved Attack Rate: ' + ev_att_rate +
                        '\nPiercing: ' + pierc + '(DEF:' + pierc_def +
                        '|Block: ' + pierc_block + ')' + '\nAccuracy: ' + acc +
                        '(' + acc_hr + ')' + '\nConcentrationr: ' + conc +
                        '\nCrtitical Hit: ' + crit_hit + '(' + crit_hit_rate +
                        ')' + '\nCritical Damage: ' + crit_dmg + '(' +
                        crit_dmg_dmg + ')' + '\nMastery: ' + mast +
                        '\nAdditional Damage: ' + add_dmg + '\nThreat: ' +
                        threat + '\nFlame Damage: ' + fire_dmg +
                        '\nFrost Damage: ' + cold_dmg + '\n```')
                    def_stats_text = (
                        ':shield: Defense Stats: \n```' + '\nHP: ' + hp +
                        '\nDefense: ' + def_tot + '(' + def_dmg_redu + ')' +
                        '\nEvolved Defense: ' + ev_def + '\nEvasion: ' +
                        evasion + '(' + evasion_rate + ')' + '\nBlock: ' +
                        block + '(' + block_rate + ')' +
                        '\nCritical Defense: ' + crit_def + '(' +
                        crit_def_rate + ')' + '\nWillpower: ' + will +
                        '\nDamage Reduction: ' + dmg_redu +
                        '\nHealth Regen: ' + regen + '\nRecovery: ' + rec +
                        '\nDebuff Defense: ' + nerf_def + '\n```')
                    await self.client.send_message(
                        message.channel,
                        summary_text + attack_stats_text + def_stats_text)
                    # await client.send_message(message.channel, summary_text)
                    # await client.send_message(message.channel, attack_stats_text)
                    # await client.send_message(message.channel, def_stats_text)
                except:
                    await self.client.send_message(message.channel, error_msg)
            #print('CMD [' + cmd_name + '] > ' + initiator_data)
        # Blade and Soul Attack Details API
        elif message.content.startswith(pfx + 'bnsatt'):
            cmd_name = 'Blade and Soul Attack Details'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            await self.client.send_typing(message.channel)
            query = message.content[len('bnsatt') + 1 + 3 + len(pfx):]
            region = str(query[:query.find(' ')]).lower()
            if not region == 'na' and not region == 'eu':
                error_msg = 'Invalid Region: `' + region + '`\nThe command format is `' + pfx + 'bnsatt [region] [Character Name]`\nThe region can be `NA` or `EU` and the character name **CAN** contain spaces.'
                await self.client.send_message(message.channel, error_msg)
            else:
                error_msg = 'Something went wrong, API is unavailable or character does not exist.'
                username = str(query[query.find(' ') + 1:]).lower()
                profile = fetchStats(region, username)
                try:
                    # Summary
                    nickname = str(profile['Summary']['Nickname'])
                    # Attack Stats
                    att_pwr = str(
                        profile['Attack Stats']['Attack Power']['Total'])
                    att_pwr_base = str(
                        profile['Attack Stats']['Attack Power']['Base'])
                    att_pwr_eqp = str(
                        profile['Attack Stats']['Attack Power']['Equipped'])
                    ev_att_rate = str(profile['Attack Stats']
                                      ['Evolved Attack Rate']['Total'])
                    ev_att_rate_base = str(
                        profile['Attack Stats']['Evolved Attack Rate']['Base'])
                    ev_att_rate_eqp = str(profile['Attack Stats']
                                          ['Evolved Attack Rate']['Equipped'])
                    pierc = str(profile['Attack Stats']['Piercing']['Total'])
                    pierc_base = str(
                        profile['Attack Stats']['Piercing']['Base'])
                    pierc_eqp = str(
                        profile['Attack Stats']['Piercing']['Equipped'])
                    pierc_def = str(profile['Attack Stats']['Piercing']
                                    ['Defense Piercing'])
                    pierc_block = str(
                        profile['Attack Stats']['Piercing']['Block Piercing'])
                    acc = str(profile['Attack Stats']['Accuracy']['Total'])
                    acc_base = str(profile['Attack Stats']['Accuracy']['Base'])
                    acc_eqp = str(
                        profile['Attack Stats']['Accuracy']['Equipped'])
                    acc_hr = str(
                        profile['Attack Stats']['Accuracy']['Hit Rate'])
                    conc = str(
                        profile['Attack Stats']['Concentration']['Total'])
                    conc_base = str(
                        profile['Attack Stats']['Concentration']['Base'])
                    conc_eqp = str(
                        profile['Attack Stats']['Concentration']['Equipped'])
                    conc_bsp = str(profile['Attack Stats']['Concentration']
                                   ['Block Skill Piercing'])
                    conc_csp = str(profile['Attack Stats']['Concentration']
                                   ['Counter Skill Piercing'])
                    crit_hit = str(
                        profile['Attack Stats']['Critical Hit']['Total'])
                    crit_hit_base = str(
                        profile['Attack Stats']['Critical Hit']['Base'])
                    crit_hit_eqp = str(
                        profile['Attack Stats']['Critical Hit']['Equipped'])
                    crit_hit_rate = str(profile['Attack Stats']['Critical Hit']
                                        ['Critical Rate'])
                    crit_dmg = str(
                        profile['Attack Stats']['Critical Damage']['Total'])
                    crit_dmg_base = str(
                        profile['Attack Stats']['Critical Damage']['Base'])
                    crit_dmg_eqp = str(
                        profile['Attack Stats']['Critical Damage']['Equipped'])
                    crit_dmg_dmg = str(profile['Attack Stats']
                                       ['Critical Damage']['Increase Damage'])
                    mast = str(profile['Attack Stats']['Mastery']['Total'])
                    add_dmg = str(
                        profile['Attack Stats']['Additional Damage']['Total'])
                    add_dmg_bonus = str(profile['Attack Stats']
                                        ['Additional Damage']['Damage Bonus'])
                    threat = str(profile['Attack Stats']['Threat']['Total'])
                    threat_base = str(
                        profile['Attack Stats']['Threat']['Base'])
                    threat_eqp = str(
                        profile['Attack Stats']['Threat']['Equipped'])
                    threat_bonus = str(
                        profile['Attack Stats']['Threat']['Threat Bonus'])
                    fire_dmg = str(
                        profile['Attack Stats']['Flame Damage']['Total'])
                    fire_dmg_base = str(
                        profile['Attack Stats']['Flame Damage']['Base'])
                    fire_dmg_eqp = str(
                        profile['Attack Stats']['Flame Damage']['Equipped'])
                    fire_dmg_rate = str(profile['Attack Stats']['Flame Damage']
                                        ['Flame Damage Rate'])
                    cold_dmg = str(
                        profile['Attack Stats']['Frost Damage']['Total'])
                    cold_dmg_base = str(
                        profile['Attack Stats']['Frost Damage']['Base'])
                    cold_dmg_eqp = str(
                        profile['Attack Stats']['Frost Damage']['Equipped'])
                    cold_dmg_rate = str(profile['Attack Stats']['Frost Damage']
                                        ['Frost Damage Rate'])
                    attack_stats_text = (
                        ':crossed_swords: Attack Stats for **' + nickname +
                        '**: \n```' + '\nAttack Power: ' + att_pwr +
                        '\n(Base: ' + att_pwr_base + '|Equipped: ' +
                        att_pwr_eqp + ')' + '\nEvolved Attack Rate: ' +
                        ev_att_rate + '\n(Base: ' + ev_att_rate_base +
                        '|Equipped: ' + ev_att_rate_eqp + ')' +
                        '\nPiercing: ' + pierc + '\n(Base: ' + pierc_base +
                        '|Equipped: ' + pierc_eqp + '|DEF: ' + pierc_def +
                        '|Block: ' + pierc_block + ')' + '\nAccuracy: ' + acc +
                        '\n(Base: ' + acc_base + '|Equipped: ' + acc_eqp +
                        '|Rate: ' + acc_hr + ')' + '\nConcentrationr: ' +
                        conc + '\n(Base: ' + conc_base + '|Equipped: ' +
                        conc_eqp + '|BSP: ' + conc_bsp + '|CSP: ' + conc_csp +
                        ')' + '\nCrtitical Hit: ' + crit_hit + '\n(Base: ' +
                        crit_hit_base + '|Equipped: ' + crit_hit_eqp +
                        '|Rate:' + crit_hit_rate + ')' +
                        '\nCritical Damage: ' + crit_dmg + '\n(Base: ' +
                        crit_dmg_base + '|Equipped: ' + crit_dmg_eqp +
                        '|DMG: ' + crit_dmg_dmg + ')' + '\nMastery: ' + mast +
                        '\nAdditional Damage: ' + add_dmg + '\n(DMG Bonus: ' +
                        add_dmg_bonus + ')' + '\nThreat: ' + threat +
                        '\n(Base: ' + threat_base + '|Equipped: ' +
                        threat_eqp + '|Bonus:' + threat_bonus + ')' +
                        '\nFlame Damage: ' + fire_dmg + '\n(Base: ' +
                        fire_dmg_base + '|Equipped: ' + fire_dmg_eqp +
                        '|Rate: ' + fire_dmg_rate + ')' + '\nFrost Damage: ' +
                        cold_dmg + '\n(Base: ' + cold_dmg_base +
                        '|Equipped: ' + cold_dmg_eqp + '|Rate: ' +
                        cold_dmg_rate + ')' + '\n```')
                    await self.client.send_message(message.channel,
                                                   attack_stats_text)
                except:
                    await self.client.send_message(message.channel, error_msg)
            #print('CMD [' + cmd_name + '] > ' + initiator_data)
        # Blade and Soul Defense Details API
        elif message.content.startswith(pfx + 'bnsdef'):
            cmd_name = 'Blade and Soul Defense Details'
            try:
                self.log.info(
                    'User %s [%s] on server %s [%s], used the ' + cmd_name +
                    ' command on #%s channel', message.author,
                    message.author.id, message.server.name, message.server.id,
                    message.channel)
            except:
                self.log.info(
                    'User %s [%s], used the ' + cmd_name + ' command.',
                    message.author, message.author.id)
            await self.client.send_typing(message.channel)
            query = message.content[len('bnsdef') + 1 + 3 + len(pfx):]
            region = str(query[:query.find(' ')]).lower()
            if not region == 'na' and not region == 'eu':
                error_msg = 'Invalid Region: `' + region + '`\nThe command format is `' + pfx + 'bnsdef [region] [Character Name]`\nThe region can be `NA` or `EU` and the character name **CAN** contain spaces.'
                await self.client.send_message(message.channel, error_msg)
            else:
                error_msg = 'Something went wrong, API is unavailable or character does not exist.'
                username = str(query[query.find(' ') + 1:]).lower()
                profile = fetchStats(region, username)
                try:
                    # Summary
                    nickname = str(profile['Summary']['Nickname'])
                    # Defense Stats
                    hp = str(profile['Defense Stats']['HP']['Total'])
                    hp_base = str(profile['Defense Stats']['HP']['Base'])
                    hp_eqp = str(profile['Defense Stats']['HP']['Equipped'])
                    def_tot = str(profile['Defense Stats']['Defense']['Total'])
                    def_base = str(profile['Defense Stats']['Defense']['Base'])
                    def_eqp = str(
                        profile['Defense Stats']['Defense']['Equipped'])
                    def_dmg_redu = str(profile['Defense Stats']['Defense']
                                       ['Damage Reduction'])
                    def_aoe = str(
                        profile['Defense Stats']['Defense']['AoE Defense'])
                    def_aoe_redu = str(profile['Defense Stats']['Defense']
                                       ['AoE Defense Reduction'])
                    ev_def = str(
                        profile['Defense Stats']['Evolved Defense']['Total'])
                    ev_def_base = str(
                        profile['Defense Stats']['Evolved Defense']['Base'])
                    ev_def_eqp = str(profile['Defense Stats']
                                     ['Evolved Defense']['Equipped'])
                    ev_def_rate = str(
                        profile['Defense Stats']['Evolved Defense']
                        ['Evolved Defense Rate'])
                    ev_def_aoe = str(profile['Defense Stats']
                                     ['Evolved Defense']['AoE Defense'])
                    ev_def_aoe_dmg_redu = str(
                        profile['Defense Stats']['Evolved Defense']
                        ['AoE Defense Reduction'])
                    evasion = str(profile['Defense Stats']['Evasion']['Total'])
                    evasion_base = str(
                        profile['Defense Stats']['Evasion']['Base'])
                    evastion_eqp = str(
                        profile['Defense Stats']['Evasion']['Equipped'])
                    evasion_rate = str(
                        profile['Defense Stats']['Evasion']['Evasion Rate'])
                    evasion_ctr = str(
                        profile['Defense Stats']['Evasion']['Counter Bonus'])
                    block = str(profile['Defense Stats']['Block']['Total'])
                    block_base = str(profile['Defense Stats']['Block']['Base'])
                    block_eqp = str(
                        profile['Defense Stats']['Block']['Equipped'])
                    block_rate = str(
                        profile['Defense Stats']['Block']['Block Rate'])
                    block_bonus = str(
                        profile['Defense Stats']['Block']['Block Bonus'])
                    block_dmg_redu = str(
                        profile['Defense Stats']['Block']['Damage Reduction'])
                    crit_def = str(
                        profile['Defense Stats']['Critical Defense']['Total'])
                    crit_def_rate = str(
                        profile['Defense Stats']['Critical Defense']
                        ['Critical Evasion Rate'])
                    crit_def_dmg_redu = str(
                        profile['Defense Stats']['Critical Defense']
                        ['Damage Reduction'])
                    will = str(profile['Defense Stats']['Willpower']['Total'])
                    dmg_redu = str(
                        profile['Defense Stats']['Damage Reduction']['Total'])
                    dmg_redu_dmg_redu = str(
                        profile['Defense Stats']['Damage Reduction']
                        ['Damage Reduction'])
                    regen = str(
                        profile['Defense Stats']['Health Regen']['Total'])
                    regen_in = str(
                        profile['Defense Stats']['Health Regen']['In Combat'])
                    regen_out = str(profile['Defense Stats']['Health Regen']
                                    ['Out of Combat'])
                    rec = str(profile['Defense Stats']['Recovery']['Total'])
                    rec_pt = str(
                        profile['Defense Stats']['Recovery']['Recovery'])
                    rec_add = str(profile['Defense Stats']['Recovery']
                                  ['Additional Recovery'])
                    rec_rate = str(
                        profile['Defense Stats']['Recovery']['Recovery Rate'])
                    nerf_def = str(
                        profile['Defense Stats']['Debuff Defense']['Total'])
                    nerf_def_rate = str(
                        profile['Defense Stats']['Debuff Defense']
                        ['Debuff Defense Rate'])
                    def_stats_text = (
                        ':shield: Defense Stats for **' + nickname +
                        '**: \n```' + '\nHP: ' + hp + '\n(Base: ' + hp_base +
                        '|Equipped: ' + hp_eqp + ')' + '\nDefense: ' +
                        def_tot + '\n(Base: ' + def_base + '|Equipped: ' +
                        def_eqp + '|DMG Reduction: ' + def_dmg_redu +
                        '|AoE DEF: ' + def_aoe + '|AoE DMG Reduction: ' +
                        def_aoe_redu + ')' + '\nEvolved Defense: ' + ev_def +
                        '\n(Base: ' + ev_def_base + '|Equipped: ' +
                        ev_def_eqp + '|Defense Rate: ' + ev_def_rate +
                        '|AoE Defense: ' + ev_def_aoe +
                        '|AoE DMG Reduction: ' + ev_def_aoe_dmg_redu + ')' +
                        '\nEvasion: ' + evasion + '\n(Base: ' + evasion_base +
                        '|Equipped: ' + evastion_eqp + '|Rate: ' +
                        evasion_rate + '|Counter Bonus: ' + evasion_ctr + ')' +
                        '\nBlock: ' + block + '\n(Base: ' + block_base +
                        '|Equipped: ' + block_eqp + '|DMG Redu: ' +
                        block_dmg_redu + '|Bonus: ' + block_bonus + '|Rate: ' +
                        block_rate + ')' + '\nCritical Defense: ' + crit_def +
                        '\n(Rate: ' + crit_def_rate + '|DMG Reduction: ' +
                        crit_def_dmg_redu + ')' + '\nWillpower: ' + will +
                        '\nDamage Reduction: ' + dmg_redu + '\n(DMG Redu: ' +
                        dmg_redu_dmg_redu + ')' + '\nHealth Regen: ' + regen +
                        '\n(Out of Combat: ' + regen_out + '|In Combat: ' +
                        regen_in + ')' + '\nRecovery: ' + rec +
                        '\n(Recovery: ' + rec_pt + '|Additional: ' + rec_add +
                        '|Rate: ' + rec_rate + ')' + '\nDebuff Defense: ' +
                        nerf_def + '\n(Rate: ' + nerf_def_rate + ')' + '\n```')
                    await self.client.send_message(message.channel,
                                                   def_stats_text)
                except:
                    await self.client.send_message(message.channel, error_msg)
예제 #30
0
class VNDBSearch(Plugin):
    is_global = True
    log = create_logger('vndb')

    async def on_message(self, message, pfx):
        if message.content.startswith(pfx + 'vndb' + ' '):
            await self.client.send_typing(message.channel)
            cmd_name = 'VNDB Search'
            try:
                self.log.info('User %s [%s] on server %s [%s], used the ' + cmd_name + ' command on #%s channel',
                              message.author,
                              message.author.id, message.server.name, message.server.id, message.channel)
            except:
                self.log.info('User %s [%s], used the ' + cmd_name + ' command.',
                              message.author,
                              message.author.id)
            vndb_input = (str(message.content[len('vndb') + 1 + len(pfx):]))
            try:
                sdata = await setsu.search_vndb('v', vndb_input)
                n = 0
                list_text = '```'
                for entry in sdata:
                    n += 1
                    list_text += '\n#' + str(n) + ' ' + entry['name']
                if len(sdata) > 1:
                    await self.client.send_message(message.channel, list_text + '\n```')
                    choice = await self.client.wait_for_message(author=message.author, channel=message.channel,
                                                                timeout=20)
                    await self.client.send_typing(message.channel)
                    try:
                        nh_no = int(choice.content) - 1
                    except:
                        await self.client.send_message(message.channel,
                                                       'Not a number or timed out... Please start over')
                else:
                    nh_no = 0
                kill = 0
            except Shosetsu.VNDBOneResult as err:
                choice_id = str(err)[len(vndb_input) + len('Search ') + len(' only had one result at ID '):].replace(
                    '.', '')
                kill = 1
            except Shosetsu.VNDBNoResults as err:
                await self.client.send_message(message.channel, err)
                kill = 0
            except:
                await self.client.send_message(message.channel, 'Error: ' + sys.exc_info()[0])
                kill = 0
            if kill == 1:
                pass
            else:
                choice_id = sdata[nh_no]['id']
            data = await setsu.get_novel(choice_id)
            vn_title = data['titles']['english']
            vn_img = data['img']
            vn_devs = ''
            for dev in data['developers']:
                vn_devs += str(dev)
            vn_desc = data['description']
            vn_id = data['id']
            vn_len = data['length']
            if data['tags']['erotic'] == None:
                nsfw = 'Yes'
            else:
                nsfw = 'No'
            if len(vn_desc) > 300:
                suffix = '...'
            else:
                suffix = ''
            if len(vn_title) > 21:
                tit_sfx = '...'
            else:
                tit_sfx = ''
            vn_cover_raw = requests.get(vn_img).content
            vn_cover_res = Image.open(BytesIO(vn_cover_raw))
            vn_cover = vn_cover_res.resize((231, 321), Image.ANTIALIAS)
            base = Image.open('img/ani/base_vn.png')
            overlay = Image.open('img/ani/overlay_vn.png')
            base.paste(vn_cover, (110, 0))
            base.paste(overlay, (0, 0), overlay)
            base.save('cache\\ani\\vn_' + message.author.id + '.png')
            try:
                await self.client.send_file(message.channel, 'cache\\ani\\vn_' + message.author.id + '.png')
                await self.client.send_message(message.channel,
                                               'Title: `' + vn_title + '`\nDescription:```\n' + vn_desc[
                                                                                                :300] + suffix + '\n```\nMore at: <https://vndb.org/' + vn_id + '>')
                os.remove('cache\\ani\\vn_' + message.author.id + '.png')
            except:
                await self.client.send_message(message.channel, 'Error: It goofed... =P')