Update agent.py
Browse files
agent.py
CHANGED
|
@@ -242,6 +242,37 @@ class Permission:
|
|
| 242 |
if not u:
|
| 243 |
return False
|
| 244 |
return bool(u["is_banned"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
|
| 246 |
# ================================================================
|
| 247 |
# LLM SERVICE (all providers + curl for custom)
|
|
|
|
| 242 |
if not u:
|
| 243 |
return False
|
| 244 |
return bool(u["is_banned"])
|
| 245 |
+
|
| 246 |
+
class SupabaseDB:
|
| 247 |
+
_client = None
|
| 248 |
+
|
| 249 |
+
@classmethod
|
| 250 |
+
def get(cls):
|
| 251 |
+
if not cls._client and Config.has_supabase():
|
| 252 |
+
try:
|
| 253 |
+
from supabase import create_client
|
| 254 |
+
cls._client = create_client(Config.SUPABASE_URL, Config.SUPABASE_KEY)
|
| 255 |
+
except:
|
| 256 |
+
pass
|
| 257 |
+
return cls._client
|
| 258 |
+
|
| 259 |
+
@classmethod
|
| 260 |
+
async def get_buttons(cls):
|
| 261 |
+
c = cls.get()
|
| 262 |
+
if not c: return []
|
| 263 |
+
try:
|
| 264 |
+
r = await asyncio.to_thread(lambda: c.table("bot_buttons").select("*").execute())
|
| 265 |
+
return r.data
|
| 266 |
+
except: return []
|
| 267 |
+
|
| 268 |
+
@classmethod
|
| 269 |
+
async def add_button(cls, label, url):
|
| 270 |
+
c = cls.get()
|
| 271 |
+
if not c: return False
|
| 272 |
+
try:
|
| 273 |
+
await asyncio.to_thread(lambda: c.table("bot_buttons").insert({"label": label, "url": url}).execute())
|
| 274 |
+
return True
|
| 275 |
+
except: return False
|
| 276 |
|
| 277 |
# ================================================================
|
| 278 |
# LLM SERVICE (all providers + curl for custom)
|