Skip to content

Commit

Permalink
chore: format code
Browse files Browse the repository at this point in the history
  • Loading branch information
paring-chan authored and Kimu-Nowchira committed Jul 16, 2022
1 parent 33f08ac commit 4abdb9b
Show file tree
Hide file tree
Showing 34 changed files with 572 additions and 389 deletions.
4 changes: 2 additions & 2 deletions Legacy_Codes/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 디스코드 메세지 인텐트로 인한 검열 기능 사용 제한.
# From cogs/admin.py
'''
"""
class DBManagerCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
Expand Down Expand Up @@ -157,4 +157,4 @@ async def 목록(self, ctx, *args):
else:
await ctx.send("`이프야 목록 <야한말/정치언급/욕설/변태/나쁜말/관리자>`")
return None
'''
"""
2 changes: 1 addition & 1 deletion Legacy_Codes/censorship.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ async def gumyol(message):
# 검열에 안 걸린 경우
return True
'''
'''
69 changes: 50 additions & 19 deletions cogs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ def __init__(self, bot):
self.bot = bot

@on_working.administrator()
@slash_command(name = "계란", guild_ids = config.ADMIN_COMMAND_GUILD, decription = "관리자 디버그용 도구입니다. (관리자 전용)")
@slash_command(
name="계란",
guild_ids=config.ADMIN_COMMAND_GUILD,
decription="관리자 디버그용 도구입니다. (관리자 전용)",
)
async def 계란(self, ctx, args: str):
here = Room(ctx.channel)
me = User(ctx.author)
Expand All @@ -55,13 +59,17 @@ async def 계란(self, ctx, args: str):
)
embed.set_footer(
text=f"{ctx.author.name} • 달걀",
#작동하지 않음
#icon_url=str(ctx.author.avatar_url_as(static_format="png", size=128)),
# 작동하지 않음
# icon_url=str(ctx.author.avatar_url_as(static_format="png", size=128)),
)
await ctx.respond(embed=embed)

@on_working.administrator()
@slash_command(name = "달걀", guild_ids = config.ADMIN_COMMAND_GUILD, description = "관리자 디버그용 도구입니다. (관리자 전용)")
@slash_command(
name="달걀",
guild_ids=config.ADMIN_COMMAND_GUILD,
description="관리자 디버그용 도구입니다. (관리자 전용)",
)
async def 달걀(self, ctx, args: str):
here = Room(ctx.channel)
me = User(ctx.author)
Expand All @@ -88,27 +96,39 @@ async def 달걀(self, ctx, args: str):
)
embed.set_footer(
text=f"{ctx.author.name} • 달걀",
#작동하지 않음
#icon_url=str(ctx.author.avatar_url_as(static_format="png", size=128)),
# 작동하지 않음
# icon_url=str(ctx.author.avatar_url_as(static_format="png", size=128)),
)
await ctx.respond(embed=embed)

# 팡 하면 펑 하고 터짐
@on_working.administrator()
@slash_command(name = "팡", guild_ids = config.ADMIN_COMMAND_GUILD, description = "관리자 디버그용 도구입니다. (관리자 전용)")
@slash_command(
name="팡",
guild_ids=config.ADMIN_COMMAND_GUILD,
description="관리자 디버그용 도구입니다. (관리자 전용)",
)
async def (self, ctx):
await ctx.respond(f"펑! 💥\n`지연 시간 : {int(self.bot.latency * 1000)}ms`")
raise Exception

# 팡 하면 펑 하고 터짐
@on_working.administrator()
@slash_command(name = "핑핑", guild_ids = config.ADMIN_COMMAND_GUILD, description = "관리자 디버그용 도구입니다. (관리자 전용)")
@slash_command(
name="핑핑",
guild_ids=config.ADMIN_COMMAND_GUILD,
description="관리자 디버그용 도구입니다. (관리자 전용)",
)
async def 핑핑(self, ctx):
ping = [f"#shard_{i[0]} ({int(i[1] * 1000)}ms)" for i in self.bot.latencies]
text = "\n".join(ping)
await ctx.respond(f"퐁퐁! 🏓🏓\n```css\n[ 지연 시간 ]\n{text}```")

@slash_command(name = "공지", guild_ids = config.ADMIN_COMMAND_GUILD, description = "관리자 공지용 도구입니다. (관리자 전용)")
@slash_command(
name="공지",
guild_ids=config.ADMIN_COMMAND_GUILD,
description="관리자 공지용 도구입니다. (관리자 전용)",
)
@on_working.administrator()
async def 공지(self, ctx: discord.commands.context.ApplicationContext):
old = await ctx.respond(
Expand All @@ -134,8 +154,8 @@ async def 공지(self, ctx: discord.commands.context.ApplicationContext):
)
news_embed.set_footer(
text=f"{ctx.author.name} • #공지",
#작동하지 않음
#icon_url=str(ctx.author.avatar_url_as(static_format="png", size=128)),
# 작동하지 않음
# icon_url=str(ctx.author.avatar_url_as(static_format="png", size=128)),
)
"""
news_embed.set_thumbnail(
Expand Down Expand Up @@ -206,25 +226,29 @@ async def progress():
)
await window.edit(embed=embed)

@slash_command(name = "업데이트공지", guild_ids = config.ADMIN_COMMAND_GUILD, description = "관리자 공지용 도구입니다. (관리자 전용)")
@slash_command(
name="업데이트공지",
guild_ids=config.ADMIN_COMMAND_GUILD,
description="관리자 공지용 도구입니다. (관리자 전용)",
)
@on_working.administrator()
async def 업데이트공지(self, ctx, arg):
embed = discord.Embed(
title="**공지사항**", color=0x00A495, timestamp=datetime.datetime.now()
)
'''
"""
embed.set_thumbnail(
url=str(self.bot.user.avatar_url_as(static_format="png", size=256))
)
'''
"""
embed.add_field(
name="**<이프 업데이트 공지>**",
value=f"이프가 **`{arg}`**동안 업데이트 될 예정입니다.\n업데이트 중에는 이프를 사용하실수 없습니다.\n\n감사합니다.",
inline=False,
)
embed.set_footer(
text=f"{ctx.author.name} • #공지",
#icon_url=str(ctx.author.avatar_url_as(static_format="png", size=128)),
# icon_url=str(ctx.author.avatar_url_as(static_format="png", size=128)),
)
end = []
for guild in self.bot.guilds: # 서버 리스트
Expand Down Expand Up @@ -257,7 +281,11 @@ class LogManagerCog(commands.Cog):
def __init__(self, bot):
self.bot = bot

@slash_command(name = "로그", guild_ids = config.ADMIN_COMMAND_GUILD, description = "관리자 디버그용 도구입니다. (관리자 전용)")
@slash_command(
name="로그",
guild_ids=config.ADMIN_COMMAND_GUILD,
description="관리자 디버그용 도구입니다. (관리자 전용)",
)
@on_working.administrator()
async def 로그(self, ctx, args: str):
arg = (
Expand All @@ -273,7 +301,11 @@ async def 로그(self, ctx, args: str):
else:
await ctx.respond(f"'logs/log_{arg}.txt'는 없는 파일입니다.")

@slash_command(name = "에러로그", guild_ids = config.ADMIN_COMMAND_GUILD, description = "관리자 디버그용 도구입니다. (관리자 전용)")
@slash_command(
name="에러로그",
guild_ids=config.ADMIN_COMMAND_GUILD,
description="관리자 디버그용 도구입니다. (관리자 전용)",
)
@on_working.administrator()
async def 에러로그(self, ctx, args: str):
arg = (
Expand All @@ -290,9 +322,8 @@ async def 에러로그(self, ctx, args: str):
await ctx.send(f"'logs/error_log_{arg}.txt'는 없는 파일입니다.")



def setup(bot):
logger.info(f"{os.path.abspath(__file__)} 로드 완료")
bot.add_cog(AdminCog(bot))
bot.add_cog(LogManagerCog(bot))
#bot.add_cog(DBManagerCog(bot)) # Legacy Code
# bot.add_cog(DBManagerCog(bot)) # Legacy Code
21 changes: 14 additions & 7 deletions cogs/censorship.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,22 @@ class CensorshipCog(commands.Cog):
def __init__(self, bot):
self.bot = bot

@slash_command(name = "검열", description = "검열 기능에 대한 설명입니다!", guild_ids=SCRS)
@slash_command(name="검열", description="검열 기능에 대한 설명입니다!", guild_ids=SCRS)
async def 검열(self, ctx):
embed = discord.Embed(title = "검열 기능은 어디로 갔나요?", colour = 0x4BC59F)
embed.add_field(name = "왜 없어졌나요?", value = "디스코드의 메세지 인텐트 정책에 의거해, 2022.09.01 부터는 검열 기능이 정상적으로 작동하지 않을 예정입니다.", inline = False)
embed.add_field(name = "그럼 검열은 어디에서 해야 하나요?", value = "키뮤소프트가 새롭게 개발중인 봇 `위브`는 검열을 위한 봇입니다! 검열 기능은 위브로 이관될 예정이니 많은 관심 부탁드릴게요!", inline = False)
await ctx.respond(embed = embed)
embed = discord.Embed(title="검열 기능은 어디로 갔나요?", colour=0x4BC59F)
embed.add_field(
name="왜 없어졌나요?",
value="디스코드의 메세지 인텐트 정책에 의거해, 2022.09.01 부터는 검열 기능이 정상적으로 작동하지 않을 예정입니다.",
inline=False,
)
embed.add_field(
name="그럼 검열은 어디에서 해야 하나요?",
value="키뮤소프트가 새롭게 개발중인 봇 `위브`는 검열을 위한 봇입니다! 검열 기능은 위브로 이관될 예정이니 많은 관심 부탁드릴게요!",
inline=False,
)
await ctx.respond(embed=embed)

@slash_command(name = "태그", description="이 채널의 태그를 확인하세요!", guild_ids=SCRS)
@slash_command(name="태그", description="이 채널의 태그를 확인하세요!", guild_ids=SCRS)
async def 태그(self, ctx):
tags = eptag.tag_to_korean(eptag.get_tags(ctx.channel))

Expand All @@ -34,7 +42,6 @@ async def 태그(self, ctx):
await ctx.respond(embed=embed)



def setup(bot):
logger.info(f"{os.path.abspath(__file__)} 로드 완료")
bot.add_cog(CensorshipCog(bot)) # 꼭 이렇게 위의 클래스를 이렇게 add_cog해 줘야 작동해요!
8 changes: 6 additions & 2 deletions cogs/etc.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ async def 핑(self, ctx: discord.commands.context.ApplicationContext):
now = datetime.datetime.now()

latency = int(self.bot.latency * 1000)
i = await ctx.respond(f"퐁! 🏓\n`지연 시간 : {latency}ms (실제 지연시간 계산 중...)`", )
i = await ctx.respond(
f"퐁! 🏓\n`지연 시간 : {latency}ms (실제 지연시간 계산 중...)`",
)

wd = await i.original_message()

real_latency = int((wd.created_at.replace(tzinfo=None) - now).microseconds / 1000)
real_latency = int(
(wd.created_at.replace(tzinfo=None) - now).microseconds / 1000
)
await ctx.edit(
content=f"퐁! 🏓\n`지연 시간 : {latency}ms (실제 지연시간 {real_latency}ms)`"
)
Expand Down
27 changes: 19 additions & 8 deletions cogs/fishing/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,21 @@ class FishAdminCog(commands.Cog):
def __init__(self, bot):
self.bot = bot

@slash_command(name = "디버그", guild_ids = config.ADMIN_COMMAND_GUILD, description="관리자 디버그용 도구입니다. (관리자 전용)")
@slash_command(
name="디버그",
guild_ids=config.ADMIN_COMMAND_GUILD,
description="관리자 디버그용 도구입니다. (관리자 전용)",
)
@administrator()
async def 테스트(self, ctx, command_type:
Option(str, "관리자 명령어 종류", choices = ["지형변경", "명성설정", "명성부여", "돈부여", "기타"]),
num: int = None, user: discord.Member = None):
async def 테스트(
self,
ctx,
command_type: Option(
str, "관리자 명령어 종류", choices=["지형변경", "명성설정", "명성부여", "돈부여", "기타"]
),
num: int = None,
user: discord.Member = None,
):

if command_type == "지형변경":
Room(ctx.channel).biome = num
Expand All @@ -34,23 +44,24 @@ async def 테스트(self, ctx, command_type:
origin_exp = room.exp
room.exp = num
await ctx.respond(content=f"여기의 명성을 `{origin_exp}`에서 `{num}`(으)로 바꿔써!")

elif command_type == "명성부여":
room = Room(ctx.channel)
origin_exp = room.exp
room.exp += num
await ctx.respond(content=f"여기의 명성을 `{origin_exp}`에서 `{room.exp:,}`(으)로 바꿔써!")
await ctx.respond(
content=f"여기의 명성을 `{origin_exp}`에서 `{room.exp:,}`(으)로 바꿔써!"
)

elif command_type == "돈부여":
user = User(user)
user.give_money(num)
await ctx.respond(f"<@!{user.id}>가 `{user.money:,}💰` 가 됐어!")

else:
else:
await ctx.respond("Hello, This is KOI3125 test command!")



def setup(bot):
logger.info(f"{os.path.abspath(__file__)} 로드 완료")
bot.add_cog(FishAdminCog(bot))
4 changes: 3 additions & 1 deletion cogs/fishing/cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, bot):
logger.info("AsyncIOScheduler 스케쥴 시작")
self.sched = AsyncIOScheduler()

#self.sched.add_job(self.day_end_schedule, "cron", hour="23", minute="55")
# self.sched.add_job(self.day_end_schedule, "cron", hour="23", minute="55")
# self.sched.add_job(self.day_end_schedule, 'cron', minute='*/5')
self.sched.start()

Expand All @@ -56,6 +56,7 @@ async def cleaner(self):
if len(self.bot.guilds) != 0:
logger.info(f"통계 : 현재 서버 수 {len(self.bot.guilds)}곳")


""" 사용하지 않음
@commands.command()
@administrator()
Expand Down Expand Up @@ -166,6 +167,7 @@ async def day_end_schedule(self):
db.update_sql("users", "biggest_size=0, biggest_name=''") # 최고 기록 초기화
"""


def setup(bot):
logger.info(f"{os.path.abspath(__file__)} 로드 완료")
bot.add_cog(CycleCog(bot)) # 꼭 이렇게 위의 클래스를 이렇게 add_cog해 줘야 작동해요!
16 changes: 13 additions & 3 deletions cogs/fishing/fishing.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ async def 여기(self, ctx: discord.commands.context.ApplicationContext):
@slash_command(name="랭킹", description="이프의 랭킹을 보여줘요!", guild_ids=SCRS)
@on_working(prohibition=True)
async def 랭킹(
self, ctx: discord.commands.context.ApplicationContext, type: Option(str, "보고 싶으신 랭킹의 종류를 고르세요!", choices=["개인", "낚시터"])
self,
ctx: discord.commands.context.ApplicationContext,
type: Option(str, "보고 싶으신 랭킹의 종류를 고르세요!", choices=["개인", "낚시터"]),
):
await ctx.defer()

Expand Down Expand Up @@ -195,7 +197,11 @@ async def 낚시중지(self, ctx: discord.commands.context.ApplicationContext):

@slash_command(name="도감", description="물고기의 정보 or 도감을 보여드려요!", guild_ids=SCRS)
@on_working(prohibition=True)
async def 도감(self, ctx: discord.commands.context.ApplicationContext, fish_name: Option(str, "검색하고 싶은 물고기 이름") = None):
async def 도감(
self,
ctx: discord.commands.context.ApplicationContext,
fish_name: Option(str, "검색하고 싶은 물고기 이름") = None,
):
await ctx.defer()

# 물고기가 낚인 이후
Expand Down Expand Up @@ -248,7 +254,11 @@ async def 도감(self, ctx: discord.commands.context.ApplicationContext, fish_na

@slash_command(name="분석", description="물고기가 낚이는 확률을 보여드려요!", guild_ids=SCRS)
@commands.cooldown(3, 30)
async def 분석(self, ctx: discord.commands.context.ApplicationContext, type: Option(str, "분석 결과의 종류", choices=["일반", "단순 표현"])):
async def 분석(
self,
ctx: discord.commands.context.ApplicationContext,
type: Option(str, "분석 결과의 종류", choices=["일반", "단순 표현"]),
):
await ctx.defer()

accuracy = 20
Expand Down
8 changes: 6 additions & 2 deletions cogs/fishing/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ def __init__(self, ctx):
@discord.ui.button(
label="낚싯줄 당기기", style=discord.ButtonStyle.blurple, emoji="🎣"
)
async def button1_callback(self, button: discord.ui.Button, interaction: discord.Interaction):
async def button1_callback(
self, button: discord.ui.Button, interaction: discord.Interaction
):
self.button_value = "당김"
self.stop()
await interaction.response.defer()

@discord.ui.button(label="그만하기", style=discord.ButtonStyle.red, emoji="🚫")
async def button2_callback(self, button: discord.ui.Button, interaction: discord.Interaction):
async def button2_callback(
self, button: discord.ui.Button, interaction: discord.Interaction
):
self.button_value = "그만둠"
self.stop()

Expand Down
3 changes: 1 addition & 2 deletions cogs/fishing/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,7 @@ async def interaction_check(self, interaction) -> bool:

@slash_command(name="시설", description="특정 티어의 시설중 낚시터에 알려드려요!", guild_ids=SCRS)
@on_working(fishing=True, prohibition=True, landwork=True, twoball=False)
async def 시설(self, ctx,
tier: Option(int, "시설 목록을 알고 싶은 특정 티어를 입력해주세요!") = 1):
async def 시설(self, ctx, tier: Option(int, "시설 목록을 알고 싶은 특정 티어를 입력해주세요!") = 1):
room = Room(ctx.channel)

if room.tier < int(tier):
Expand Down
2 changes: 1 addition & 1 deletion config.example.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

""" FishCard Server Setting"""
CARD_SERVER = "http://localhost:3000" # 슬래시로 끝내지 말아주세요
CARD_TOKEN = os.getenv('IMAGE_GENERATOR_TOKEN', '') # python scripts/genscript.py
CARD_TOKEN = os.getenv("IMAGE_GENERATOR_TOKEN", "") # python scripts/genscript.py

""" Discord Bot Configuration """
TOKEN = ""
Expand Down
Loading

0 comments on commit 4abdb9b

Please sign in to comment.