Skip to content

Twitter Search Client Broken #943

Closed
Closed
@owenwahlgren

Description

Describe the bug
The TwitterSearchClient comes broken out of box

Error engaging with search terms: TypeError: Cannot read properties of undefined (reading 'id')
    at TwitterSearchClient.fetchHomeTimeline (file:///Users/owen.wahlgren/code/eliza/packages/client-twitter/dist/index.js:337:82)
    at TwitterSearchClient.engageWithSearchTerms (file:///Users/owen.wahlgren/code/eliza/packages/client-twitter/dist/index.js:812:45)

To Reproduce
Clone most recent release
Build character.json with twitter in character files clients array.

 "clients": [
    "twitter",
    "telegram"
  ],

Update packages/client-twitter/src/index.ts to include search functionality

import { TwitterPostClient } from "./post.ts";
import { TwitterSearchClient } from "./search.ts";
import { TwitterInteractionClient } from "./interactions.ts";
import { IAgentRuntime, Client, elizaLogger } from "@ai16z/eliza";
import { validateTwitterConfig } from "./environment.ts";
import { ClientBase } from "./base.ts";

class TwitterManager {
    client: ClientBase;
    post: TwitterPostClient;
    search: TwitterSearchClient;
    interaction: TwitterInteractionClient;
    constructor(runtime: IAgentRuntime) {
        this.client = new ClientBase(runtime);
        this.post = new TwitterPostClient(this.client, runtime);
        this.search = new TwitterSearchClient(runtime); // don't start the search client by default (ADDED THIS)
        // this searches topics from character file, but kind of violates consent of random users
        // burns your rate limit and can get your account banned
        // use at your own risk
        this.interaction = new TwitterInteractionClient(this.client, runtime);
    }
}

export const TwitterClientInterface: Client = {
    async start(runtime: IAgentRuntime) {
        await validateTwitterConfig(runtime);

        elizaLogger.log("Twitter client started");

        const manager = new TwitterManager(runtime);

        await manager.client.init();

        await manager.post.start();

        await manager.interaction.start();

        await manager.search.onReady(); // (ADDED THIS)

        return manager;
    },
    async stop(_runtime: IAgentRuntime) {
        elizaLogger.warn("Twitter client does not support stopping yet");
    },
};

export default TwitterClientInterface;

Build and start project:

pnpm build
pnpm start

Expected behavior

Should engage in searched timeline activity outside of just mentions

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions