Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,63 +1,31 @@
|
|
1 |
-
import
|
2 |
-
import
|
|
|
|
|
3 |
|
4 |
-
# λμ€μ½λ λ΄
|
5 |
-
|
6 |
-
CHANNELI = "1261896610506604564"
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
url = f"https://discord.com/api/v9/channels/{channelid}/messages"
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
# λ©μμ§
|
19 |
-
|
20 |
-
"content": message
|
21 |
-
}
|
22 |
|
23 |
-
|
24 |
-
|
|
|
|
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
else:
|
30 |
-
print(f"λ©μμ§ μ μ‘ μ€ν¨: {response.statuscode}")
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
url = f"https://discord.com/api/v9/channels/{channelid}/messages"
|
35 |
-
|
36 |
-
# ν€λ μ€μ
|
37 |
-
headers = {
|
38 |
-
"Authorization": DISCB,
|
39 |
-
"Content-ype": "application/json"
|
40 |
-
}
|
41 |
-
|
42 |
-
# λ©μμ§ μ μ‘
|
43 |
-
response = requests.get(url, headers=headers)
|
44 |
-
|
45 |
-
# μλ΅ μ²λ¦¬
|
46 |
-
if response.statuscode == 200:
|
47 |
-
messages = json.loads(response.text)
|
48 |
-
return messages[-1]["content"]
|
49 |
-
else:
|
50 |
-
print(f"λ©μμ§ κ°μ Έμ€ μ€ν¨: {response.statuscode}")
|
51 |
-
|
52 |
-
# λν μμ
|
53 |
-
message = input("μ¬μ©μ: ")
|
54 |
-
sendmessage(CHANNELI, message)
|
55 |
-
|
56 |
-
while True:
|
57 |
-
# μλ΅ λ°κΈ°
|
58 |
-
response = getmessage(CHANNELI)
|
59 |
-
print(f"AI: {response}")
|
60 |
-
|
61 |
-
# μ¬μ©μ μ
λ ₯
|
62 |
-
message = input("μ¬μ©μ: ")
|
63 |
-
sendmessage(CHANNELI, message)
|
|
|
1 |
+
import discord
|
2 |
+
from discord.ext import commands
|
3 |
+
from discord.ext.commands import Bot
|
4 |
+
import os
|
5 |
|
6 |
+
# λμ€μ½λ λ΄ ν ν°
|
7 |
+
ISC = "YISC"
|
|
|
8 |
|
9 |
+
# λμ€μ½λ λ΄ ν΄λΌμ΄μΈνΈ μμ±
|
10 |
+
client = Bot(commandprefix='!')
|
|
|
11 |
|
12 |
+
# λ©μμ§ μ²λ¦¬ ν¨μ
|
13 |
+
async def processmessage(message):
|
14 |
+
# λ©μμ§λ₯Ό λ°μ μ²λ¦¬
|
15 |
+
if message.author == client.user:
|
16 |
+
return
|
17 |
|
18 |
+
# λ©μμ§ μ²λ¦¬ λ‘μ§ μΆκ°
|
19 |
+
await message.channel.send(f"AI: {message.content}")
|
|
|
|
|
20 |
|
21 |
+
# μ΄λ²€νΈ νΈλ€ λ±λ‘
|
22 |
+
@client.event
|
23 |
+
async def onready():
|
24 |
+
print(f'{client.user} λ΄μ΄ μ€λΉλμμ΅λλ€.')
|
25 |
|
26 |
+
@client.event
|
27 |
+
async def onmessage(message):
|
28 |
+
await processmessage(message)
|
|
|
|
|
29 |
|
30 |
+
# λ΄ μ€ν
|
31 |
+
client.run(ISC)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|