@elizaos/plugin-twitter 1.0.0-beta.34 → 1.0.0-beta.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2914,6 +2914,41 @@ async function fetchListTweets(listId, maxTweets, cursor, auth) {
|
|
|
2914
2914
|
}
|
|
2915
2915
|
return parseListTimelineTweets(res.value);
|
|
2916
2916
|
}
|
|
2917
|
+
async function deleteTweet(tweetId, auth) {
|
|
2918
|
+
const onboardingTaskUrl = "https://api.twitter.com/1.1/onboarding/task.json";
|
|
2919
|
+
const cookies = await auth.cookieJar().getCookies(onboardingTaskUrl);
|
|
2920
|
+
const xCsrfToken = cookies.find((cookie) => cookie.key === "ct0");
|
|
2921
|
+
const headers = new Headers({
|
|
2922
|
+
authorization: `Bearer ${auth.bearerToken}`,
|
|
2923
|
+
cookie: await auth.cookieJar().getCookieString(onboardingTaskUrl),
|
|
2924
|
+
"content-type": "application/json",
|
|
2925
|
+
"User-Agent": "Mozilla/5.0 (Linux; Android 11; Nokia G20) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.88 Mobile Safari/537.36",
|
|
2926
|
+
"x-guest-token": auth.guestToken,
|
|
2927
|
+
"x-twitter-auth-type": "OAuth2Client",
|
|
2928
|
+
"x-twitter-active-user": "yes",
|
|
2929
|
+
"x-csrf-token": xCsrfToken?.value
|
|
2930
|
+
});
|
|
2931
|
+
const variables = {
|
|
2932
|
+
tweet_id: tweetId,
|
|
2933
|
+
dark_request: false
|
|
2934
|
+
};
|
|
2935
|
+
const response = await fetch(
|
|
2936
|
+
"https://twitter.com/i/api/graphql/VaenaVgh5q5ih7kvyVjgtg/DeleteTweet",
|
|
2937
|
+
{
|
|
2938
|
+
headers,
|
|
2939
|
+
body: JSON.stringify({
|
|
2940
|
+
variables,
|
|
2941
|
+
queryId: "VaenaVgh5q5ih7kvyVjgtg"
|
|
2942
|
+
}),
|
|
2943
|
+
method: "POST"
|
|
2944
|
+
}
|
|
2945
|
+
);
|
|
2946
|
+
await updateCookieJar(auth.cookieJar(), response.headers);
|
|
2947
|
+
if (!response.ok) {
|
|
2948
|
+
throw new Error(await response.text());
|
|
2949
|
+
}
|
|
2950
|
+
return response;
|
|
2951
|
+
}
|
|
2917
2952
|
function getTweets(user, maxTweets, auth) {
|
|
2918
2953
|
return getTweetTimeline(user, maxTweets, async (q, mt, c) => {
|
|
2919
2954
|
const userIdRes = await getEntityIdByScreenName(q, auth);
|
|
@@ -4026,6 +4061,14 @@ var Client = class {
|
|
|
4026
4061
|
async sendQuoteTweet(text, quotedTweetId, options) {
|
|
4027
4062
|
return await createQuoteTweetRequest(text, quotedTweetId, this.auth, options?.mediaData);
|
|
4028
4063
|
}
|
|
4064
|
+
/**
|
|
4065
|
+
* Delete a tweet with the given ID.
|
|
4066
|
+
* @param tweetId The ID of the tweet to delete.
|
|
4067
|
+
* @returns A promise that resolves when the tweet is deleted.
|
|
4068
|
+
*/
|
|
4069
|
+
async deleteTweet(tweetId) {
|
|
4070
|
+
return await deleteTweet(tweetId, this.auth);
|
|
4071
|
+
}
|
|
4029
4072
|
/**
|
|
4030
4073
|
* Likes a tweet with the given tweet ID.
|
|
4031
4074
|
* @param tweetId The ID of the tweet to like.
|