Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export const MESSAGE_CONSTANTS = {
PARTIAL_INTEREST_DECAY: 3 * 60 * 1000, // 3 minutes
} as const;

export const TELEGRAM_SERVICE_NAME = 'telegram';
export const TELEGRAM_SERVICE_NAME = "telegram";
19 changes: 11 additions & 8 deletions src/environment.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { IAgentRuntime } from '@elizaos/core';
import { z } from 'zod';
import type { IAgentRuntime } from "@elizaos/core";
import { z } from "zod";

export const telegramEnvSchema = z.object({
TELEGRAM_BOT_TOKEN: z.string().min(1, 'Telegram bot token is required'),
TELEGRAM_BOT_TOKEN: z.string().min(1, "Telegram bot token is required"),
});

/**
Expand All @@ -18,21 +18,24 @@ export type TelegramConfig = z.infer<typeof telegramEnvSchema>;
* @returns {Promise<TelegramConfig | null>} A promise that resolves with the validated Telegram configuration or null if invalid.
*/
export async function validateTelegramConfig(
runtime: IAgentRuntime
runtime: IAgentRuntime,
): Promise<TelegramConfig | null> {
try {
const config = {
TELEGRAM_BOT_TOKEN:
runtime.getSetting('TELEGRAM_BOT_TOKEN') || process.env.TELEGRAM_BOT_TOKEN,
runtime.getSetting("TELEGRAM_BOT_TOKEN") ||
process.env.TELEGRAM_BOT_TOKEN,
};

return telegramEnvSchema.parse(config);
} catch (error) {
if (error instanceof z.ZodError) {
const errorMessages = error.issues
.map((err) => `${err.path.join('.')}: ${err.message}`)
.join('\n');
console.warn(`Telegram configuration validation failed:\n${errorMessages}`);
.map((err) => `${err.path.join(".")}: ${err.message}`)
.join("\n");
console.warn(
`Telegram configuration validation failed:\n${errorMessages}`,
);
}
return null;
}
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { Plugin } from '@elizaos/core';
import { TELEGRAM_SERVICE_NAME } from './constants';
import { TelegramService } from './service';
import { TelegramTestSuite } from './tests';
import { MessageManager } from './messageManager';
import type { Plugin } from "@elizaos/core";
import { TELEGRAM_SERVICE_NAME } from "./constants";
import { TelegramService } from "./service";
import { TelegramTestSuite } from "./tests";
import { MessageManager } from "./messageManager";

const telegramPlugin: Plugin = {
name: TELEGRAM_SERVICE_NAME,
description: 'Telegram client plugin',
description: "Telegram client plugin",
services: [TelegramService],
tests: [new TelegramTestSuite()],
};
Comment on lines 7 to 12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify the GIF animation fix is present in messageManager.ts

Confirm explicit GIF routing and the async loop refactor claimed in the PR.

Run:


🏁 Script executed:

#!/bin/bash
# Expect explicit use of replyWithAnimation for GIFs
rg -nP 'replyWithAnimation\s*\(' src/messageManager.ts -C3 || true

# Ensure generic image matcher excludes .gif or contentType image/gif
rg -nP 'gif' src/messageManager.ts -n -C2 || true

# Ensure old prefix-based typeMap removed
rg -nP 'typeMap' src/messageManager.ts -n -C2 || true

# Ensure for-await replaces .map(async)
rg -nP '\.map\s*\(\s*async' src/messageManager.ts -n -C2 || true
rg -nP 'for\s+await\s*\(' src/messageManager.ts -n -C2 || true

Length of output: 1776


GIF routing confirmed; async loop refactor incomplete

The explicit replyWithAnimation usage (line 478) and proper GIF type detection (line 431) are in place. However, the async loop refactor is incomplete: the legacy typeMap fallback (lines 523–535) still exists and hasn't been replaced with for-await. No for-await loop was found in the file. Either complete the refactor by removing the typeMap fallback, or clarify if the fallback is intentional and document why it's retained.

🤖 Prompt for AI Agents
In src/index.ts around lines 431–535, the async loop refactor is incomplete
because the legacy typeMap fallback (lines ~523–535) remains instead of using a
for-await loop; remove the legacy typeMap fallback and replace it with a single
async iterator loop (for await (...) { ... }) that yields the same routing
behavior and preserves the GIF detection and replyWithAnimation behavior already
implemented (ensure you await async handlers, propagate errors appropriately,
and maintain any type checks previously provided by typeMap), or if you
intentionally keep the fallback, add a clear code comment above the fallback
explaining why the legacy path is required and add a unit/integration test
asserting the fallback path is exercised.

Expand Down
Loading