Skip to content

Commit adec4a6

Browse files
authored
Merge pull request #3 from elizaos-plugins/fix/tg-build-issue
2 parents 713be7f + 9d62949 commit adec4a6

5 files changed

Lines changed: 25 additions & 14 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
dist
2-
node_modules
2+
node_modules
3+
.turbo

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@elizaos/plugin-telegram",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"type": "module",
55
"main": "dist/index.js",
66
"module": "dist/index.js",

src/service.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
logger,
1818
} from '@elizaos/core';
1919
import { type Context, Telegraf } from 'telegraf';
20-
import { type ChatMemberOwner, type ChatMemberAdministrator } from 'telegraf/types';
20+
import { type ChatMemberOwner, type ChatMemberAdministrator, type User } from 'telegraf/types';
2121
import { TELEGRAM_SERVICE_NAME } from './constants';
2222
import { validateTelegramConfig } from './environment';
2323
import { MessageManager } from './messageManager';
@@ -477,7 +477,7 @@ export class TelegramService extends Service {
477477
/**
478478
* Builds entity for message sender
479479
*/
480-
private buildMsgSenderEntity(from: any): Entity | null {
480+
private buildMsgSenderEntity(from: User): Entity | null {
481481
if (!from) return null;
482482

483483
const userId = createUniqueUuid(this.runtime, from.id.toString()) as UUID;
@@ -679,12 +679,20 @@ export class TelegramService extends Service {
679679
entityBatch.map(async (entity: Entity) => {
680680
try {
681681
if (entity.id) {
682+
const telegramMetadata = entity.metadata?.telegram as
683+
| {
684+
username?: string;
685+
name?: string;
686+
id?: string;
687+
}
688+
| undefined;
689+
682690
await this.runtime.ensureConnection({
683691
entityId: entity.id,
684692
roomId: roomId,
685-
userName: entity.metadata?.telegram?.username,
686-
name: entity.metadata?.telegram?.name,
687-
userId: entity.metadata?.telegram?.id,
693+
userName: telegramMetadata?.username,
694+
name: telegramMetadata?.name,
695+
userId: telegramMetadata?.id as UUID,
688696
source: 'telegram',
689697
channelId: channelId,
690698
serverId: serverId,
@@ -697,7 +705,12 @@ export class TelegramService extends Service {
697705
);
698706
}
699707
} catch (err) {
700-
logger.warn(`Failed to sync user ${entity.metadata?.telegram?.username}: ${err}`);
708+
const telegramMetadata = entity.metadata?.telegram as
709+
| {
710+
username?: string;
711+
}
712+
| undefined;
713+
logger.warn(`Failed to sync user ${telegramMetadata?.username}: ${err}`);
701714
}
702715
})
703716
);

tsconfig.build.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"sourceMap": true,
77
"inlineSources": true,
88
"declaration": true,
9-
"emitDeclarationOnly": true
9+
"emitDeclarationOnly": true,
10+
"paths": {}
1011
},
1112
"include": ["src/**/*.ts"],
1213
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]

tsconfig.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@
2020
"noEmitOnError": false,
2121
"moduleDetection": "force",
2222
"allowArbitraryExtensions": true,
23-
"baseUrl": ".",
24-
"paths": {
25-
"@elizaos/core": ["../../core/src"],
26-
"@elizaos/core/*": ["../../core/src/*"]
27-
}
23+
"baseUrl": "."
2824
},
2925
"include": ["src/**/*.ts"]
3026
}

0 commit comments

Comments
 (0)