루담이 만든 봇 도구를 쓰면 연결·다시 연결·명령어 등록을 알아서 해 줘요. 명령어는 코드에 적으면 봇을 켤 때 자동으로 등록돼요(다시 심사 없음). 처음이면 자바스크립트나 파이썬을 추천해요. 모든 언어에서 대답·보내기·입력 중·임베드·AI 표시·보안 봇 기능을 똑같이 쓸 수 있어요.
npm i ludamtalk → require("ludamtalk") (npm 페이지 · 파일로 받기: ludam.js)npm i ludamtalk → import { Client } from "ludamtalk"pip install ludamtalk → import ludamtalk as ludam (PyPI 페이지 · 파일로 받기: ludam.py)go get ludamtalk.com/sdk/go → import ludamtalk "ludamtalk.com/sdk/go" → ludamtalk.New(token), bot.Command(…), bot.Run(ctx)cargo add ludamtalk tokio --features tokio/full (crates.io 페이지) → Bot::new(token), bot.command(…), bot.run().awaitrepositories { maven("https://jitpack.io") } · implementation("com.github.FRAMETECH-STUDIO:ludamtalk-sdk:v1.0.0") → Kotlin LudamBot(token) · Java bot.commandJava(…)const { Client, Embed } = require("ludamtalk");
const bot = new Client({ token: process.env.LUDAM_TOKEN });
bot.on("ready", (me) => console.log(me.name + " 온라인!"));
bot.command("주사위", "주사위를 굴려요", async (ctx) => {
const n = 1 + Math.floor(Math.random() * 6);
await ctx.reply(`주사위: **${n}**`);
});
bot.command("날씨", "오늘 날씨", async (ctx) => {
await ctx.reply(new Embed()
.title("오늘의 날씨").color(0x3b82f6)
.description("**맑음** · 최고 18°C")
.field("미세먼지", "좋음", true));
});
// "모든 메시지" 권한이 있는 봇만 (예: 욕설 지우는 보안 봇)
bot.on("message", async (msg) => {
if (msg.text.includes("나쁜말")) await msg.delete(); // 관리 권한
});
bot.login();
켜기: LUDAM_TOKEN=ldb_… node bot.js (윈도우 PowerShell: $env:LUDAM_TOKEN="ldb_…"; node bot.js)
import os, random
import ludamtalk as ludam
bot = ludam.Bot(token=os.environ["LUDAM_TOKEN"])
@bot.event
async def on_ready(me):
print(me["name"], "온라인!")
@bot.command("주사위", "주사위를 굴려요")
async def dice(ctx):
await ctx.reply(f"주사위: **{random.randint(1, 6)}**")
@bot.command("날씨", "오늘 날씨")
async def weather(ctx):
e = ludam.Embed(title="오늘의 날씨", color=0x3b82f6,
description="**맑음** · 최고 18°C")
e.add_field("미세먼지", "좋음", inline=True)
await ctx.reply(embed=e)
# "모든 메시지" 권한이 있는 봇만
@bot.event
async def on_message(msg):
if "나쁜말" in msg.text:
await msg.delete() # 관리 권한
bot.run()
켜기: LUDAM_TOKEN=ldb_… python bot.py (윈도우 PowerShell: $env:LUDAM_TOKEN="ldb_…"; python bot.py)
ctx.reply() 대답 · ctx.send()·bot.send(방 번호, …) 보내기 · bot.rooms() 봇이 들어간 방 · ctx.delete()·ctx.kick()(관리 권한) · 이벤트 ready · command · message · install · uninstall.봇 서버가 루담에 웹소켓으로 연결해 두면, 이벤트가 그 연결로 바로 와요. 공개 주소가 없는 컴퓨터에서도 돌릴 수 있어요.
// Node.js (npm i ws)
const WebSocket = require("ws");
const TOKEN = process.env.LUDAM_BOT_TOKEN; // ldb_…
function connect() {
const ws = new WebSocket("wss://api.ludamtalk.com/bot/gateway", {
headers: { Authorization: "Bot " + TOKEN },
});
let beat;
ws.on("message", async (raw) => {
const m = JSON.parse(raw);
if (m.op === "ready") beat = setInterval(() => ws.send('{"op":"ping"}'), m.heartbeat);
if (m.op === "event" && m.d.type === "command" && m.d.command === "주사위") {
await reply(m.d.replyToken, { text: `주사위: **${1 + Math.floor(Math.random() * 6)}**` });
}
});
ws.on("close", () => { clearInterval(beat); setTimeout(connect, 3000); });
}
async function reply(replyToken, body) {
await fetch("https://api.ludamtalk.com/bot/api/reply", {
method: "POST",
headers: { Authorization: "Bot " + TOKEN, "Content-Type": "application/json" },
body: JSON.stringify({ replyToken, ...body }),
});
}
connect();
{"op":"ready","heartbeat":30000}이 와요. 30초마다 {"op":"ping"}을 보내 주세요.403 not_approved, 만든 사람이 이용 제한 중이면 403 owner_banned로 연결이 거절돼요.사람은 그 방 닉네임과 방마다 다른 번호(u+16자리, 예: u3f9a…)로만 와요. 같은 사람도 방이 다르면 번호가 달라요. 방도 봇마다 다른 번호(r+16자리)예요. 아이디·계정·연락처는 오지 않아요.
{
"op": "event",
"d": {
"type": "command", // command · message · install · uninstall · ping
"bot": { "id": "…", "name": "주사위봇" },
"room": { "id": "r4c1e…", "title": "보드게임 모임" },
"user": { "id": "u3f9a…", "name": "방 닉네임" },
"text": "/주사위 2", // 보낸 글
"message": { "id": "m…", "text": "/주사위 2" }, // id는 암호 번호(약 65자, m으로 시작) — 그대로 /delete 에 넘겨요
"command": "주사위", "args": "2",
"replyToken": "rt1.…", // 15분 동안 대답 5개까지
"at": "2026-11-16T12:00:00.000Z"
}
}
/명령어를 썼을 때. /명령어@봇이름이면 그 봇만 받아요.user.newAccount가 true면 만든 지 7일이 안 된 계정이에요 (습격 막기용).message.mentions는 그 메시지에서 부른 사람 수, message.reply는 답장인지예요 (멘션 도배 막기용).message.id·replyToken은 루담만 풀 수 있는 암호 번호예요. 모양을 해석하지 말고 받은 그대로 쓰세요./명령어만 가고, "모든 메시지" 봇에게는 가지 않아요.모두 POST https://api.ludamtalk.com/bot/api/…, 머리글 Authorization: Bot ldb_…, 본문은 JSON이에요.
{ replyToken, text, embeds } — 명령에 대답 (15분 안, 5개까지). 보낸 메시지 번호(m…)를 돌려줘요{ room, text, embeds } — 봇이 들어간 방에 먼저 보내기 (한 방에 1분 20개까지). 보낸 메시지 번호(m…)를 돌려줘요{ cursor } — 봇이 들어간 방 목록 { rooms: [{ id, title, members }], cursor }. 다음 쪽은 받은 cursor를 넣어 다시 불러요 (봇마다 1분에 10번까지){ room, message } — 메시지 지우기 (방장·부방장·다른 봇 메시지는 못 지워요){ room, user } — 내보내기. user는 그 방 이벤트에서 받은 번호예요 (방장·부방장은 못 내보내요){ room, ai } — "입력 중" 10초 표시 (3초에 한 번까지). ai: true면 "AI로 답을 쓰고 있어요"로 보여요. 대답을 보내면 바로 사라져요{ room } — 방 사람 [{ id, name, role(owner·sub·member), timeoutUntil }]와 잠금 상태 (1분에 6번){ room, user, minutes(1~10080), reason } — 잠깐 말 못 하게 · 풀기. 방에 안내가 올라가요{ room, locked, reason } — 방 잠그기·풀기. 잠기면 방장·부방장만 말할 수 있어요 (도배·습격 막기){ room, messages: [m…] } — 한꺼번에 지우기 (100개까지){ room, user } — 내보낸 사람이 다시 들어올 수 있게ai: true를 넣으면 메시지에 "AI" 표시가 붙어요. GPT·Gemini 같은 AI로 만든 답에는 꼭 넣어 주세요운영자에게 "모든 메시지"·"관리" 권한을 승인받으면 이런 보안 봇을 만들 수 있어요. 방장·부방장은 봇이 건드릴 수 없어요.
message 이벤트 → 글을 검사 → delete 지우기, 여러 번이면 timeouttimeout + 최근 메시지 purgemessage.mentions가 많으면 지우고 경고member_join이 짧은 시간에 몰리면 lock으로 방 잠그기, newAccount면 잠깐 timeoutmember_join에 규칙 안내 보내기 (임베드로 꾸미기)kick(다시 못 들어와요) · unban · untimeout루담톡에 아직 없는 것: 역할(관리자 외 등급), 메시지 고침·지움 이벤트, 방 설정 바꾸기(이름·공지), 봇이 1:1로 말 걸기(아이 보호를 위해 막아 뒀어요).
봇 서버에서 AI 회사의 API를 부르고, 그 답을 루담톡에 보내면 돼요. 기다리는 동안 "AI가 답을 쓰는 중" 표시가 방에 떠요. AI 회사의 API 열쇠는 봇 서버에만 두세요.
// 자바스크립트 (openai 예시: npm i openai)
const OpenAI = require("openai");
const ai = new OpenAI(); // OPENAI_API_KEY 환경 변수
bot.command("ai", "AI에게 물어봐요", async (ctx) => {
await ctx.typing(true); // AI가 답을 쓰는 중…
const r = await ai.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: ctx.args }],
});
await ctx.reply({ text: r.choices[0].message.content.slice(0, 2000), ai: true });
});
# 파이썬 (Gemini 예시: pip install google-genai)
from google import genai
client = genai.Client() # GEMINI_API_KEY 환경 변수
@bot.command("ai", "AI에게 물어봐요")
async def ask(ctx):
await ctx.typing(ai=True)
r = await client.aio.models.generate_content(model="gemini-2.0-flash", contents=ctx.args)
await ctx.reply(r.text[:2000], ai=True)
typing을 8초마다 다시 불러 주세요.ai: true를 넣어서 사람들이 AI 답인 걸 알 수 있게 해 주세요.봇 메시지는 말풍선 없이 넓게 보여요. 사람 메시지는 그대로 글자만이에요. 글은 2,000자, 임베드는 5개, 임베드 안 칸(fields)은 10개까지예요.
# 큰 제목 ## 중간 제목 ### 작은 제목 -# 작은 회색 글씨 **굵게** *기울임* __밑줄__ ~~취소선~~ ||스포일러|| `코드` ```js 여러 줄 코드 ``` > 인용 >>> 여기서부터 끝까지 인용 - 목록 1. 번호 목록 [글자](https://주소) <t:1794750000:R> → "3시간 후" 루담 추가: ==형광펜== - [ ] 할 일 - [x] 한 일 --- 가로줄
{ "embeds": [{
"title": "오늘의 날씨", "url": "https://…",
"description": "**맑음** · 최고 18°C",
"color": 3900150, // 왼쪽 띠 색 (0xRRGGBB 숫자)
"author": { "name": "날씨봇" },
"fields": [ { "name": "미세먼지", "value": "좋음", "inline": true },
{ "name": "강수", "value": "0%", "inline": true } ],
"thumbnail": { "url": "https://…/sun.png" },
"image": { "url": "https://…/map.png" },
"footer": { "text": "기상청 자료" }
}] }
그림은 루담 서버가 대신 받아서 보여 줘요 (보는 사람의 접속 주소가 그림 사이트에 알려지지 않게). jpg·png·webp·gif, 4MB까지예요. 청소년에게는 그림이 가려져 있다가 눌러야 보여요. [글자](주소) 링크 옆에는 진짜 사이트 이름이 함께 보여요.
대시보드는 개발자의 서버에서 돌아가요. 사용자가 허락하면, 이 봇에서만 쓰는 사용자 번호·프로필 이름과 그 사람이 방장인 방 목록을 알 수 있어요.
1) 사용자를 보내요
https://ludamtalk.com/oauth/authorize?client_id=<봇 번호>
&redirect_uri=<개발자 사이트에 적은 주소>&response_type=code
&scope=identify%20rooms&state=<임의 값>
(response_type=code 와 state 는 꼭 넣어야 해요)
2) 허락하면 → redirect_uri?code=…&state=… (code는 5분, 한 번만)
3) 내 서버에서 바꿔요
POST https://api.ludamtalk.com/oauth/token
grant_type=authorization_code&code=…&redirect_uri=…
&client_id=<봇 번호>&client_secret=<클라이언트 비밀값>
(폼 글·JSON 둘 다 돼요. client_id·client_secret 은 Authorization: Basic 으로 보내도 돼요)
→ { "access_token": "lda_…", "token_type": "Bearer", "expires_in": 3600, "scope": "identify rooms" }
4) GET https://api.ludamtalk.com/oauth/me → { id: "a…(16자리)", name }
GET https://api.ludamtalk.com/oauth/rooms → { rooms: [{ id: "r…", title, n, installed, full }] }
/oauth/me의 id(a+16자리)는 로그인용 번호라서 이벤트의 user.id(u…, 방마다 다름)와 달라요. name은 그 사람의 루담톡 프로필 이름이에요. /oauth/rooms의 id는 이벤트의 room.id와 같아요. full은 봇이 5개라 더 못 넣는 방이에요.code_challenge=<code_verifier의 SHA-256을 base64url로>&code_challenge_method=S256을 붙이고, 3)에 code_verifier=<처음 만든 임의 글자 43~128자>를 보내요. 개발용 http://localhost 주소는 PKCE가 꼭 있어야 해요.401 invalid_token). 다시 로그인하게 안내해 주세요.웹훅 주소를 적으면, 게이트웨이가 연결돼 있지 않을 때 같은 이벤트를 POST로 보내요. 5초 안에 { "text": "…", "embeds": [] }로 바로 대답할 수 있어요.
// 서명 확인 (Node.js)
const crypto = require("crypto");
function fromLudam(req, rawBody, secret) {
const ts = req.headers["x-ludam-timestamp"];
const sig = req.headers["x-ludam-signature"] || "";
if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
const want = "v1=" + crypto.createHmac("sha256", secret)
.update(ts + "." + rawBody).digest("hex");
const a = Buffer.from(sig), b = Buffer.from(want);
// 글자 수가 아니라 바이트 수로 비교해요 (한글 등이 섞이면 길이가 달라요)
return a.byteLength === b.byteLength && crypto.timingSafeEqual(a, b);
}궁금한 점은 help@ludamtalk.com로 보내 주세요.