## Agents Added - Alateya: R&D, biotech, innovations - Clan (Spirit): Community spirit agent - Eonarch: Consciousness evolution agent ## Changes - docker-compose.node1.yml: Added tokens for all 3 new agents - gateway-bot/http_api.py: Added configs and webhook endpoints - gateway-bot/clan_prompt.txt: New prompt file - gateway-bot/eonarch_prompt.txt: New prompt file ## Fixes - Fixed ROUTER_URL from :9102 to :8000 (internal container port) - All 9 Telegram agents now working ## Documentation - Created PROJECT-MASTER-INDEX.md - single entry point - Added various status documents and scripts Tokens configured: - Helion, NUTRA, Agromatrix (existing) - Alateya, Clan, Eonarch (new) - Druid, GreenFood, DAARWIZZ (configured)
40 lines
1.2 KiB
PL/PgSQL
40 lines
1.2 KiB
PL/PgSQL
-- Migration 051: Fix is_mentor function type mismatch
|
|
-- Issue: bigint = text error when comparing telegram_user_id
|
|
|
|
DROP FUNCTION IF EXISTS is_mentor(text, text);
|
|
|
|
CREATE FUNCTION is_mentor(
|
|
p_telegram_user_id TEXT,
|
|
p_telegram_username TEXT
|
|
) RETURNS BOOLEAN AS $$
|
|
DECLARE
|
|
user_id_num BIGINT;
|
|
BEGIN
|
|
-- Safely convert telegram_user_id to bigint if it's numeric
|
|
IF p_telegram_user_id IS NOT NULL AND p_telegram_user_id ~ '^[0-9]+$' THEN
|
|
user_id_num := p_telegram_user_id::BIGINT;
|
|
ELSE
|
|
user_id_num := NULL;
|
|
END IF;
|
|
|
|
RETURN EXISTS (
|
|
SELECT 1 FROM helion_mentors
|
|
WHERE active = true
|
|
AND (
|
|
-- Match by telegram user ID (bigint)
|
|
(user_id_num IS NOT NULL AND telegram_user_id = user_id_num)
|
|
OR
|
|
-- Match by username (with or without @)
|
|
(p_telegram_username IS NOT NULL AND username = p_telegram_username)
|
|
OR
|
|
(p_telegram_username IS NOT NULL AND username = '@' || p_telegram_username)
|
|
)
|
|
);
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|
|
|
|
-- Test the function
|
|
SELECT is_mentor('1642840513', 'ivantytar') as test_by_id;
|
|
SELECT is_mentor(NULL, 'ivantytar') as test_by_username;
|
|
SELECT is_mentor(NULL, 'unknown_user') as test_not_mentor;
|