Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Puilin authored Aug 14, 2021
1 parent 1194b69 commit d073ea5
Show file tree
Hide file tree
Showing 21 changed files with 284,658 additions and 0 deletions.
Binary file not shown.
29 changes: 29 additions & 0 deletions discord bot/beta v.10.5/bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from discord.ext import commands
import discord

intents = discord.Intents.all()
bot = commands.Bot(command_prefix='/', intents=intents)

token = "Your token here"

bot.load_extension("cogs.maincog")
bot.load_extension("cogs.randomgame")
bot.load_extension("cogs.crawling")
bot.load_extension("cogs.maple")
bot.load_extension("cogs.br31")
bot.load_extension("cogs.inchant")
bot.load_extension("cogs.music")
bot.load_extension("cogs.setting")

@bot.event
async def on_ready():
print("등장 : ")
print(bot.user.name)
print(bot.user.id)
print("----------")
print(len(bot.guilds), "개 서버에서 동작 중")
print("==========")
game = discord.Game("퓨이린 봇 개발모드")
await bot.change_presence(status=discord.Status.online, activity=game)

bot.run(token)
32 changes: 32 additions & 0 deletions discord bot/beta v.10.5/cardgame.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

def fresh_deck():
suits = {"Spade", "Heart", "Diamond", "Club"}
ranks = {2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "Q", "K", "A"}
deck = []
for suit in suits:
for rank in ranks:
deck.append((suit, rank))
import random
random.shuffle(deck)
return deck

def hit(deck):
if deck == []:
deck = fresh_deck()
return (deck[0], deck[1:])

def count_score(cards):
score = 0
num_of_ace = 0
for card in cards:
if card[1] in [2,3,4,5,6,7,8,9,10]:
score += card[1]
elif card[1] in ["J", "Q", "K"]:
score += 10
else: #'A'
score += 11
num_of_ace += 1
while score > 21 and num_of_ace >= 1:
score -= 10
num_of_ace -= 1
return score
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
130 changes: 130 additions & 0 deletions discord bot/beta v.10.5/cogs/br31.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
from discord.ext import commands
import asyncio
import random
import discord
import re

class Br31(commands.Cog):

def __init__(self, bot):
self.bot = bot

@commands.command(name="배라", pass_context=True)
async def br(self, ctx):
embed = discord.Embed(title="배스킨라빈스 31", description=":exclamation: 채널 관리 & 역할 관리 권한 필요 :exclamation: ", color=0xFAED7D)
embed.add_field(name="시작하려면 /시작", value="끝내려면 /종료")
await ctx.send(embed=embed)
def check1(res):
return res.content == '/시작' or res.content == '/종료'
try:
res = await self.bot.wait_for('message', timeout=10.0, check=check1)
if res.content == "/시작":
embed = discord.Embed(title="배스킨라빈스 31", description="", color=0xFAED7D)
embed.add_field(name="여기여기 모여라", value="참여하실 분은 10초 안에 아래 감정표현을 눌러주세요")
message = await ctx.send(embed=embed)
await message.add_reaction('👍')
def check2(reaction, user):
return user == ctx.author and str(reaction.emoji) == '👍'
try:
reaction, user = await self.bot.wait_for('reaction_add', timeout=10.0, check=check2)
await asyncio.sleep(10)
user_list = []
async for i in reaction.users():
if (not i.bot):
user_list.append(i.name)
if len(user_list) < 1:
await ctx.send("참여인원이 부족하여 게임을 종료합니다.")
return None
await ctx.send("참여인원 : %s" %user_list)
try:
channel = await ctx.guild.create_text_channel('배스킨라빈스')
try:
async for i in reaction.users():
await channel.set_permissions(i, read_messages=True, send_messages=True)
embed = discord.Embed(title='입력 규칙 설명', description='입력은 1 2 3과 같이 띄어쓰기로 구분합니다.', color=0xFAED7D)
await channel.send(embed=embed)
await channel.send("순서를 정합니다.")
user_list.append("퓨이린 봇")
random.shuffle(user_list)
my_str = ""
for i in user_list:
if i == user_list[-1]:
my_str += i
else:
my_str = my_str + i + " -> "
await channel.send("%s" %my_str)
turn = 0
history = 0
while True:
if user_list[turn % len(user_list)] == '퓨이린 봇':
if history == 28:
how_many = random.randint(1, 2)
ans = ""
if how_many == 1:
ans += str(history + 1)
history += 1; turn += 1
await channel.send(ans)
elif how_many == 2:
ans += str(history + 1) + " " + str(history + 2)
history += 2; turn += 1
await channel.send(ans)
elif history == 29:
await channel.send("30")
history += 1; turn += 1
elif history == 30:
await channel.send("봇이 패배했습니다")
await asyncio.sleep(5)
await channel.delete()
return None
else:
how_many = random.randint(1, 3)
ans = ""
if how_many == 1:
ans += str(history + 1)
history += 1; turn += 1
await channel.send(ans)
elif how_many == 2:
ans += str(history + 1) + " " + str(history + 2)
history += 2; turn += 1
await channel.send(ans)
else:
ans += str(history + 1) + " " + str(history + 2) + " " + str(history + 3)
history += 3; turn += 1
await channel.send(ans)
else:
def check3(message):
return message.author.name == user_list[turn % len(user_list)]
try:
if (history == 30):
await channel.send("%s 님의 패배입니다...." %user_list[turn % len(user_list)])
await asyncio.sleep(5)
await channel.delete()
return None
message = await self.bot.wait_for('message', timeout=20.0, check=check3)
human_ans = re.split(' ', message.content)
if (len(human_ans) > 3 or human_ans[0] != str(history + 1)):
await channel.send("잘못된 입력입니다.")
continue
history += len(human_ans)
turn += 1
except asyncio.TimeoutError:
await channel.send("입력 시간 초과로 %s 님의 패배입니다..." %user_list[turn % len(user_list)])
await asyncio.sleep(5)
await channel.delete()
return None
except discord.Forbidden:
await ctx.send("역할 관리 권한이 없습니다. 게임을 종료합니다.")
await channel.delete()
return None
except discord.Forbidden:
await ctx.send("채널 개설 권한이 없습니다. 게임을 종료합니다.")
except asyncio.TimeoutError:
pass
else:
await message.channel.send("게임이 종료되었습니다.")
except asyncio.TimeoutError:
pass


def setup(bot):
bot.add_cog(Br31(bot))
Loading

0 comments on commit d073ea5

Please sign in to comment.