feat: Add slash command help system (#57) #62

Merged
shoko merged 18 commits from fix/issue-57 into main 2026-04-14 04:03:29 +02:00
Showing only changes of commit 62bcd6e099 - Show all commits

View File

@@ -985,24 +985,27 @@ class ConversationalAgent:
} }
def _execute_price(self, token_ids: str) -> Dict[str, Any]: def _execute_price(self, token_ids: str) -> Dict[str, Any]:
"""Execute price lookup for the given token IDs.""" """Execute price lookup for the given token IDs or symbols."""
try: try:
tokens_list = token_ids.replace(",", " ").split() tokens_list = token_ids.replace(",", " ").split()
if not tokens_list: if not tokens_list:
return { return {
"response": "No token IDs provided. Please provide token IDs like 'PEPE-bsc TRUMP-bsc'", "response": "No token provided. Please provide a token name, symbol, or address like 'PEPE', 'TRUMP', or '0x...'",
"thinking": None, "thinking": None,
"strategy_updated": False, "strategy_updated": False,
"strategy_needs_confirmation": False, "strategy_needs_confirmation": False,
"success": True, "success": True,
} }
# Use search to find tokens and get their prices
# Search for the first token
search_keyword = tokens_list[0]
code, output = self._call_ave_script( code, output = self._call_ave_script(
"price", "search",
["--tokens"] + tokens_list, ["--keyword", search_keyword.strip(), "--chain", "bsc", "--limit", "5"],
) )
if self._is_error_output(code, output): if self._is_error_output(code, output):
return { return {
"response": f"Failed to get prices: {output}", "response": f"Failed to search for token: {output}",
"thinking": None, "thinking": None,
"strategy_updated": False, "strategy_updated": False,
"strategy_needs_confirmation": False, "strategy_needs_confirmation": False,
@@ -1010,15 +1013,30 @@ class ConversationalAgent:
} }
try: try:
data = json.loads(output) data = json.loads(output)
prices = data.get("data", {}) # Handle both dict with 'tokens' key and direct list
if not isinstance(prices, dict): data_field = data.get("data", [])
prices = {} if isinstance(data_field, list):
if prices: tokens = data_field
else:
tokens = data_field.get("tokens", [])
if tokens:
price_text = "💰 **Token Prices:**\n" price_text = "💰 **Token Prices:**\n"
for token_id, price_data in prices.items(): for t in tokens[:5]:
price = price_data.get("price", "N/A") if isinstance(price_data, dict) else "N/A" addr = t.get("token", "")
change_24h = price_data.get("token_price_change_24h", "N/A") if isinstance(price_data, dict) else "N/A" symbol = t.get("symbol", "")
price_text += f"- {token_id}: ${price} (24h: {change_24h}%)\n" name = t.get("name", "")
price = t.get("current_price_usd") or t.get("price", "N/A")
change_24h = t.get("token_price_change_24h", "N/A") or t.get("price_change_24h", "N/A")
mc = t.get("market_cap", "N/A")
try:
price_str = f"${float(price):,.6f}" if price and price != "N/A" else price
except (ValueError, TypeError):
price_str = str(price) if price else "N/A"
try:
mc_str = f"${float(mc):,.0f}" if mc and mc != "N/A" else mc
except (ValueError, TypeError):
mc_str = str(mc) if mc else "N/A"
price_text += f"- **{symbol}** ({name}): {price_str} (MC: {mc_str})\n"
return { return {
"response": price_text, "response": price_text,
"thinking": None, "thinking": None,