diff --git a/KMS_Bot.py b/KMS_Bot.py index 0f9f21b..2aefa42 100644 --- a/KMS_Bot.py +++ b/KMS_Bot.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +from discord.ext import commands from module.help import * from module.simbol import * @@ -13,20 +13,35 @@ from module.linknunion import * from module.BodyAndMindTrainingCenter import * -client = discord.Client() +PREFIX = '#' +extension_list = ['module.help', 'module.simbol', + 'module.additional_options', 'module.defense_percentage_ignore', + 'module.level', 'module.hangang', + 'module.linknunion', + 'module.BodyAndMindTrainingCenter'] -@client.event +todolist=['module.gambling','module.information','module.homepage'] + +bot = commands.Bot(command_prefix=PREFIX) +bot.remove_command('help') + +for extension in extension_list: + bot.load_extension(extension) +#client = discord.Client() + + +@bot.event async def on_ready(): print('Logged in as') - print(client.user.name) - print(client.user.id) + print(bot.user.name) + print(bot.user.id) print('hello') activity = discord.Game(name="#도움말 for help") - await client.change_presence(status=discord.Status.idle, activity=activity) + await bot.change_presence(status=discord.Status.idle, activity=activity) -@client.event +@bot.event async def on_message(message): if message.author.bot: return None @@ -34,30 +49,6 @@ async def on_message(message): if message.content.startswith("#"): logging_main(message) - if message.content.startswith("#help") or message.content.startswith("#도움말"): - output = help_main() - await message.channel.send(embed=output) - - if message.content.startswith("#심볼"): - msg = message.content.split(" ") - output = simbol_main(msg) - await message.channel.send(embed=output) - - if message.content.startswith("#추옵"): - msg = message.content.split(" ") - output = additional_options_main(msg) - await message.channel.send(embed=output) - - if message.content.startswith("#방무"): - msg = message.content.split(" ") - output = defense_percentage_ignore_main(msg) - await message.channel.send(embed=output) - - if message.content.startswith("#레벨"): - msg = message.content.split(" ") - output = level_main(msg) - await message.channel.send(embed=output) - if message.content.startswith("#정보") \ or message.content.startswith("#무릉") \ or message.content.startswith("#시드") \ @@ -68,9 +59,6 @@ async def on_message(message): output = information_main(msg) await message.channel.send(embed=output) - if message.content.startswith("#한강"): - output = hangang_main() - await message.channel.send(embed=output) if message.content.startswith("#골드") \ or message.content.startswith("#애플") \ @@ -93,15 +81,7 @@ async def on_message(message): output = homepage_main(msg) await message.channel.send(embed=output) - if message.content.startswith('#링크'): - msg = message.content.split(" ") - output = linknunion_main(msg) - await message.channel.send(embed=output) - - if message.content.startswith('#심신'): - msg = message.content.split(" ") - output = BodyAndMindTrainingCenter_main(msg) - await message.channel.send(embed=output) + await bot.process_commands(message) try: @@ -110,4 +90,4 @@ async def on_message(message): except: key = '' -client.run(key) +bot.run(key) diff --git a/module/BodyAndMindTrainingCenter.py b/module/BodyAndMindTrainingCenter.py index 572e1f1..cc7249d 100644 --- a/module/BodyAndMindTrainingCenter.py +++ b/module/BodyAndMindTrainingCenter.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import discord +from discord.ext import commands import csv @@ -36,33 +37,42 @@ def BodyAndMindTrainingCenter1(msg1, msg2): return output +class BnMTrainCenter(commands.Cog): + def __init__(self, bot): + self.bot = bot -def BodyAndMindTrainingCenter_main(msg): - if len(msg) == 3: - if msg[1].isdecimal() and msg[2].isdecimal(): - msg1 = float(msg[1]) - msg2 = float(msg[2]) - if msg1 == int(msg1) and msg2 == int(msg2): - msg1 = int(msg1) - msg2 = int(msg2) - if 105 <= msg1 < 275 and 105 < msg2 <= 275: - if msg1 > msg2: - output = discord.Embed(title="Warning!!!", description='시작 레벨은 끝 레벨의 값을 넘을 수 없습니다!', - color=0xff0000) + @commands.command() + async def 심신(self, ctx, *args): + msg = ['#심신'] + msg.extend(args) + if len(msg) == 3: + if msg[1].isdecimal() and msg[2].isdecimal(): + msg1 = float(msg[1]) + msg2 = float(msg[2]) + if msg1 == int(msg1) and msg2 == int(msg2): + msg1 = int(msg1) + msg2 = int(msg2) + if 105 <= msg1 < 275 and 105 < msg2 <= 275: + if msg1 > msg2: + output = discord.Embed(title="Warning!!!", description='시작 레벨은 끝 레벨의 값을 넘을 수 없습니다!', + color=0xff0000) + else: + output = BodyAndMindTrainingCenter1(msg1, msg2) else: - output = BodyAndMindTrainingCenter1(msg1, msg2) + output = discord.Embed(title="Warning!!!", description='숫자 범위 초과!', color=0xff0000) + output.set_footer(text="105이상, 275이하의 값만 입력해주세요!") else: - output = discord.Embed(title="Warning!!!", description='숫자 범위 초과!', color=0xff0000) - output.set_footer(text="105이상, 275이하의 값만 입력해주세요!") + output = discord.Embed(title="Warning!!!", description='데이터는 정수값이어야 합니다!', color=0xff0000) else: - output = discord.Embed(title="Warning!!!", description='데이터는 정수값이어야 합니다!', color=0xff0000) + output = discord.Embed(title="Warning!!!", description='두 개의 숫자를 입력하세요!', color=0xff0000) + output.set_footer(text="예) #심신 105 150") else: - output = discord.Embed(title="Warning!!!", description='두 개의 숫자를 입력하세요!', color=0xff0000) + output = discord.Embed(title="#심신", + description='#심신 (시작 레벨) (끝 레벨)으로 사용 가능하며, 시작 레벨부터 끝 레벨까지 필요한 심신수련관에서의 시간을 나타냅니다.', + color=0x00ff00) output.set_footer(text="예) #심신 105 150") - else: - output = discord.Embed(title="#심신", - description='#심신 (시작 레벨) (끝 레벨)으로 사용 가능하며, 시작 레벨부터 끝 레벨까지 필요한 심신수련관에서의 시간을 나타냅니다.', - color=0x00ff00) - output.set_footer(text="예) #심신 105 150") - return output + await ctx.send(embed=output) + +def setup(bot): + bot.add_cog(BnMTrainCenter(bot)) \ No newline at end of file diff --git a/module/additional_options.py b/module/additional_options.py index dbc62fb..73cf0b8 100644 --- a/module/additional_options.py +++ b/module/additional_options.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import discord +from discord.ext import commands import csv @@ -28,10 +29,13 @@ def additional_options1(msg, weapon): title = row_list[1] data = "기본 공격력 : " + row_list[2] + "\n\n" for k in range(1, len(row_list)-3): - data += "☆" * (len(row_list)-4-k) + "★" * k + " : " + row_list[k+2] + "\n" - image = "http://ec2-52-79-205-251.ap-northeast-2.compute.amazonaws.com/image/weapon/%s/%s.png" % (weapon, row_list[len(row_list) - 1]) + data += "☆" * (len(row_list)-4-k) + "★" * \ + k + " : " + row_list[k+2] + "\n" + image = "http://ec2-52-79-205-251.ap-northeast-2.compute.amazonaws.com/image/weapon/%s/%s.png" % ( + weapon, row_list[len(row_list) - 1]) if not title: - output = discord.Embed(title="Warning!!!", description='올바른 옵션을 입력하세요.', color=0xff0000) + output = discord.Embed( + title="Warning!!!", description='올바른 옵션을 입력하세요.', color=0xff0000) output.set_footer(text="#추옵 (셋트 종류) (무기 종류)") if oneline is 0: with open(file, newline='', encoding='UTF-8') as database: @@ -43,67 +47,84 @@ def additional_options1(msg, weapon): title = row_list[1] data = "기본 공격력 : " + row_list[2] + "\n\n" for k in range(1, len(row_list) - 3): - data += "☆" * (len(row_list) - 4 - k) + "★" * k + " : " + row_list[k + 2] + "\n" - image = "http://ec2-52-79-205-251.ap-northeast-2.compute.amazonaws.com/image/weapon/%s/%s.png" % (weapon, row_list[len(row_list) - 1]) + data += "☆" * (len(row_list) - 4 - k) + \ + "★" * k + " : " + row_list[k + 2] + "\n" + image = "http://ec2-52-79-205-251.ap-northeast-2.compute.amazonaws.com/image/weapon/%s/%s.png" % ( + weapon, row_list[len(row_list) - 1]) if title: - output = discord.Embed(title="%s" % title, description='%s' % data, color=0x0000ff) + output = discord.Embed( + title="%s" % title, description='%s' % data, color=0x0000ff) output.set_thumbnail(url=image) else: - output = discord.Embed(title = "%s" % title, description = '%s' % data, color=0x0000ff) + output = discord.Embed(title="%s" % + title, description='%s' % data, color=0x0000ff) output.set_thumbnail(url=image) return output -def additional_options_main(msg): - if len(msg) is 1: - output = discord.Embed(title="#추옵", description='#추옵(셋트명) (무기 종류)로 사용 가능합니다.\n무기의 단계별 추옵 수치를 확인하실 수 있습니다.', - color=0x00ff00) - output.set_footer(text="예) #추옵 우트가르드 케인, #추옵 제로 1형, #추옵 해카세") - else: - if msg[1].startswith("알리")\ - or msg[1].startswith("변질"): - output = additional_options1(msg, "alicia's_mutated_staff") - elif msg[1].startswith("아케")\ - or msg[1].startswith("아셰"): - output = additional_options1(msg, 'arcane_umbra') - elif msg[1].startswith("시그")\ - or msg[1].startswith("여제")\ - or msg[1].startswith("라이온")\ - or msg[1].startswith("드래")\ - or msg[1].startswith("팔콘")\ - or msg[1].startswith("레이")\ - or msg[1].startswith("샤크"): - output = additional_options1(msg, 'cygnus') - elif msg[1].startswith("파프"): - output = additional_options1(msg, 'fafnir') - elif msg[1].startswith("제네"): - output = additional_options1(msg, 'genesis') - elif msg[1].startswith("쟈이"): - output = additional_options1(msg, 'jaihin') - elif msg[1].startswith("해방")\ - or msg[1].startswith("해카")\ - or msg[1].startswith("카이"): - output = additional_options1(msg, 'liberated_kaiserium') - elif msg[1].startswith("라이"): - output = additional_options1(msg, 'lightseeker') - elif msg[1].startswith("네크"): - output = additional_options1(msg, 'necro') - elif msg[1].startswith("반레"): - output = additional_options1(msg, 'royal_von_leon') - elif msg[1].startswith("류드"): - output = additional_options1(msg, "ryude's_sword") - elif msg[1].startswith("우트"): - output = additional_options1(msg, 'utgard') - elif msg[1].startswith("자쿰")\ - or msg[1].startswith("포이"): - output = additional_options1(msg, "zakum's_poisonic") - elif msg[1].startswith("제로")\ - or msg[1].startswith("라피스")\ - or msg[1].startswith("라즐리"): - output = additional_options1(msg, 'zero') - elif msg[1].startswith("앱솔"): - output = additional_options1(msg, 'absolab') +class AddiOptions(commands.Cog): + + def __init__(self, bot): + self.bot = bot + + @commands.command() + async def 추옵(self, ctx, *args): + msg = ['#추옵'] + msg.extend(args) + if len(msg) is 1: + output = discord.Embed(title="#추옵", description='#추옵(셋트명) (무기 종류)로 사용 가능합니다.\n무기의 단계별 추옵 수치를 확인하실 수 있습니다.', + color=0x00ff00) + output.set_footer(text="예) #추옵 우트가르드 케인, #추옵 제로 1형, #추옵 해카세") else: - output = discord.Embed(title="Warning!!!", description='올바른 옵션을 입력하세요.', color=0xff0000) - output.set_footer(text="#추옵 (셋트 종류) (무기 종류)") - return output \ No newline at end of file + if msg[1].startswith("알리")\ + or msg[1].startswith("변질"): + output = additional_options1(msg, "alicia's_mutated_staff") + elif msg[1].startswith("아케")\ + or msg[1].startswith("아셰"): + output = additional_options1(msg, 'arcane_umbra') + elif msg[1].startswith("시그")\ + or msg[1].startswith("여제")\ + or msg[1].startswith("라이온")\ + or msg[1].startswith("드래")\ + or msg[1].startswith("팔콘")\ + or msg[1].startswith("레이")\ + or msg[1].startswith("샤크"): + output = additional_options1(msg, 'cygnus') + elif msg[1].startswith("파프"): + output = additional_options1(msg, 'fafnir') + elif msg[1].startswith("제네"): + output = additional_options1(msg, 'genesis') + elif msg[1].startswith("쟈이"): + output = additional_options1(msg, 'jaihin') + elif msg[1].startswith("해방")\ + or msg[1].startswith("해카")\ + or msg[1].startswith("카이"): + output = additional_options1(msg, 'liberated_kaiserium') + elif msg[1].startswith("라이"): + output = additional_options1(msg, 'lightseeker') + elif msg[1].startswith("네크"): + output = additional_options1(msg, 'necro') + elif msg[1].startswith("반레"): + output = additional_options1(msg, 'royal_von_leon') + elif msg[1].startswith("류드"): + output = additional_options1(msg, "ryude's_sword") + elif msg[1].startswith("우트"): + output = additional_options1(msg, 'utgard') + elif msg[1].startswith("자쿰")\ + or msg[1].startswith("포이"): + output = additional_options1(msg, "zakum's_poisonic") + elif msg[1].startswith("제로")\ + or msg[1].startswith("라피스")\ + or msg[1].startswith("라즐리"): + output = additional_options1(msg, 'zero') + elif msg[1].startswith("앱솔"): + output = additional_options1(msg, 'absolab') + else: + output = discord.Embed( + title="Warning!!!", description='올바른 옵션을 입력하세요.', color=0xff0000) + output.set_footer(text="#추옵 (셋트 종류) (무기 종류)") + + await ctx.send(embed=output) + +def setup(bot): + bot.add_cog(AddiOptions(bot)) \ No newline at end of file diff --git a/module/defense_percentage_ignore.py b/module/defense_percentage_ignore.py index a899b03..85813b7 100644 --- a/module/defense_percentage_ignore.py +++ b/module/defense_percentage_ignore.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import discord - +from discord.ext import commands def defense_percentage_ignore1(defense_percentage_ignore, percentage): monster_damage_percentage = 1 - (percentage * (1 - defense_percentage_ignore)) @@ -10,41 +10,52 @@ def defense_percentage_ignore1(defense_percentage_ignore, percentage): return monster_damage_percentage -def defense_percentage_ignore_main(msg): - if len(msg) is 1: - output = discord.Embed(title="#방무", - description='#방무 (방어율 무시 1) (방어율 무시 2)... (방어율 무시 n)로 사용 가능하며, 몬스터에게 들어가는 데미지율을 확인할 수 있습니다.', - color=0x00ff00) - output.set_footer(text="예) #방무 85 40 20") - num = 2 - for i in msg: - if not i.isdecimal(): - num = num - 1 - if num is 1: - defense_percentage_ignore = 1 - defense_percentage_ignore_options = list(range(1, len(msg), 1)) - for i in defense_percentage_ignore_options: - defense_percentage_ignore = defense_percentage_ignore * (1 - float(msg[i]) / 100) - defense_percentage_ignore = 1 - defense_percentage_ignore - - if defense_percentage_ignore > 1: - output = discord.Embed(title="Warning!!!", description='방어율 무시는 100%를 넘을 수 없습니다.', color=0xff0000) - output.set_footer(text="#방무 (방어율 무시 1) (방어율 무시 2)... (방어율 무시 n)") +class DefperIgnore(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.command() + async def 방무(self, ctx, *args): + msg = ['#방무'] + msg.extend(args) + if len(msg) is 1: + output = discord.Embed(title="#방무", + description='#방무 (방어율 무시 1) (방어율 무시 2)... (방어율 무시 n)로 사용 가능하며, 몬스터에게 들어가는 데미지율을 확인할 수 있습니다.', + color=0x00ff00) + output.set_footer(text="예) #방무 85 40 20") else: - output = discord.Embed(title="방어율 무시 %3.2f %% 몬스터 공격 시 데미지" % (defense_percentage_ignore * 100), - description="방어율 100%% 몬스터 공격 시 데미지 : %3.2f %%\n" - "방어율 150%% 몬스터 공격 시 데미지 : %3.2f %%\n" - "방어율 200%% 몬스터 공격 시 데미지 : %3.2f %%\n" - "방어율 250%% 몬스터 공격 시 데미지 : %3.2f %%\n" - "방어율 300%% 몬스터 공격 시 데미지 : %3.2f %%\n" - % (defense_percentage_ignore1(defense_percentage_ignore, 1) * 100, - defense_percentage_ignore1(defense_percentage_ignore, 1.5) * 100, - defense_percentage_ignore1(defense_percentage_ignore, 2) * 100, - defense_percentage_ignore1(defense_percentage_ignore, 2.5) * 100, - defense_percentage_ignore1(defense_percentage_ignore, 3) * 100), - color=0x0000ff) - else: - output = discord.Embed(title="Warning!!!", description='#방무 의 옵션에는 숫자만 입력 가능합니다.', color=0xff0000) - output.set_footer(text="#방무 85 40 20") - - return output + num = 2 + for i in msg: + if not i.isdecimal(): + num = num - 1 + if num is 1: + defense_percentage_ignore = 1 + defense_percentage_ignore_options = list(range(1, len(msg), 1)) + for i in defense_percentage_ignore_options: + defense_percentage_ignore = defense_percentage_ignore * (1 - float(msg[i]) / 100) + defense_percentage_ignore = 1 - defense_percentage_ignore + + if defense_percentage_ignore > 1: + output = discord.Embed(title="Warning!!!", description='방어율 무시는 100%를 넘을 수 없습니다.', color=0xff0000) + output.set_footer(text="#방무 (방어율 무시 1) (방어율 무시 2)... (방어율 무시 n)") + else: + output = discord.Embed(title="방어율 무시 %3.2f %% 몬스터 공격 시 데미지" % (defense_percentage_ignore * 100), + description="방어율 100%% 몬스터 공격 시 데미지 : %3.2f %%\n" + "방어율 150%% 몬스터 공격 시 데미지 : %3.2f %%\n" + "방어율 200%% 몬스터 공격 시 데미지 : %3.2f %%\n" + "방어율 250%% 몬스터 공격 시 데미지 : %3.2f %%\n" + "방어율 300%% 몬스터 공격 시 데미지 : %3.2f %%\n" + % (defense_percentage_ignore1(defense_percentage_ignore, 1) * 100, + defense_percentage_ignore1(defense_percentage_ignore, 1.5) * 100, + defense_percentage_ignore1(defense_percentage_ignore, 2) * 100, + defense_percentage_ignore1(defense_percentage_ignore, 2.5) * 100, + defense_percentage_ignore1(defense_percentage_ignore, 3) * 100), + color=0x0000ff) + else: + output = discord.Embed(title="Warning!!!", description='#방무 의 옵션에는 숫자만 입력 가능합니다.', color=0xff0000) + output.set_footer(text="#방무 85 40 20") + + await ctx.send(embed=output) + +def setup(bot): + bot.add_cog(DefperIgnore(bot)) \ No newline at end of file diff --git a/module/hangang.py b/module/hangang.py index b8cf7ce..8f882d3 100644 --- a/module/hangang.py +++ b/module/hangang.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import discord +from discord.ext import commands from requests import get import json @@ -10,14 +11,23 @@ def download(): file.write(response.content) -def hangang_main(): - download() - with open('module/json/hangang.json') as json_file: - json_data = json.load(json_file) - temperature = json_data["temp"] - time = json_data["time"] +class Hangang(commands.Cog): - output = discord.Embed(title="지금 한강 온도", description='%s °C\n최종 업데이트 시간 : %s' % (temperature, time), color=0xff0000) - output.set_footer(text="도움이 필요하세요? ☎ 1393") + def __init__(self, bot): + self.bot = bot - return output + @commands.command() + async def 한강(self, ctx): + download() + with open('module/json/hangang.json') as json_file: + json_data = json.load(json_file) + temperature = json_data["temp"] + time = json_data["time"] + + output = discord.Embed(title="지금 한강 온도", description='%s °C\n최종 업데이트 시간 : %s' % (temperature, time), color=0xff0000) + output.set_footer(text="도움이 필요하세요? ☎ 1393") + + await ctx.send(embed=output) + +def setup(bot): + bot.add_cog(Hangang(bot)) \ No newline at end of file diff --git a/module/help.py b/module/help.py index facbd71..4d41856 100644 --- a/module/help.py +++ b/module/help.py @@ -1,48 +1,59 @@ #!/usr/bin/env python3 import discord +from discord.ext import commands -description = '봇 서버를 켜지 않은 동안에는 작동하지 않으며, 봇의 온/오프라인 상태 확인으로 확인하실 수 있습니다.\n' - - -def help_main(): - output = discord.Embed(title="도움말", description=description, color=0x00ff00) - output.add_field(name="#도움말", value="도움말을 표시합니다.", inline=False) - output.add_field(name="#심볼 (옵션 1) (옵션 2)", - value="(옵션 1)부터 (옵션2)까지 심볼 레벨을 올리는 데 필요한 심볼 갯수, 메소를 확인할 수 있습니다.", - inline=False) - output.add_field(name="#추옵 (셋트명) (무기 종류)", value="무기의 단계별 추옵 수치를 확인하실 수 있습니다.", - inline=False) - output.add_field(name="#방무 (방어율 무시 1) (방어율 무시 2) ... (방어율 무시 n)", - value="몬스터에게 들어가는 데미지율을 확인할 수 있습니다.", - inline=False) - output.add_field(name="#레벨 (닉네임)", - value="현재의 경험치와 250, 275까지 필요한 경험치량을 나타냅니다.\n메이플스토리 공식 홈페이지의 정보를 활용합니다.", - inline=False) - output.add_field(name="#정보 (닉네임)", - value="사용자의 프로필을 확인할 수 있습니다.\n상세 정보 확인을 위해서는 #무릉, #시드, #유니온, #업적 명령어를 입력하세요.", - inline=False) - output.add_field(name="#한강", - value="현재 한강의 수온 정보를 알려줍니다.", - inline=False) - output.add_field(name="#골드애플, 로얄스타일, 원더베리 (횟수)", - value="확률성 아이템을 시뮬레이션 할 수 있으며, 횟수 옵션이 없는 경우 1회 시행합니다.", - inline=False) - output.add_field(name="#루나 스윗/드림", - value="루나 크리스탈 스윗/드림을 시뮬레이션 할 수 있습니다.", - inline=False) - output.add_field(name="#남자/여자 헤어/성형", - value="헤어와 성형을 시뮬레이션 할 수 있습니다.", - inline=False) - output.add_field(name="#이벤트/캐시", - value="현재 진행중인 이벤트/현재 판매중인 캐시 정보를 불러옵니다.", - inline=False) - output.add_field(name="#링크 (직업)", - value="유니온 효과와 링크스킬을 확인할 수 있습니다.", - inline=False) - output.add_field(name="#심신 (시작 레벨) (끝 레벨)", - value="시작 레벨부터 끝 레벨까지 필요한 심신수련관에서의 시간을 나타냅니다.", - inline=False) - - output.set_footer(text="문의 : RIRINTO#0966") - return output + +class Help(commands.Cog): + + def __init__(self, bot): + self.bot = bot + + @commands.command(aliases=['도움말']) + async def help(self, ctx): + description = '봇 서버를 켜지 않은 동안에는 작동하지 않으며, 봇의 온/오프라인 상태 확인으로 확인하실 수 있습니다.\n' + + output = discord.Embed( + title="도움말", description=description, color=0x00ff00) + output.add_field(name="#도움말", value="도움말을 표시합니다.", inline=False) + output.add_field(name="#심볼 (옵션 1) (옵션 2)", + value="(옵션 1)부터 (옵션2)까지 심볼 레벨을 올리는 데 필요한 심볼 갯수, 메소를 확인할 수 있습니다.", + inline=False) + output.add_field(name="#추옵 (셋트명) (무기 종류)", value="무기의 단계별 추옵 수치를 확인하실 수 있습니다.", + inline=False) + output.add_field(name="#방무 (방어율 무시 1) (방어율 무시 2) ... (방어율 무시 n)", + value="몬스터에게 들어가는 데미지율을 확인할 수 있습니다.", + inline=False) + output.add_field(name="#레벨 (닉네임)", + value="현재의 경험치와 250, 275까지 필요한 경험치량을 나타냅니다.\n메이플스토리 공식 홈페이지의 정보를 활용합니다.", + inline=False) + output.add_field(name="#정보 (닉네임)", + value="사용자의 프로필을 확인할 수 있습니다.\n상세 정보 확인을 위해서는 #무릉, #시드, #유니온, #업적 명령어를 입력하세요.", + inline=False) + output.add_field(name="#한강", + value="현재 한강의 수온 정보를 알려줍니다.", + inline=False) + output.add_field(name="#골드애플, 로얄스타일, 원더베리 (횟수)", + value="확률성 아이템을 시뮬레이션 할 수 있으며, 횟수 옵션이 없는 경우 1회 시행합니다.", + inline=False) + output.add_field(name="#루나 스윗/드림", + value="루나 크리스탈 스윗/드림을 시뮬레이션 할 수 있습니다.", + inline=False) + output.add_field(name="#남자/여자 헤어/성형", + value="헤어와 성형을 시뮬레이션 할 수 있습니다.", + inline=False) + output.add_field(name="#이벤트/캐시", + value="현재 진행중인 이벤트/현재 판매중인 캐시 정보를 불러옵니다.", + inline=False) + output.add_field(name="#링크 (직업)", + value="유니온 효과와 링크스킬을 확인할 수 있습니다.", + inline=False) + output.add_field(name="#심신 (시작 레벨) (끝 레벨)", + value="시작 레벨부터 끝 레벨까지 필요한 심신수련관에서의 시간을 나타냅니다.", + inline=False) + + output.set_footer(text="문의 : RIRINTO#0966") + await ctx.send(embed=output) + +def setup(bot): + bot.add_cog(Help(bot)) diff --git a/module/level.py b/module/level.py index 80efa19..a6ac77b 100644 --- a/module/level.py +++ b/module/level.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import discord +from discord.ext import commands import csv import requests from bs4 import BeautifulSoup @@ -90,27 +91,37 @@ def level2(result, msg1, url): return output +class Level(commands.Cog): -def level_main(msg): - if len(msg) is 2: - empty_result = [[], [], [], [], [], [], []] + def __init__(self, bot): + self.bot = bot - main_url = 'https://maplestory.nexon.com/Ranking/World/Total?c=%s' % msg[1] - reboot_url = 'https://maplestory.nexon.com/Ranking/World/Total?c=%s&w=254' % msg[1] - main_result = level1(main_url) + @commands.command() + async def 레벨(self, ctx, *args): + msg = ['#레벨'] + msg.extend(args) + if len(msg) is 2: + empty_result = [[], [], [], [], [], [], []] - if main_result == empty_result: - reboot_result = level1(reboot_url) - if reboot_result == empty_result: - output = discord.Embed(title="Warning!!!", description='랭킹 정보가 없습니다!', color=0xff0000) + main_url = 'https://maplestory.nexon.com/Ranking/World/Total?c=%s' % msg[1] + reboot_url = 'https://maplestory.nexon.com/Ranking/World/Total?c=%s&w=254' % msg[1] + main_result = level1(main_url) + + if main_result == empty_result: + reboot_result = level1(reboot_url) + if reboot_result == empty_result: + output = discord.Embed(title="Warning!!!", description='랭킹 정보가 없습니다!', color=0xff0000) + else: + output = level2(reboot_result, msg[1], reboot_url) else: - output = level2(reboot_result, msg[1], reboot_url) + output = level2(main_result, msg[1], main_url) else: - output = level2(main_result, msg[1], main_url) - else: - output = discord.Embed(title="#레벨", - description='#레벨 (닉네임)으로 사용 가능하며, 현재의 경험치와 250, 275까지 필요한 경험치 량을 나타냅니다.\n메이플스토리 공식 홈페이지의 정보를 활용합니다.', - color=0x00ff00) - output.set_footer(text="예) #레벨 RIRINTO") + output = discord.Embed(title="#레벨", + description='#레벨 (닉네임)으로 사용 가능하며, 현재의 경험치와 250, 275까지 필요한 경험치 량을 나타냅니다.\n메이플스토리 공식 홈페이지의 정보를 활용합니다.', + color=0x00ff00) + output.set_footer(text="예) #레벨 RIRINTO") - return output + await ctx.send(embed=output) + +def setup(bot): + bot.add_cog(Level(bot)) \ No newline at end of file diff --git a/module/linknunion.py b/module/linknunion.py index 6b92620..4fd2290 100644 --- a/module/linknunion.py +++ b/module/linknunion.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import discord +from discord.ext import commands import csv from module.changename import * @@ -43,10 +44,21 @@ def linknunion1(msg): return output -def linknunion_main(msg): - if len(msg) is not 1: - output = linknunion1(msg) - else: - output = discord.Embed(title="#링크", description='#링크 (직업명) 으로 사용 가능합니다.\n명령어 입력 시 해당 직업의 유니온 효과와 링크스킬을 확인하실 수 있습니다.', color=0x00ff00) - output.set_footer(text="예) #링크 키네시스, #링크 제로") - return output +class Linknunion(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.command() + async def 링크(self, ctx, *args): + msg = ['#링크'] + msg.extend(args) + if len(msg) is not 1: + output = linknunion1(msg) + else: + output = discord.Embed(title="#링크", description='#링크 (직업명) 으로 사용 가능합니다.\n명령어 입력 시 해당 직업의 유니온 효과와 링크스킬을 확인하실 수 있습니다.', color=0x00ff00) + output.set_footer(text="예) #링크 키네시스, #링크 제로") + + await ctx.send(embed=output) + +def setup(bot): + bot.add_cog(Linknunion(bot)) \ No newline at end of file diff --git a/module/simbol.py b/module/simbol.py index 70c7489..1e0d769 100644 --- a/module/simbol.py +++ b/module/simbol.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import discord +from discord.ext import commands def simbol1(a, b): @@ -36,36 +37,51 @@ def simbol3(a, b): return format(result, ',') -def simbol_main(msg): - if len(msg) == 3: - if msg[1].isdecimal() and msg[2].isdecimal(): - msg1 = float(msg[1]) - msg2 = float(msg[2]) - if msg1 == int(msg1) and msg2 == int(msg2): - msg1 = int(msg1) - msg2 = int(msg2) - if 0 < msg1 < 21 and 0 < msg2 < 21: - if msg1 > msg2: - output = discord.Embed(title="Warning!!!", description='옵션 1은 옵션 2의 값을 넘을 수 없습니다!', - color=0xff0000) - return output +class Simbol(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.command() + async def 심볼(self, ctx, *args): + msg = ['#심볼'] + msg.extend(args) + if len(msg) == 3: + if msg[1].isdecimal() and msg[2].isdecimal(): + msg1 = float(msg[1]) + msg2 = float(msg[2]) + if msg1 == int(msg1) and msg2 == int(msg2): + msg1 = int(msg1) + msg2 = int(msg2) + if 0 < msg1 < 21 and 0 < msg2 < 21: + if msg1 > msg2: + output = discord.Embed(title="Warning!!!", description='옵션 1은 옵션 2의 값을 넘을 수 없습니다!', + color=0xff0000) + return output + else: + output = discord.Embed(title="심볼 %d → %d" % (msg1, msg2), + description='필요 성장치 : %s \n 소멸의 여로 심볼 강화 비용 : %s \n 츄레아모에 심볼 강화 비용 : %s' + % (simbol1(msg1, msg2), simbol2(msg1, msg2), + simbol3(msg1, msg2)), color=0x0000ff) + return output else: - output = discord.Embed(title="심볼 %d → %d" % (msg1, msg2), - description='필요 성장치 : %s \n 소멸의 여로 심볼 강화 비용 : %s \n 츄레아모에 심볼 강화 비용 : %s' - % (simbol1(msg1, msg2), simbol2(msg1, msg2), - simbol3(msg1, msg2)), color=0x0000ff) + output = discord.Embed( + title="Warning!!!", description='숫자 범위 초과!', color=0xff0000) + output.set_footer(text="1이상, 20 이하의 정수만 입력해주세요!") return output else: - output = discord.Embed(title="Warning!!!", description='숫자 범위 초과!', color=0xff0000) - output.set_footer(text="1이상, 20 이하의 정수만 입력해주세요!") - return output + output = discord.Embed( + title="Warning!!!", description='데이터는 정수값이어야 합니다!', color=0xff0000) else: - output = discord.Embed(title="Warning!!!", description='데이터는 정수값이어야 합니다!', color=0xff0000) + output = discord.Embed( + title="Warning!!!", description='두 개의 숫자를 입력하세요!', color=0xff0000) + output.set_footer(text="#심볼 (옵션1) (옵션2)") else: - output = discord.Embed(title="Warning!!!", description='두 개의 숫자를 입력하세요!', color=0xff0000) - output.set_footer(text="#심볼 (옵션1) (옵션2)") - else: - output = discord.Embed(title="#심볼", description='#심볼 (옵션1) (옵션2)을 입력하여 (옵션1)부터 (옵션2) 까지 심볼을 레벨업하는 데 필요한 심볼 갯수, 메소를 확인할 수 있습니다.', color=0x00ff00) - output.set_footer(text="#심볼 7 12") + output = discord.Embed( + title="#심볼", description='#심볼 (옵션1) (옵션2)을 입력하여 (옵션1)부터 (옵션2) 까지 심볼을 레벨업하는 데 필요한 심볼 갯수, 메소를 확인할 수 있습니다.', color=0x00ff00) + output.set_footer(text="#심볼 7 12") + + await ctx.send(embed=output) + - return output +def setup(bot): + bot.add_cog(Simbol(bot)) diff --git a/requirements.txt b/requirements.txt index b813108..85f55df 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,4 @@ requests==2.22.0 -discord==1.0.1 \ No newline at end of file +discord==1.0.1 +beautifulsoup4==4.8.2 +imgkit==1.0.2 \ No newline at end of file