-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
78 lines (55 loc) · 2.98 KB
/
example.py
File metadata and controls
78 lines (55 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""
example.py — topluyo_bot kütüphanesi kullanım örneği
"""
from topluyobot import TopluyoBOT, BotMessage
bot = TopluyoBOT("BURAYA_TOKEN")
@bot.on("connected")
def on_connected():
print("✅ Bota bağlandı!")
@bot.on("close")
def on_close():
print("🔌 Bağlantı kapandı, yeniden bağlanılıyor...")
@bot.on("auth_problem")
def on_auth_problem():
print("❌ Token geçersiz! Lütfen token'ı kontrol edin.")
@bot.on("error")
def on_error(err):
print(f"⚠️ Hata: {err}")
@bot.on("message")
def on_message(data: BotMessage):
action = data.get("action")
# ── Direkt mesaj ──────────────────────────────────────────────────
if action == "message/send":
user_id = data["user_id"]
text = data["message"]
print(f"[DM] kullanıcı {user_id}: {text}")
# Örnek yanıt (senkron POST)
bot.post_sync("messages.send", {
"user_id": user_id,
"message": f"Merhaba! Şunu yazdın: {text}"
})
# ── Kanal postu ───────────────────────────────────────────────────
elif action == "post/add":
print(f"[POST] kanal {data['channel_id']} | kullanıcı {data['user_id']}: {data['message']}")
# ── Bot mention ───────────────────────────────────────────────────
elif action == "post/mention":
print(f"[MENTION] {data['user_id']} seni mention etti: {data['message']}")
# ── Bumote formu ──────────────────────────────────────────────────
elif action == "post/bumote":
form = data["message"]["form"]
submit = data["message"]["submit"]
print(f"[BUMOTE] form: {form} | submit: {submit}")
# ── Grup olayları ─────────────────────────────────────────────────
elif action == "group/join":
print(f"[GROUP] kullanıcı {data['user_id']} gruba katıldı: {data['group_id']}")
elif action == "group/leave":
print(f"[GROUP] kullanıcı {data['user_id']} gruptan ayrıldı: {data['group_id']}")
elif action == "group/kick":
print(f"[GROUP] kullanıcı {data['user_id']} gruptan atıldı: {data['group_id']}")
# ── Turbo transferi ───────────────────────────────────────────────
elif action == "turbo/transfer":
qty = data["message"]["quantity"]
note = data["message"]["message"]
print(f"[TURBO] {data['user_id']} → {qty} turbo gönderdi. Not: {note}")
# Botu başlat (bloklayıcı)
bot.run()