Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve #611 - migrate to twitter v2 #612

Closed
wants to merge 1 commit into from
Closed

Conversation

cma2819
Copy link
Member

@cma2819 cma2819 commented Dec 21, 2022

issue

bundleConfig

Twitter API v2 プロジェクトの Bearer トークンを使うように変更しました

extensions

Filtered stream のルールは以下のようにしてます

(word1 OR word2 OR word3) -is:retweet -is:reply -is:quote

その上で、一応 extensions 内でRT・リプライ・引用をフィルタするようにしています

ややこしいんですが、filtered stream の仕様でフィルタルールの状態を Twitter API が保持するので、extensions 起動ごとに削除→新規追加をしてます

	// Reset rules
	const rules = await twitterApi.v2.streamRules();

	const ruleIds = rules.data
		?.map((rule) => rule.id)
		?.filter((id): id is string => {
			return !!id;
		});

	if (ruleIds) {
		await twitterApi.v2.updateStreamRules({
			delete: {
				ids: ruleIds,
			},
		});
	}

	const resultRules = await twitterApi.v2.updateStreamRules({
		add: [
			{
				value: `(${twitterConfig.targetWords.join(
					" OR ",
				)}) -is:retweet -is:reply -is:quote`,
			},
		],
	});

@pasta04
Copy link
Contributor

pasta04 commented May 5, 2023

@pasta04 pasta04 closed this May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants