twitter_channel
twitter_channel
¶
TwitterChannel — Twitter/X API v2 adapter using OAuth 1.0a.
Classes¶
TwitterChannel
¶
TwitterChannel(
bearer_token: str = "",
*,
api_key: str = "",
api_secret: str = "",
access_token: str = "",
access_secret: str = "",
bot_user_id: str = "",
poll_interval: int = 60,
bus: Optional[EventBus] = None,
)
Bases: BaseChannel
Native Twitter/X channel adapter using the v2 API.
| PARAMETER | DESCRIPTION |
|---|---|
bearer_token
|
Bearer token for read endpoints. Falls back to
TYPE:
|
api_key
|
OAuth 1.0a consumer credentials. Fall back to
TYPE:
|
access_token
|
OAuth 1.0a user credentials. Fall back to
TYPE:
|
bot_user_id
|
Numeric Twitter user ID for the bot account. Falls back to
TYPE:
|
poll_interval
|
Seconds between mention polls (default 60).
TYPE:
|
bus
|
Optional event bus for publishing channel events.
TYPE:
|
Source code in src/diapason/channels/twitter_channel.py
Methods:¶
connect
¶
Validate credentials and start mention polling.
Source code in src/diapason/channels/twitter_channel.py
disconnect
¶
Stop the polling thread.
Source code in src/diapason/channels/twitter_channel.py
send
¶
send(
channel: str,
content: str,
*,
conversation_id: str = "",
metadata: Dict[str, Any] | None = None,
) -> bool
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.
Source code in src/diapason/channels/twitter_channel.py
status
¶
status() -> ChannelStatus