@@ -155,11 +155,18 @@ async function genereateMeme(
155
155
imgflipTemplate : ImgflipTemplate ,
156
156
captions : string [ ]
157
157
) : Promise < string > {
158
+ const username = process . env . IMGFLIP_USERNAME ;
159
+ const password = process . env . IMGFLIP_PASSWORD ;
160
+
161
+ if ( ! username || ! password ) {
162
+ throw new Error ( "Imgflip credentials not configured. Please set IMGFLIP_USERNAME and IMGFLIP_PASSWORD environment variables." ) ;
163
+ }
164
+
158
165
// Create form data with template ID and credentials
159
166
const formData = new URLSearchParams ( {
160
167
template_id : imgflipTemplate . id ,
161
- username : process . env . IMGFLIP_USERNAME ! ,
162
- password : process . env . IMGFLIP_PASSWORD ! ,
168
+ username,
169
+ password,
163
170
} ) ;
164
171
165
172
// Add each caption as text0, text1, etc.
@@ -180,7 +187,7 @@ async function genereateMeme(
180
187
const result : ImgflipCaptionResponse = await response . json ( ) ;
181
188
182
189
if ( ! result . success || ! result . data . url ) {
183
- throw new Error ( " Failed to generate meme: " + result . error_message ) ;
190
+ throw new Error ( ` Failed to generate meme: ${ result . error_message } ` ) ;
184
191
}
185
192
186
193
return result . data . url ;
@@ -214,7 +221,11 @@ export async function generateMemeActionHandler(
214
221
) ;
215
222
216
223
const url = await genereateMeme ( imgflipTemplate , captions ) ;
217
- const text = `Generated a meme, using imgflip.com:\nMeme template: "${ template } ".\nCaptions:\n${ captions . join ( "\n" ) } \nMeme URL: ${ url } ` ;
224
+ const text = `Generated a meme, using imgflip.com:
225
+ Meme template: "${ template } ".
226
+ Captions:
227
+ ${ captions . join ( "\n" ) }
228
+ Meme URL: ${ url } ` ;
218
229
219
230
return {
220
231
url,
@@ -226,14 +237,14 @@ export const generateMemeAction: Action = {
226
237
name : "GENERATE_MEME" ,
227
238
similes : [ "MAKE_MEME" , "NEW_MEME" , "GENERATE_NEW_MEME" , "MAKE_NEW_MEME" ] ,
228
239
description : "Use this action to generate a meme" ,
229
- validate : async ( runtime : IAgentRuntime , message : Memory ) => {
240
+ validate : async ( _runtime : IAgentRuntime , _message : Memory ) => {
230
241
return true ;
231
242
} ,
232
243
handler : async (
233
244
runtime : IAgentRuntime ,
234
245
message : Memory ,
235
246
state : State ,
236
- options : any ,
247
+ _options : Record < string , unknown > ,
237
248
callback : HandlerCallback
238
249
) => {
239
250
const meme = await generateMemeActionHandler (
0 commit comments