首页
/ Earthquake 项目技术文档

Earthquake 项目技术文档

2024-12-26 21:14:02作者:董宙帆

本文档旨在帮助用户了解并使用 Earthquake 项目,这是一个基于终端的 Twitter 客户端,支持实时流 API。以下是项目的安装指南、使用说明以及 API 使用文档。

1. 安装指南

Docker 快速安装

  1. 克隆仓库:

    $ docker build -t earthquake . --build-arg TZ='Asia/Tokyo'
    
  2. 运行 Docker:

    $ docker run --rm -v $HOME/.earthquake:/root/.earthquake -it earthquake
    

    如果需要其他选项:

    $ docker run -v $HOME/.earthquake:/root/.earthquake -it earthquake --no-stream --no-logo
    

正常安装

  1. 确保安装了 openssl 和 readline 支持:

    $ rvm pkg install openssl
    $ rvm pkg install readline
    $ rvm remove 1.9.2
    $ rvm install 1.9.2 --with-openssl-dir=$HOME/.rvm/usr --with-readline-dir=$HOME/.rvm/usr
    
  2. 安装 gem:

    $ gem install earthquake
    

Ubuntu 用户:需要安装 libssl-dev 包。

$ sudo apt-get install libssl-dev

2. 项目使用说明

启动 Earthquake:

$ earthquake

以下是一些常用命令:

  • 显示帮助:⚡ :help
  • 发送推文:⚡ Hello World!
  • 显示推文:⚡ $xx (其中 $xx 是推文 ID)
  • 回复推文:⚡ $xx hi!
  • 删除推文:⚡ :delete $xx
  • 转发推文:⚡ :retweet $xx
  • 显示时间线:⚡ :recent
  • 显示用户列表:⚡ :recent jugyo
  • 搜索推文:⚡ :search #ruby
  • 执行代码:⚡ :eval Time.now
  • 退出程序:⚡ :exit
  • 重连:⚡ :reconnect
  • 重启程序:⚡ :restart
  • 显示线程:⚡ :thread $xx
  • 安装插件:⚡ :plugin_install https://gist.github.com/899506
  • 定义别名:⚡ :alias :rt :retweet
  • 推送 ASCII 艺术字:⚡ :update[ENTER] 后续输入 ASCII 字符串,结束后按 Ctrl+D
  • 查看 ASCII 艺术字:⚡ :aa :status $aa

更多命令请参考项目文档。

3. 项目 API 使用文档

Earthquake 使用 Twitter 的 Streaming API 来接收实时数据。配置文件 ~/.earthquake/config 中可以设置跟踪的关键词和用户。

例如,跟踪关键词 "earthquakegem" 和 "twitter":

Earthquake.config[:api] = {
  :method => 'POST',
  :host => 'stream.twitter.com',
  :path => '/1/statuses/filter.json',
  :ssl => true,
  :filters => %w(earthquakegem twitter)
}

跟踪特定用户:

Earthquake.config[:api] = {
  :method => 'POST',
  :host => 'stream.twitter.com',
  :path: '/1/statuses/filter.json',
  :ssl => true,
  :params => {
    :follow => '6253282,183709371' # @twitterapi @sitestreams
  }
}

4. 项目安装方式

Earthquake 可以通过 Docker 或者直接安装 Ruby gem 来使用。

  • Docker 安装:参考上面的 Docker 快速安装步骤。
  • 正常安装:确保系统中安装了 openssl 和 readline,然后使用 gem install earthquake 命令安装。

以上是 Earthquake 项目的基本使用和配置方法。希望对您有所帮助。

登录后查看全文
热门项目推荐
相关项目推荐