TAWNY BOTLARI
Sunucunu botlarla güçlendir
Moderasyon, mini oyunlar, hatırlatıcılar ve daha fazlası. Topluluğun geliştirdiği botları keşfet, tek tıkla sunucuna ekle — ya da kendi botunu birkaç dakikada yaz.
Popüler botlar
Basit REST API
Tek bir token ile kullanıcı, sunucu, kanal ve mesaj uç noktaları. Her dilde HTTP isteğiyle çalışır.
Olay akışı
Mesajlar, yeni üyeler ve tepkiler uzun yoklamalı gateway ile anında botuna ulaşır.
İzin kontrollü
Bot yalnız sunucu yöneticisinin verdiği izinlerle çalışır; tokenlar yalnız özet olarak saklanır.
İlk botunu 5 dakikada yaz
Geliştirici portalında bir uygulama oluştur, tokenını al ve aşağıdaki örneği çalıştır. Botun "!ping" yazana "Pong!" diye cevap verir.
// Node.js 18+ (yerleşik fetch) — npm paketi gerekmez
const TOKEN = process.env.TAWNY_TOKEN;
const API = 'https://tawny.com.tr/api/v1';
const headers = { Authorization: 'Bot ' + TOKEN, 'Content-Type': 'application/json' };
async function main() {
let cursor = '';
for (;;) {
const res = await fetch(API + '/gateway/events?wait=25&cursor=' + cursor, { headers });
const data = await res.json();
cursor = data.cursor;
for (const ev of data.events) {
if (ev.type !== 'MESSAGE_CREATE' || ev.data.author.bot) continue;
if (ev.data.content === '!ping') {
await fetch(API + '/channels/' + ev.data.channel_id + '/messages', {
method: 'POST', headers,
body: JSON.stringify({ content: 'Pong! 🏓' }),
});
}
}
}
}
main();# Python 3.8+ — pip install requests
import os, requests
API = "https://tawny.com.tr/api/v1"
H = {"Authorization": "Bot " + os.environ["TAWNY_TOKEN"]}
cursor = ""
while True:
r = requests.get(API + "/gateway/events", params={"wait": 25, "cursor": cursor}, headers=H, timeout=40).json()
cursor = r["cursor"]
for ev in r["events"]:
msg = ev["data"]
if ev["type"] == "MESSAGE_CREATE" and not msg["author"]["bot"] and msg["content"] == "!ping":
requests.post(API + "/channels/" + str(msg["channel_id"]) + "/messages",
json={"content": "Pong! 🏓"}, headers=H)