X to Kindle
Convert X/Twitter posts into Kindle-readable documents via email.
Requirements
- - Gmail account with App Password (or other SMTP setup)
- Kindle email address (found in Amazon account settings)
Workflow
When user shares an X link:
- 1. Extract content via fxtwitter API:
https://api.fxtwitter.com/status/<tweet_id>
Extract from URL:
twitter.com/*/status/<id> or INLINECODE1
- 2. Format as HTML file (save to /tmp):
CODEBLOCK1
- 3. Send via SMTP with HTML as ATTACHMENT (Kindle requires attachment, not inline HTML):
CODEBLOCK2
Tools
- -
send_to_kindle: Send a local file to the configured Kindle email.
Configuration
Set the following environment variables in your Clawdbot configuration (or .env file):
- -
SMTP_EMAIL: Your sender email (e.g., gmail) - INLINECODE5 : Your app password
- INLINECODE6 : Your Kindle email address
- INLINECODE7 : (Optional) Default: smtp.gmail.com
- INLINECODE8 : (Optional) Default: 587
Tool Definitions
sendtokindle
Send a local file (PDF, HTML, TXT) to the Kindle.
Configuration
Store in TOOLS.md:
CODEBLOCK3
Example
User sends: INLINECODE10
- 1. Fetch INLINECODE11
- Extract author, text, timestamp
- Send HTML email to Kindle address
- Confirm: "Sent to Kindle 📚"
X to Kindle
将X/Twitter帖子通过电子邮件转换为Kindle可阅读的文档。
前提条件
- - 拥有应用专用密码的Gmail账户(或其他SMTP设置)
- Kindle电子邮件地址(可在亚马逊账户设置中找到)
工作流程
当用户分享X链接时:
- 1. 通过fxtwitter API提取内容:
https://api.fxtwitter.com/status/<推文ID>
从URL中提取:twitter.com//status/ 或 x.com//status/
- 2. 格式化为HTML文件(保存至/tmp):
html
{标题}
@{作者昵称}
{推文内容}
{时间戳}
在X上查看
- 3. 通过SMTP发送HTML附件(Kindle需要附件,而非内嵌HTML):
python
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
msg = MIMEMultipart()
msg[Subject] = 来自@handle的推文
msg[From] = 发件邮箱
msg[To] = kindle邮箱
# 纯文本正文(非内容)
msg.attach(MIMEText(附件为文章。, plain))
# HTML文件作为附件 - 此为必需
with open(/tmp/article.html, rb) as f:
attachment = MIMEBase(text, html)
attachment.set_payload(f.read())
encoders.encode_base64(attachment)
attachment.add_header(Content-Disposition, attachment, filename=article.html)
msg.attach(attachment)
工具
- - sendtokindle:将本地文件发送至配置的Kindle邮箱。
配置
在Clawdbot配置(或.env文件)中设置以下环境变量:
- - SMTPEMAIL:您的发件邮箱(例如gmail)
- SMTPPASSWORD:您的应用专用密码
- KINDLEEMAIL:您的Kindle邮箱地址
- SMTPSERVER:(可选)默认值:smtp.gmail.com
- SMTP_PORT:(可选)默认值:587
工具定义
sendtokindle
将本地文件(PDF、HTML、TXT)发送至Kindle。
- - 运行: python3 skills/x-to-kindle/sendtokindle.py <文件路径>
配置
存储于TOOLS.md中:
markdown
Kindle
邮箱(Gmail SMTP)
- - 发件人:your@gmail.com
- 应用专用密码:xxxx xxxx xxxx xxxx
- 主机:smtp.gmail.com
- 端口:587
示例
用户发送:https://x.com/elonmusk/status/1234567890
- 1. 获取 https://api.fxtwitter.com/status/1234567890
- 提取作者、文本、时间戳
- 发送HTML邮件至Kindle地址
- 确认:已发送至Kindle 📚