ludamtalk 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ludamtalk-1.0.0/LICENSE +21 -0
- ludamtalk-1.0.0/PKG-INFO +60 -0
- ludamtalk-1.0.0/README.md +46 -0
- ludamtalk-1.0.0/ludamtalk/__init__.py +294 -0
- ludamtalk-1.0.0/ludamtalk.egg-info/PKG-INFO +60 -0
- ludamtalk-1.0.0/ludamtalk.egg-info/SOURCES.txt +9 -0
- ludamtalk-1.0.0/ludamtalk.egg-info/dependency_links.txt +1 -0
- ludamtalk-1.0.0/ludamtalk.egg-info/requires.txt +1 -0
- ludamtalk-1.0.0/ludamtalk.egg-info/top_level.txt +1 -0
- ludamtalk-1.0.0/pyproject.toml +21 -0
- ludamtalk-1.0.0/setup.cfg +4 -0
ludamtalk-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FRAMETECH STUDIO
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
ludamtalk-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ludamtalk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: 루담톡(LudamTalk) 온라인채팅 봇 SDK — 게이트웨이 연결, 명령어, 임베드, 보안 봇, AI 봇
|
|
5
|
+
Author: FRAMETECH STUDIO
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://ludamtalk.com/developers
|
|
8
|
+
Keywords: ludamtalk,루담톡,bot,chatbot,sdk
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: websockets>=12
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# ludamtalk
|
|
16
|
+
|
|
17
|
+
루담톡(LudamTalk) 온라인채팅 봇을 만드는 공식 파이썬 도구예요.
|
|
18
|
+
|
|
19
|
+
- 설명서: https://ludamtalk.com/developers
|
|
20
|
+
- 봇 만들기(열쇠 받기): https://web.ludamtalk.com/dev
|
|
21
|
+
|
|
22
|
+
## 설치
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install ludamtalk
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Python 3.9 이상이 필요해요.
|
|
29
|
+
|
|
30
|
+
## 예제
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
import os, random
|
|
34
|
+
import ludamtalk as ludam
|
|
35
|
+
|
|
36
|
+
bot = ludam.Bot(token=os.environ["LUDAM_TOKEN"])
|
|
37
|
+
|
|
38
|
+
@bot.event
|
|
39
|
+
async def on_ready(me):
|
|
40
|
+
print(me["name"], "온라인!")
|
|
41
|
+
|
|
42
|
+
@bot.command("주사위", "주사위를 굴려요")
|
|
43
|
+
async def dice(ctx):
|
|
44
|
+
await ctx.reply(f"🎲 **{random.randint(1, 6)}** 이(가) 나왔어요!")
|
|
45
|
+
|
|
46
|
+
@bot.command("날씨", "오늘 날씨")
|
|
47
|
+
async def weather(ctx):
|
|
48
|
+
e = ludam.Embed(title="오늘의 날씨", color=0x3b82f6, description="**맑음** · 최고 18°C")
|
|
49
|
+
await ctx.reply(embed=e)
|
|
50
|
+
|
|
51
|
+
bot.run()
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
켜기: `LUDAM_TOKEN=ldb_… python bot.py` (윈도우 PowerShell: `$env:LUDAM_TOKEN="ldb_…"; python bot.py`)
|
|
55
|
+
|
|
56
|
+
봇 열쇠(ldb_…)는 비밀번호처럼 다뤄 주세요. 코드에 바로 적거나 다른 사람에게 보여 주지 마세요.
|
|
57
|
+
|
|
58
|
+
## 라이선스
|
|
59
|
+
|
|
60
|
+
MIT © FRAMETECH STUDIO
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# ludamtalk
|
|
2
|
+
|
|
3
|
+
루담톡(LudamTalk) 온라인채팅 봇을 만드는 공식 파이썬 도구예요.
|
|
4
|
+
|
|
5
|
+
- 설명서: https://ludamtalk.com/developers
|
|
6
|
+
- 봇 만들기(열쇠 받기): https://web.ludamtalk.com/dev
|
|
7
|
+
|
|
8
|
+
## 설치
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install ludamtalk
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Python 3.9 이상이 필요해요.
|
|
15
|
+
|
|
16
|
+
## 예제
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
import os, random
|
|
20
|
+
import ludamtalk as ludam
|
|
21
|
+
|
|
22
|
+
bot = ludam.Bot(token=os.environ["LUDAM_TOKEN"])
|
|
23
|
+
|
|
24
|
+
@bot.event
|
|
25
|
+
async def on_ready(me):
|
|
26
|
+
print(me["name"], "온라인!")
|
|
27
|
+
|
|
28
|
+
@bot.command("주사위", "주사위를 굴려요")
|
|
29
|
+
async def dice(ctx):
|
|
30
|
+
await ctx.reply(f"🎲 **{random.randint(1, 6)}** 이(가) 나왔어요!")
|
|
31
|
+
|
|
32
|
+
@bot.command("날씨", "오늘 날씨")
|
|
33
|
+
async def weather(ctx):
|
|
34
|
+
e = ludam.Embed(title="오늘의 날씨", color=0x3b82f6, description="**맑음** · 최고 18°C")
|
|
35
|
+
await ctx.reply(embed=e)
|
|
36
|
+
|
|
37
|
+
bot.run()
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
켜기: `LUDAM_TOKEN=ldb_… python bot.py` (윈도우 PowerShell: `$env:LUDAM_TOKEN="ldb_…"; python bot.py`)
|
|
41
|
+
|
|
42
|
+
봇 열쇠(ldb_…)는 비밀번호처럼 다뤄 주세요. 코드에 바로 적거나 다른 사람에게 보여 주지 마세요.
|
|
43
|
+
|
|
44
|
+
## 라이선스
|
|
45
|
+
|
|
46
|
+
MIT © FRAMETECH STUDIO
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
# 루담톡 봇 SDK (Python 3.9 이상)
|
|
2
|
+
# 설치: pip install ludamtalk (또는 https://ludamtalk.com/sdk/ludam.py 를 받아서 pip install websockets)
|
|
3
|
+
# 설명서: https://ludamtalk.com/developers
|
|
4
|
+
#
|
|
5
|
+
# import os, random, ludamtalk as ludam
|
|
6
|
+
# bot = ludam.Bot(token=os.environ["LUDAM_TOKEN"])
|
|
7
|
+
#
|
|
8
|
+
# @bot.event
|
|
9
|
+
# async def on_ready(me):
|
|
10
|
+
# print(f"{me['name']} 온라인!")
|
|
11
|
+
#
|
|
12
|
+
# @bot.command("주사위", "주사위를 굴려요")
|
|
13
|
+
# async def dice(ctx):
|
|
14
|
+
# await ctx.reply(f"🎲 **{random.randint(1, 6)}**")
|
|
15
|
+
#
|
|
16
|
+
# bot.run()
|
|
17
|
+
#
|
|
18
|
+
# AI 봇: await ctx.typing(ai=True); answer = await ask_ai(ctx.args); await ctx.reply(answer, ai=True)
|
|
19
|
+
# 보안 봇: @bot.event
|
|
20
|
+
# async def on_member_join(ctx):
|
|
21
|
+
# if ctx.user.get("newAccount"): await ctx.timeout(10, "새 계정")
|
|
22
|
+
import asyncio
|
|
23
|
+
import json
|
|
24
|
+
import random
|
|
25
|
+
import re
|
|
26
|
+
import urllib.error
|
|
27
|
+
import urllib.request
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
import websockets
|
|
31
|
+
except ImportError: # pragma: no cover
|
|
32
|
+
websockets = None
|
|
33
|
+
|
|
34
|
+
API = "https://api.ludamtalk.com"
|
|
35
|
+
GATEWAY = "wss://api.ludamtalk.com/bot/gateway"
|
|
36
|
+
VERSION = "1.0.0"
|
|
37
|
+
_CMD_RE = re.compile(r"^[a-z0-9가-힣_]{1,20}$")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class LudamError(Exception):
|
|
41
|
+
def __init__(self, status, code, message=None):
|
|
42
|
+
super().__init__(message or f"루담 API 오류 ({status} {code})")
|
|
43
|
+
self.status = status
|
|
44
|
+
self.code = code
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class Embed:
|
|
48
|
+
"""임베드 만들기 도우미: Embed(title="…", color=0x3b82f6).add_field("이름", "값", inline=True)"""
|
|
49
|
+
|
|
50
|
+
def __init__(self, title=None, description=None, url=None, color=None):
|
|
51
|
+
self.data = {}
|
|
52
|
+
if title: self.data["title"] = title
|
|
53
|
+
if description: self.data["description"] = description
|
|
54
|
+
if url: self.data["url"] = url
|
|
55
|
+
if color is not None: self.data["color"] = color
|
|
56
|
+
|
|
57
|
+
def set_author(self, name): self.data["author"] = {"name": name}; return self
|
|
58
|
+
def set_footer(self, text): self.data["footer"] = {"text": text}; return self
|
|
59
|
+
def set_image(self, url): self.data["image"] = {"url": url}; return self
|
|
60
|
+
def set_thumbnail(self, url): self.data["thumbnail"] = {"url": url}; return self
|
|
61
|
+
|
|
62
|
+
def add_field(self, name, value, inline=False):
|
|
63
|
+
self.data.setdefault("fields", []).append({"name": name, "value": value, "inline": inline})
|
|
64
|
+
return self
|
|
65
|
+
|
|
66
|
+
def to_dict(self): return dict(self.data)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _payload(content=None, embed=None, embeds=None, ai=False):
|
|
70
|
+
out = {"ai": True} if ai else {}
|
|
71
|
+
if isinstance(content, Embed):
|
|
72
|
+
embed, content = content, None
|
|
73
|
+
if content:
|
|
74
|
+
out["text"] = str(content)
|
|
75
|
+
es = list(embeds or []) + ([embed] if embed else [])
|
|
76
|
+
if es:
|
|
77
|
+
out["embeds"] = [e.to_dict() if isinstance(e, Embed) else e for e in es]
|
|
78
|
+
return out
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class Context:
|
|
82
|
+
"""명령어·메시지 하나. ctx.reply("…"), ctx.send("…"), ctx.delete(), ctx.kick()"""
|
|
83
|
+
|
|
84
|
+
def __init__(self, bot, d):
|
|
85
|
+
self.bot = bot
|
|
86
|
+
self.raw = d
|
|
87
|
+
self.type = d.get("type")
|
|
88
|
+
self.room = d.get("room") or {}
|
|
89
|
+
self.user = d.get("user") or {}
|
|
90
|
+
self.message = d.get("message") or {}
|
|
91
|
+
self.text = d.get("text") or self.message.get("text") or ""
|
|
92
|
+
self.command = d.get("command") or ""
|
|
93
|
+
self.args = d.get("args") or ""
|
|
94
|
+
self.argv = self.args.split() if self.args else []
|
|
95
|
+
self.reply_token = d.get("replyToken") or ""
|
|
96
|
+
|
|
97
|
+
async def reply(self, content=None, *, embed=None, embeds=None, ai=False):
|
|
98
|
+
return await self.bot.api("reply", {"replyToken": self.reply_token, **_payload(content, embed, embeds, ai)})
|
|
99
|
+
|
|
100
|
+
async def send(self, content=None, *, embed=None, embeds=None, ai=False):
|
|
101
|
+
return await self.bot.send(self.room.get("id"), content, embed=embed, embeds=embeds, ai=ai)
|
|
102
|
+
|
|
103
|
+
async def typing(self, ai=False): # ⌨️ "입력 중" 10초 (ai=True면 "AI가 답을 쓰는 중")
|
|
104
|
+
return await self.bot.typing(self.room.get("id"), ai)
|
|
105
|
+
|
|
106
|
+
async def timeout(self, minutes=10, reason=""): # 관리 권한: 잠깐 말 못 하게
|
|
107
|
+
return await self.bot.timeout(self.room.get("id"), self.user.get("id"), minutes, reason)
|
|
108
|
+
|
|
109
|
+
async def delete(self): # 관리 권한
|
|
110
|
+
return await self.bot.api("delete", {"room": self.room.get("id"), "message": self.message.get("id")})
|
|
111
|
+
|
|
112
|
+
async def kick(self): # 관리 권한
|
|
113
|
+
return await self.bot.api("kick", {"room": self.room.get("id"), "user": self.user.get("id")})
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class Bot:
|
|
117
|
+
def __init__(self, token, sync_commands=True, reconnect=True):
|
|
118
|
+
if not token or not str(token).startswith("ldb_"):
|
|
119
|
+
raise ValueError("봇 열쇠(token)가 필요해요. 개발자 사이트에서 받은 ldb_… 값을 넣어 주세요.")
|
|
120
|
+
self.token = token
|
|
121
|
+
self.sync_commands = sync_commands
|
|
122
|
+
self.reconnect = reconnect
|
|
123
|
+
self.commands = {} # 이름 → (설명, 함수)
|
|
124
|
+
self.events = {} # on_ready · on_message · on_command · on_install · on_uninstall · on_error
|
|
125
|
+
self.user = None
|
|
126
|
+
self._closed = False
|
|
127
|
+
|
|
128
|
+
# @bot.event 로 on_ready 같은 함수를 등록해요
|
|
129
|
+
def event(self, fn):
|
|
130
|
+
self.events[fn.__name__] = fn
|
|
131
|
+
return fn
|
|
132
|
+
|
|
133
|
+
# @bot.command("이름", "설명")
|
|
134
|
+
def command(self, name, description=""):
|
|
135
|
+
n = str(name).lstrip("/").lower()
|
|
136
|
+
if not _CMD_RE.match(n):
|
|
137
|
+
raise ValueError(f"명령어 이름이 규칙에 맞지 않아요: {name} (한글·영어 소문자·숫자·_ 20자까지)")
|
|
138
|
+
|
|
139
|
+
def deco(fn):
|
|
140
|
+
self.commands[n] = (str(description)[:60], fn)
|
|
141
|
+
return fn
|
|
142
|
+
|
|
143
|
+
return deco
|
|
144
|
+
|
|
145
|
+
def _post(self, path, body):
|
|
146
|
+
req = urllib.request.Request(
|
|
147
|
+
f"{API}/bot/api/{path}", data=json.dumps(body).encode("utf-8"), method="POST",
|
|
148
|
+
headers={"Authorization": f"Bot {self.token}", "Content-Type": "application/json", "User-Agent": f"LudamBotPy/{VERSION}"},
|
|
149
|
+
)
|
|
150
|
+
try:
|
|
151
|
+
with urllib.request.urlopen(req, timeout=15) as r:
|
|
152
|
+
return json.loads(r.read().decode("utf-8") or "{}")
|
|
153
|
+
except urllib.error.HTTPError as e:
|
|
154
|
+
try:
|
|
155
|
+
data = json.loads(e.read().decode("utf-8") or "{}")
|
|
156
|
+
except Exception:
|
|
157
|
+
data = {}
|
|
158
|
+
raise LudamError(e.code, data.get("error", "error"), data.get("error_description")) from None
|
|
159
|
+
|
|
160
|
+
async def api(self, path, body=None):
|
|
161
|
+
return await asyncio.to_thread(self._post, path, body or {})
|
|
162
|
+
|
|
163
|
+
async def me(self):
|
|
164
|
+
return await self.api("me")
|
|
165
|
+
|
|
166
|
+
async def send(self, room_id, content=None, *, embed=None, embeds=None, ai=False):
|
|
167
|
+
return await self.api("send", {"room": room_id, **_payload(content, embed, embeds, ai)})
|
|
168
|
+
|
|
169
|
+
async def typing(self, room_id, ai=False):
|
|
170
|
+
return await self.api("typing", {"room": room_id, "ai": bool(ai)})
|
|
171
|
+
|
|
172
|
+
# 🛡️ 보안 봇 (관리 권한)
|
|
173
|
+
async def members(self, room_id):
|
|
174
|
+
return await self.api("members", {"room": room_id})
|
|
175
|
+
|
|
176
|
+
async def timeout(self, room_id, user_id, minutes=10, reason=""):
|
|
177
|
+
return await self.api("timeout", {"room": room_id, "user": user_id, "minutes": minutes, "reason": reason})
|
|
178
|
+
|
|
179
|
+
async def untimeout(self, room_id, user_id):
|
|
180
|
+
return await self.api("untimeout", {"room": room_id, "user": user_id})
|
|
181
|
+
|
|
182
|
+
async def lock(self, room_id, reason=""):
|
|
183
|
+
return await self.api("lock", {"room": room_id, "locked": True, "reason": reason})
|
|
184
|
+
|
|
185
|
+
async def unlock(self, room_id):
|
|
186
|
+
return await self.api("lock", {"room": room_id, "locked": False})
|
|
187
|
+
|
|
188
|
+
async def purge(self, room_id, message_ids):
|
|
189
|
+
return await self.api("purge", {"room": room_id, "messages": list(message_ids)[:100]})
|
|
190
|
+
|
|
191
|
+
async def unban(self, room_id, user_id):
|
|
192
|
+
return await self.api("unban", {"room": room_id, "user": user_id})
|
|
193
|
+
|
|
194
|
+
async def rooms(self):
|
|
195
|
+
out, cursor = [], ""
|
|
196
|
+
while True:
|
|
197
|
+
r = await self.api("rooms", {"cursor": cursor} if cursor else {})
|
|
198
|
+
out += r.get("rooms", [])
|
|
199
|
+
cursor = r.get("cursor") or ""
|
|
200
|
+
if not cursor:
|
|
201
|
+
return out
|
|
202
|
+
|
|
203
|
+
async def _emit(self, name, *args):
|
|
204
|
+
fn = self.events.get(name)
|
|
205
|
+
if fn:
|
|
206
|
+
try:
|
|
207
|
+
await fn(*args)
|
|
208
|
+
except Exception as e: # 봇 코드 오류로 연결이 끊기지 않게
|
|
209
|
+
await self._error(e)
|
|
210
|
+
|
|
211
|
+
async def _error(self, e):
|
|
212
|
+
fn = self.events.get("on_error")
|
|
213
|
+
if fn:
|
|
214
|
+
await fn(e)
|
|
215
|
+
else:
|
|
216
|
+
print("[루담 봇]", e)
|
|
217
|
+
|
|
218
|
+
async def _dispatch(self, d):
|
|
219
|
+
ctx = Context(self, d)
|
|
220
|
+
t = d.get("type")
|
|
221
|
+
if t == "command":
|
|
222
|
+
await self._emit("on_command", ctx)
|
|
223
|
+
c = self.commands.get(str(d.get("command") or "").lower())
|
|
224
|
+
if c:
|
|
225
|
+
try:
|
|
226
|
+
await c[1](ctx)
|
|
227
|
+
except Exception as e:
|
|
228
|
+
await self._error(e)
|
|
229
|
+
elif t in ("message", "install", "uninstall", "ping", "member_join", "member_leave"):
|
|
230
|
+
await self._emit(f"on_{t}", ctx)
|
|
231
|
+
|
|
232
|
+
def _connect(self):
|
|
233
|
+
headers = {"Authorization": f"Bot {self.token}", "User-Agent": f"LudamBotPy/{VERSION}"}
|
|
234
|
+
try: # websockets 14 이상
|
|
235
|
+
return websockets.connect(GATEWAY, additional_headers=headers, ping_interval=None)
|
|
236
|
+
except TypeError: # 예전 버전
|
|
237
|
+
return websockets.connect(GATEWAY, extra_headers=headers, ping_interval=None)
|
|
238
|
+
|
|
239
|
+
async def start(self):
|
|
240
|
+
if websockets is None:
|
|
241
|
+
raise RuntimeError("websockets 패키지가 필요해요: pip install websockets")
|
|
242
|
+
if self.sync_commands and self.commands:
|
|
243
|
+
try:
|
|
244
|
+
await self.api("commands", {"commands": [{"name": n, "description": c[0]} for n, c in self.commands.items()]})
|
|
245
|
+
except LudamError as e:
|
|
246
|
+
print("[루담 봇] 명령어 맞추기 실패:", e)
|
|
247
|
+
tries = 0
|
|
248
|
+
while not self._closed:
|
|
249
|
+
try:
|
|
250
|
+
async with self._connect() as ws:
|
|
251
|
+
beat = None
|
|
252
|
+
async for raw in ws:
|
|
253
|
+
try:
|
|
254
|
+
m = json.loads(raw)
|
|
255
|
+
except ValueError:
|
|
256
|
+
continue
|
|
257
|
+
if m.get("op") == "ready":
|
|
258
|
+
tries = 0
|
|
259
|
+
self.user = m.get("bot")
|
|
260
|
+
gap = (m.get("heartbeat") or 30000) / 1000
|
|
261
|
+
|
|
262
|
+
async def heartbeat():
|
|
263
|
+
while True:
|
|
264
|
+
await asyncio.sleep(gap)
|
|
265
|
+
await ws.send('{"op":"ping"}')
|
|
266
|
+
|
|
267
|
+
beat = asyncio.create_task(heartbeat())
|
|
268
|
+
await self._emit("on_ready", self.user)
|
|
269
|
+
elif m.get("op") == "event" and m.get("d"):
|
|
270
|
+
asyncio.create_task(self._dispatch(m["d"]))
|
|
271
|
+
if beat:
|
|
272
|
+
beat.cancel()
|
|
273
|
+
if getattr(ws, "close_code", None) == 4004: # 열쇠를 새로 받아서 끊김
|
|
274
|
+
self._closed = True
|
|
275
|
+
except Exception as e:
|
|
276
|
+
status = getattr(getattr(e, "response", None), "status_code", None) or getattr(e, "status_code", None)
|
|
277
|
+
if status == 401:
|
|
278
|
+
print("[루담 봇] 봇 열쇠가 틀렸어요. 개발자 사이트에서 확인해 주세요.")
|
|
279
|
+
return
|
|
280
|
+
await self._error(e)
|
|
281
|
+
if self._closed or not self.reconnect:
|
|
282
|
+
return
|
|
283
|
+
await asyncio.sleep(min(60, 2 * 2 ** min(tries, 5)) + random.random())
|
|
284
|
+
tries += 1
|
|
285
|
+
|
|
286
|
+
def run(self):
|
|
287
|
+
"""봇 켜기 (Ctrl+C로 끄기)"""
|
|
288
|
+
try:
|
|
289
|
+
asyncio.run(self.start())
|
|
290
|
+
except KeyboardInterrupt:
|
|
291
|
+
print("[루담 봇] 껐어요")
|
|
292
|
+
|
|
293
|
+
def close(self):
|
|
294
|
+
self._closed = True
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ludamtalk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: 루담톡(LudamTalk) 온라인채팅 봇 SDK — 게이트웨이 연결, 명령어, 임베드, 보안 봇, AI 봇
|
|
5
|
+
Author: FRAMETECH STUDIO
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://ludamtalk.com/developers
|
|
8
|
+
Keywords: ludamtalk,루담톡,bot,chatbot,sdk
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: websockets>=12
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# ludamtalk
|
|
16
|
+
|
|
17
|
+
루담톡(LudamTalk) 온라인채팅 봇을 만드는 공식 파이썬 도구예요.
|
|
18
|
+
|
|
19
|
+
- 설명서: https://ludamtalk.com/developers
|
|
20
|
+
- 봇 만들기(열쇠 받기): https://web.ludamtalk.com/dev
|
|
21
|
+
|
|
22
|
+
## 설치
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install ludamtalk
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Python 3.9 이상이 필요해요.
|
|
29
|
+
|
|
30
|
+
## 예제
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
import os, random
|
|
34
|
+
import ludamtalk as ludam
|
|
35
|
+
|
|
36
|
+
bot = ludam.Bot(token=os.environ["LUDAM_TOKEN"])
|
|
37
|
+
|
|
38
|
+
@bot.event
|
|
39
|
+
async def on_ready(me):
|
|
40
|
+
print(me["name"], "온라인!")
|
|
41
|
+
|
|
42
|
+
@bot.command("주사위", "주사위를 굴려요")
|
|
43
|
+
async def dice(ctx):
|
|
44
|
+
await ctx.reply(f"🎲 **{random.randint(1, 6)}** 이(가) 나왔어요!")
|
|
45
|
+
|
|
46
|
+
@bot.command("날씨", "오늘 날씨")
|
|
47
|
+
async def weather(ctx):
|
|
48
|
+
e = ludam.Embed(title="오늘의 날씨", color=0x3b82f6, description="**맑음** · 최고 18°C")
|
|
49
|
+
await ctx.reply(embed=e)
|
|
50
|
+
|
|
51
|
+
bot.run()
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
켜기: `LUDAM_TOKEN=ldb_… python bot.py` (윈도우 PowerShell: `$env:LUDAM_TOKEN="ldb_…"; python bot.py`)
|
|
55
|
+
|
|
56
|
+
봇 열쇠(ldb_…)는 비밀번호처럼 다뤄 주세요. 코드에 바로 적거나 다른 사람에게 보여 주지 마세요.
|
|
57
|
+
|
|
58
|
+
## 라이선스
|
|
59
|
+
|
|
60
|
+
MIT © FRAMETECH STUDIO
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
websockets>=12
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ludamtalk
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ludamtalk"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "루담톡(LudamTalk) 온라인채팅 봇 SDK — 게이트웨이 연결, 명령어, 임베드, 보안 봇, AI 봇"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "FRAMETECH STUDIO" }]
|
|
14
|
+
dependencies = ["websockets>=12"]
|
|
15
|
+
keywords = ["ludamtalk", "루담톡", "bot", "chatbot", "sdk"]
|
|
16
|
+
|
|
17
|
+
[project.urls]
|
|
18
|
+
Homepage = "https://ludamtalk.com/developers"
|
|
19
|
+
|
|
20
|
+
[tool.setuptools]
|
|
21
|
+
packages = ["ludamtalk"]
|