Skip to content

Commit e9ec7fd

Browse files
AIFlowMLwtfsayo
andauthored
Fixed all the typing issues (elizaOS#2976)
Co-authored-by: Sayo <hi@sayo.wtf>
1 parent ded7d38 commit e9ec7fd

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

packages/plugin-imgflip/src/actions/generate-meme.ts

+17-6
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,18 @@ async function genereateMeme(
155155
imgflipTemplate: ImgflipTemplate,
156156
captions: string[]
157157
): 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+
158165
// Create form data with template ID and credentials
159166
const formData = new URLSearchParams({
160167
template_id: imgflipTemplate.id,
161-
username: process.env.IMGFLIP_USERNAME!,
162-
password: process.env.IMGFLIP_PASSWORD!,
168+
username,
169+
password,
163170
});
164171

165172
// Add each caption as text0, text1, etc.
@@ -180,7 +187,7 @@ async function genereateMeme(
180187
const result: ImgflipCaptionResponse = await response.json();
181188

182189
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}`);
184191
}
185192

186193
return result.data.url;
@@ -214,7 +221,11 @@ export async function generateMemeActionHandler(
214221
);
215222

216223
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}`;
218229

219230
return {
220231
url,
@@ -226,14 +237,14 @@ export const generateMemeAction: Action = {
226237
name: "GENERATE_MEME",
227238
similes: ["MAKE_MEME", "NEW_MEME", "GENERATE_NEW_MEME", "MAKE_NEW_MEME"],
228239
description: "Use this action to generate a meme",
229-
validate: async (runtime: IAgentRuntime, message: Memory) => {
240+
validate: async (_runtime: IAgentRuntime, _message: Memory) => {
230241
return true;
231242
},
232243
handler: async (
233244
runtime: IAgentRuntime,
234245
message: Memory,
235246
state: State,
236-
options: any,
247+
_options: Record<string, unknown>,
237248
callback: HandlerCallback
238249
) => {
239250
const meme = await generateMemeActionHandler(

0 commit comments

Comments
 (0)