twitter_channel
diapason.channels.twitter_channel
¶
TwitterChannel — Twitter/X API v2 adapter using OAuth 1.0a.
TwitterChannel
¶
Bases: BaseChannel
Native Twitter/X channel adapter using the v2 API.
Parameters¶
bearer_token:
Bearer token for read endpoints. Falls back to
TWITTER_BEARER_TOKEN env var.
api_key / api_secret:
OAuth 1.0a consumer credentials. Fall back to
TWITTER_API_KEY / TWITTER_API_SECRET.
access_token / access_secret:
OAuth 1.0a user credentials. Fall back to
TWITTER_ACCESS_TOKEN / TWITTER_ACCESS_SECRET.
bot_user_id:
Numeric Twitter user ID for the bot account. Falls back to
TWITTER_BOT_USER_ID.
poll_interval:
Seconds between mention polls (default 60).
bus:
Optional event bus for publishing channel events.
connect()
¶
Validate credentials and start mention polling.
disconnect()
¶
Stop the polling thread.
list_channels()
¶
Return available channel identifiers.
on_message(handler)
¶
Register a callback for incoming mentions.
send(channel, content, *, conversation_id='', metadata=None)
¶
Post a tweet, optionally as a reply.
channel is ignored (tweets go to the bot's timeline).
conversation_id is used as reply.in_reply_to_tweet_id when set.
Content is truncated to 280 characters.
status()
¶
Return the current connection status.