@@ -3,11 +3,12 @@ import { SlackClientProvider } from "../providers/slack-client.provider";
3
3
import { AttachmentManager } from "../attachments" ;
4
4
import { SlackConfig } from "../types/slack-types" ;
5
5
import path from "path" ;
6
+ import { elizaLogger } from "@elizaos/core" ;
6
7
7
8
// Load environment variables
8
9
config ( { path : path . resolve ( __dirname , "../../../.env" ) } ) ;
9
10
10
- console . log ( "\n=== Starting Slack Attachment Example ===\n" ) ;
11
+ elizaLogger . log ( "\n=== Starting Slack Attachment Example ===\n" ) ;
11
12
12
13
// Load environment variables
13
14
const slackConfig : SlackConfig = {
@@ -20,35 +21,35 @@ const slackConfig: SlackConfig = {
20
21
botId : process . env . SLACK_BOT_ID || "" ,
21
22
} ;
22
23
23
- console . log ( "Environment variables loaded:" ) ;
24
+ elizaLogger . log ( "Environment variables loaded:" ) ;
24
25
Object . entries ( slackConfig ) . forEach ( ( [ key , value ] ) => {
25
26
if ( value ) {
26
- console . log ( `${ key } : ${ value . slice ( 0 , 4 ) } ...${ value . slice ( - 4 ) } ` ) ;
27
+ elizaLogger . log ( `${ key } : ${ value . slice ( 0 , 4 ) } ...${ value . slice ( - 4 ) } ` ) ;
27
28
} else {
28
29
console . error ( `Missing ${ key } ` ) ;
29
30
}
30
31
} ) ;
31
32
32
33
async function runExample ( ) {
33
34
try {
34
- console . log ( "\nInitializing Slack client..." ) ;
35
+ elizaLogger . log ( "\nInitializing Slack client..." ) ;
35
36
const provider = new SlackClientProvider ( slackConfig ) ;
36
37
const client = provider . getContext ( ) . client ;
37
38
38
- console . log ( "\nValidating Slack connection..." ) ;
39
+ elizaLogger . log ( "\nValidating Slack connection..." ) ;
39
40
const isValid = await provider . validateConnection ( ) ;
40
41
if ( ! isValid ) {
41
42
throw new Error ( "Failed to validate Slack connection" ) ;
42
43
}
43
- console . log ( "✓ Successfully connected to Slack" ) ;
44
+ elizaLogger . log ( "✓ Successfully connected to Slack" ) ;
44
45
45
46
// Test file upload
46
47
const channelId = process . env . SLACK_CHANNEL_ID ;
47
48
if ( ! channelId ) {
48
49
throw new Error ( "SLACK_CHANNEL_ID is required" ) ;
49
50
}
50
51
51
- console . log ( "\nSending test message with attachment..." ) ;
52
+ elizaLogger . log ( "\nSending test message with attachment..." ) ;
52
53
const testMessage = "Here is a test message with an attachment" ;
53
54
54
55
// Create a test file
@@ -71,7 +72,7 @@ async function runExample() {
71
72
initial_comment : testMessage ,
72
73
} ) ;
73
74
74
- console . log ( "✓ File uploaded successfully" ) ;
75
+ elizaLogger . log ( "✓ File uploaded successfully" ) ;
75
76
76
77
// Initialize AttachmentManager
77
78
const runtime = {
@@ -83,7 +84,7 @@ async function runExample() {
83
84
84
85
// Process the uploaded file
85
86
if ( fileUpload . file ) {
86
- console . log ( "\nProcessing attachment..." ) ;
87
+ elizaLogger . log ( "\nProcessing attachment..." ) ;
87
88
const processedAttachment =
88
89
await attachmentManager . processAttachment ( {
89
90
id : fileUpload . file . id ,
@@ -94,19 +95,19 @@ async function runExample() {
94
95
title : fileUpload . file . title || "" ,
95
96
} ) ;
96
97
97
- console . log ( "✓ Attachment processed:" , processedAttachment ) ;
98
+ elizaLogger . log ( "✓ Attachment processed:" , processedAttachment ) ;
98
99
}
99
100
100
101
// Cleanup
101
102
fs . unlinkSync ( testFilePath ) ;
102
- console . log ( "\n✓ Test completed successfully" ) ;
103
+ elizaLogger . log ( "\n✓ Test completed successfully" ) ;
103
104
} catch ( error ) {
104
105
console . error ( "Error:" , error ) ;
105
106
process . exit ( 1 ) ;
106
107
}
107
108
}
108
109
109
110
runExample ( ) . then ( ( ) => {
110
- console . log ( "\n=== Example completed ===\n" ) ;
111
+ elizaLogger . log ( "\n=== Example completed ===\n" ) ;
111
112
process . exit ( 0 ) ;
112
113
} ) ;
0 commit comments