import { Plugin, Action, Provider, Service, EventType } from "@elizaos/core";
export const twitterPlugin: Plugin = {
name: "@elizaos/plugin-twitter",
description: "Twitter integration for social media interactions",
init: async (config, runtime) => {
const apiKey = runtime.getSetting("TWITTER_API_KEY");
if (!apiKey) {
throw new Error("TWITTER_API_KEY required");
}
runtime.logger.success("Twitter plugin initialized");
},
actions: [
{
name: "SEND_TWEET",
description: "Post a tweet to Twitter",
handler: async (runtime, message, state, options) => {
const text = options?.parameters?.text as string;
return { success: true, text: `Tweet posted: ${text}` };
},
validate: async () => true,
parameters: [
{
name: "text",
description: "Tweet content",
required: true,
schema: { type: "string", maxLength: 280 }
}
]
}
],
providers: [
{
name: "TWITTER_PROFILE",
get: async (runtime, message, state) => {
return {
text: "Twitter profile data",
values: { username: "agent" }
};
}
}
],
services: [TwitterService],
events: {
[EventType.MESSAGE_SENT]: [
async (payload) => {
console.log("Message sent to Twitter");
}
]
},
dependencies: ["@elizaos/plugin-node"]
};