This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
/// <summary> | |
/// TaskCompletionSource๋ฅผ ์ด์ฉํ ๋น๋๊ธฐ ๋ฐํ ํด๋์ค ์ ๋๋ค. | |
/// JavaScript์ Promise๋ฅผ ๋ชจ๋ฐฉํ ํด๋์ค์ ๋๋ค. | |
/// </summary> | |
/// <remarks> | |
/// JavaScript์์์ Promise (MDN Docs): | |
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import request, json | |
r = requests.post("https://siro.dev/api/urls") # https://siro.dev/api/urls์ POST๋ก ์์ฒญ์ ๋ณด๋ ๋๋ค. | |
data = r.text # ์๋ต๊ฐ์ data์ ์ ์ฅํฉ๋๋ค HTTP ์ํ ์ฝ๋๋ฅผ ์ํ ๊ฒฝ์ฐ, r.status_code๋ฅผ ์ฌ์ฉํฉ๋๋ค. | |
data_loaded = json.loads(data) # ์๋ต๊ฐ์ด JSON์ด๊ธฐ์, Python์์ ์ฌ์ฉํ ์ ์๋๋ก ๋ณํ ์์ผ์ค๋๋ค. ๊ทธ๋ฆฌ๊ณ data_loaded์ ์ ์ฅํฉ๋๋ค. | |
# ์ด์ ์ํ๋ ๋ฐ์ดํฐ๋ฅผ data_loaded["๋ฐ์ดํฐ ์ด๋ฆ"] ์ผ๋ก ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค! (List์ ๊ฒฝ์ฐ ๋ฌธ์์ด(๋ฐ์ดํ) ๋์ ์ ์๋ฅผ ๋ฃ์ด Index๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค) | |
# Ex : data_loaded["api"]["date"] ๋ก "190806" ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ ์ฌ ์ ์์ต๋๋ค (API ๋ต๋ณ ์ {"api": {"date": "190806"}, (์๋ต)} ์ ๊ตฌ์กฐ์) | |
# ---------------------------------------------------------------- # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
๐ Morning 81 commits โโโโโโโโโโโโโโโโโโโโโ 13.7% | |
๐ Daytime 148 commits โโโโโโโโโโโโโโโโโโโโโ 25.0% | |
๐ Evening 299 commits โโโโโโโโโโโโโโโโโโโโโ 50.5% | |
๐ Night 64 commits โโโโโโโโโโโโโโโโโโโโโ 10.8% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ๋ณ๋์ ๋ชจ๋ ์ค์น๊ฐ ํ์ ์์ต๋๋ค. ์๋์ฒ๋ผ random ๋ชจ๋๋ง ๋ถ๋ฌ ์ ์ฃผ์๋ฉด ๋ฉ๋๋ค. | |
import random | |
# ๊ตฌํํ๋ ๋ฐฉ๋ฒ์ ๋ง์๋ฐ, ์ผ๋จ ์กฐ๊ธ ๋ณด๊ธฐ ์ฌ์ด ๋ฐฉ๋ฒ์ผ๋ก ๊ตฌ๋ฌธ์ ์์ฑํ๊ฒ ์ต๋๋ค. | |
# ๋ณดํต์ if message.content == "๊ฐ์": if message.content == "๋ฐ์": ๊ฐ์ด if๋ฅผ ๋ค ๋ฐ๋ก ์ง์ง๋ง, | |
# ์ด๋ฒ์๋ ์ ๋ ฅํ ๋ช ๋ น์ด๊ฐ "๊ฐ์", "๋ฐ์", "๋ณด" ์ ์ค์ ํ๋๋ผ๋ฉด ๋ฐ์ํ๋๋ก if๋ฌธ์ ์์ฑ ํ๊ฒ ์ต๋๋ค. | |
if message.content == "๊ฐ์" or message.content == "๋ฐ์" or message.content == "๋ณด": | |
# ๊ทธ๋ฆฌ๊ณ ๋์, ๋ค๋ฅธ ๊ตฌ๋ฌธ์ ๋จผ์ ์ง๊ธฐ ์ ์, ๋ด์ด ๋ฌด์์ ๋ผ์ง ์ ํ๊ฒ ์ต๋๋ค. | |
# ๊ฐ์/๋ฐ์/๋ณด ์ด 3๊ฐ์ง ๊ฒฝ์ฐ์ ์๊ฐ ์์ผ๋, 1๋ถํฐ 3๊น์ง ์ ์ค์์ ์๋ฌด๊ฑฐ๋ ๋ฝ์์ bot_response ๋ผ๋ ๋ณ์์ ๋ด์๋ณด๊ฒ ์ต๋๋ค. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# await ๋ฉ์์ง๋ณ์.add_reaction("Emoji") ๋ก ๋ฐ์์ ์ถ๊ฐํฉ๋๋ค. | |
# ์ ์ ๊ฐ ์ ๋ ฅํ ๋ช ๋ น์ด์ ๋ฐ์์ ๋ฌ๊ณ ์ถ์ผ์๋ฉด '๋ฉ์์ง๋ณ์'๋ฅผ message๋ก, | |
# ์ ์กํ์ ๋ฉ์์ง์ ๋ด๊ณ ์ถ์ผ์๋ฉด message.channel.send() ๊ตฌ๋ฌธ ์์ sent = ๋ผ๊ณ ์ฐ์๊ณ , | |
# '๋ฉ์์ง๋ณ์'๋ฅผ sent๋ก ์ ์ผ์๋ฉด ๋ฉ๋๋ค. | |
# ๋ชจ๋ ๋ฉ์์ง์ ๋ํ ๋ฐ์ ์ถ๊ฐ๋ฅผ ๊ฐ์งํ์ง๋ ๋ชปํ๊ณ , ํน์ ํ ๋ฉ์์ง์ ๋ํ ๋ฐ์๋ง ๊ฐ์ง ํ ์ ์์ต๋๋ค. | |
# ๊ทธ ์ ์, ์๋์ ๊ฐ์ ๊ตฌ๋ฌธ์ ์ฌ์ฉํ์ฌ ์ด๋ค ๋ฐ์์ ์ถ๊ฐ ํ ๋๋ง ๋ฐ์ํ ์ง ์ ์ํฉ๋๋ค. | |
def question_check(reaction, user): # question_check ๋ผ๋ ์ด๋ฆ์ ๋ง์๋๋ก ๋ฐ๊พธ์ ๋ ๋ฉ๋๋ค. | |
# ๋๊ตฌ๋ ์ง :one:๋ผ๋ ์ด๋ชจ์ง๋ :two:๋ผ๋ ์ด๋ชจ์ง๋ฅผ ๋๋ ์ ๋ ๋ฐ์ํ๊ฒ ๋ฉ๋๋ค. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ๋ฉ์์ง ๋ด์ฉ์์ "!๋ช ๋ น์ด"๋ฅผ "๊ฐ๋๋ค๋ผ"๋ก ๋ฐ๊พผ ๋ค์, ๋ฐ๊พผ ๋ด์ฉ์ message_replaced ๋ณ์์ ๋ด์ต๋๋ค. | |
# "๊ฐ๋๋ค๋ผ"๋ฅผ ""๋ก ๋์๋ฉด ๋ฉ์์ง ๋ด์ฉ์์ "!๋ช ๋ น์ด"๋ฅผ ์ง์๋ฒ๋ฆฌ๋ ๊ตฌ๋ฌธ์ด ๋ฉ๋๋ค. | |
message_replaced = message.content.replace("!๋ช ๋ น์ด", "๊ฐ๋๋ค๋ผ") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ์ฐ๋ฆฌ๊ฐ ๋ณดํต @๋ฉ์ ์ ํ๋ฉด <@์ ์ ID> ์ ํํ๋ก ์ ๋ ฅ๋ฉ๋๋ค. | |
# ์ฐ๋ฆฌ๋ ์ด ์ ์ ์ด์ฉํด์ ์ ์ ์ ๋ณด๋ฅผ ๋ด์ ๋ณ์๊น์ง ๋ง๋ค์ด ๋ณด๊ฒ ์ต๋๋ค. | |
ids = re.findall(r'\d+', message.content) # ๋ฉ์์ง์์ ์ซ์๋ง ๋ค ๋ฝ์๋ด์ list๋ก ์ ์ฅํฉ๋๋ค. | |
# ์ด ์๋ ๊ตฌ๋ฌธ์ ๋ช ๋ น์ด์ ์ซ์๊ฐ ์๋ค๋ ๊ฐ์ ํ์ ์์ฑ๋์์ต๋๋ค. ๋ช ๋ น์ด์ ์ซ์๊ฐ ์์ ๊ฒฝ์ฐ, [0]์ ๋ค๋ฅธ ์ซ์๋ก ๋ฐ๊ฟ์ฃผ์ ์ผ ํฉ๋๋ค. | |
# print(ids) ๊ตฌ๋ฌธ์ผ๋ก ๋ชจ๋ list๋ฅผ ๋ณด์ค ์ ์์ต๋๋ค. ์ถ๋ ฅ๋๋ ๋ด์ฉ์ ์ฐธ๊ณ ํด์ ๋ค๋ฅธ ์ซ์๋ก ๋ฐ๊ฟ์ฃผ์๋ฉด ๋ฉ๋๋ค. | |
# list๋ ['0๋ฒ', '1๋ฒ', '2๋ฒ', ... ] ์ ํํ๋ก ์ ์ฅ๋๋๋ฐ, ์ฒซ๋ฒ์งธ ๋ฐ์ดํ์ ๋ค์ด๊ฐ๋ ๋ด์ฉ์ด 0๋ฒ์ ๋๋ค. 1๋ฒ ์๋๋๋ค. | |
target = ids[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ์ด๊ฒ๋ ๋ฉ์์ง ์ ์ก ์ ์๋ง ์จ์ฃผ์๋ฉด ๋ฉ๋๋ค. | |
# url= ๋ค์๋ ์๊น ๋ณต์ฌํ ๋งํฌ๋ฅผ ์จ์ฃผ์๋ฉด ๋ฉ๋๋ค. | |
# "๋๋ ๋ฉ์์ง๋ฅผ ๋ณด๋ธ ์ ์ ์ ํ๋กํ ์ฌ์ง์ ๊ฐ์ ธ์ค๊ณ ์ถ๋ค!" ํ์๋ ๋ถ์ url= ๋ค์ ๋ฐ์ดํ ์ง์ฐ์๊ณ message.author.avatar_url ๋ฃ์ผ์๋ฉด ๋ฉ๋๋ค. | |
# ์ธ๋ค์ผ ๊ตฌ์ญ์ ์ด๋ฏธ์ง ๋ฃ๊ธฐ | |
embed.set_thumbnail(url="๋งํฌ") | |
# ๋ฉ์์ง ๊ตฌ์ญ์ ์ด๋ฏธ์ง ๋ฃ๊ธฐ | |
embed.set_image(url="๋งํฌ") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ์ฐ๋ฆฌ๊ฐ ๋ฉ์ธ์ ๋ชฉ๊ณผ ์ค๋ช ์ ์์ฑํ๋ ์ฝ๋ ์๋์ ์จ์ค์๋ค. | |
# ๋ฉ์์ง ์ ์ก ์ ์๋ง ์จ์ฃผ๋ฉด ๋ฉ๋๋ค. | |
# add_field๋ ์ฌ๋ฌ ๊ฐ ์ถ๊ฐํ ์ ์์ผ๋ฉฐ, ์ถ๊ฐํ ์์๋๋ก ์ถ๋ ฅ๋ฉ๋๋ค. | |
embed.add_field(name="์์ ๋ชฉ", value="์ค๋ช ", inline=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ์ด๋ฒ ๊ฐ์ข๋ฅผ ์ํด์ ์ถ๊ฐ์ ์ธ ๋ชจ๋์ ๋ถ๋ฌ ์ฌ ํ์๊ฐ ์์ต๋๋ค. ๋จ์ํ ๋ฉ์์ง ์ ์ก ๊ตฌ๋ฌธ์ ์๋๊ณผ ๊ฐ์ด ๋ฐ๊พธ๋ฉด ๋ฉ๋๋ค. | |
embed = discord.Embed(title="๋ฉ์ธ ์ ๋ชฉ", description="์ค๋ช ", color=0x62c1cc) # Embed์ ๊ธฐ๋ณธ ํ(์์, ๋ฉ์ธ ์ ๋ชฉ, ์ค๋ช )์ ์ก์์ค๋๋ค | |
embed.set_footer(text="ํ๋จ ์ค๋ช ") # ํ๋จ์ ๋ค์ด๊ฐ๋ ์กฐ๊ทธ๋งํ ์ค๋ช ์ ์ก์์ค๋๋ค | |
await message.channel.send(embed=embed) # embed๋ฅผ ํฌํจ ํ ์ฑ๋ก ๋ฉ์์ง๋ฅผ ์ ์กํฉ๋๋ค. | |
await message.channel.send("ํ ๋ง", embed=embed) # embed์ ๋ฉ์์ง๋ฅผ ํจ๊ป ๋ณด๋ด๊ณ ์ถ์ผ์๋ฉด ์ด๋ ๊ฒ ์ฌ์ฉํ์๋ฉด ๋ฉ๋๋ค. |
NewerOlder