adityajat/SaarvamAI_botPublic · Bot Template

ProfileTelegram

AISarvam AI is a multi‑purpose Telegram bot that lets users ask questions, get explanations, convert text to speech, and translate messages using the Sarvam AI API. It also offers group administration commands such as warn, mute, ban, pin, delete, and announcements, and can clear personal or group AI memory. The bot uses the TeleBotHost TBL framework with Bot, Api, db, and HTTP calls, and provides inline keyboards for language and voice selection.

Ai Assistantaivoicetranslatemoderationadminsarvam
34 commands4 envUpdated 15d agoCreated Sep 14, 2026
Back to folder

commands/_clearmemory.js

javascript · 56 lines

Raw
1/**#command2name: /clearmemory3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12try {13  // This command is for groups only.14  if (15    chat.type !== "group" &&16    chat.type !== "supergroup"17  ) {18    await Api.sendMessage({19      text: "⛔ This command works only in groups."20    });21    return;22  }23 24  let chatId = String(chat.id);25 26  // Clear the history used by /handle_message.27  await db.user.set(28    "sarvam_history_" + chatId,29    []30  );31 32  // Clear the older group-memory key, too.33  await db.bot.set(34    "ai_history:" + chatId,35    []36  );37 38  await Api.sendMessage({39    text: "🧹 This group's AI conversation history has been cleared."40  });41 42  return;43 44} catch (error) {45  console.log("CLEARMEMORY ERROR:", error);46 47  await Api.sendMessage({48    text:49      "⚠️ Failed to clear group memory: " +50      (error && error.message51        ? error.message52        : String(error))53  });54 55  return;56}