Skip to content

Commit

Permalink
방무 args 없을때 도움말을 출력하지 않았던 오류 수정, 명령어 분기를 제외한 모든 명령어들을 commands.ext.co…
Browse files Browse the repository at this point in the history
…mmand 로 바꿈
  • Loading branch information
laoraid committed Jan 13, 2020
1 parent a16722c commit eefd914
Show file tree
Hide file tree
Showing 10 changed files with 354 additions and 270 deletions.
68 changes: 24 additions & 44 deletions KMS_Bot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
from discord.ext import commands

from module.help import *
from module.simbol import *
Expand All @@ -13,51 +13,42 @@
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

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("#시드") \
Expand All @@ -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("#애플") \
Expand All @@ -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:
Expand All @@ -110,4 +90,4 @@ async def on_message(message):
except:
key = ''

client.run(key)
bot.run(key)
56 changes: 33 additions & 23 deletions module/BodyAndMindTrainingCenter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import discord
from discord.ext import commands
import csv


Expand Down Expand Up @@ -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))
139 changes: 80 additions & 59 deletions module/additional_options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import discord
from discord.ext import commands
import csv


Expand Down Expand Up @@ -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:
Expand All @@ -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
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))
Loading

0 comments on commit eefd914

Please sign in to comment.