npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

twei

v0.2.7

Published

a weibo cli tool

Downloads

51

Readme

twei

twei 是用 node.js 编写的微博命令行工具. 目前支持新浪微博的查看与发送.

环境

twei 适用于所有可运行 node.js 的环境, 包括 windows, linux, mac os, cygwin 等.

安装

  1. 安装 node.js
  2. 在命令行中: npm install -g twei
  3. twei --version

使用最新的开发版本:

  1. git clone https://github.com/justan/twei.git
  2. cd twei && npm link
  3. twei --version

使用

  符号说明: 
    微博用户名: {{username}}
    微博 id: {{sid}}
    微博评论 id: {{cid}}
    评论内容: {{comment}}
    微博内容: {{status}}
  • 查看提醒: twei remind

  • 更新微博

    • 发微博: twei update 雨一直下个不停
    • 发带网络图片的微博: twei update 雨一直下个不停 -i http://example/example.png
    • 发带本地图片的微博: twei update 雨一直下个不停 -i ./example.png
    • 转发微博: twei repost {{sid}} {{status}}
    • 转发并评论: twei rt {{sid}} {{status}}
  • timeline

    • 查看收到的微博: twei timeline
    • 查看自己的微博: twei timeline.user
    • 查看指定用户的微博: twei timeline.user {{username}}
    • 查看@你的微博: twei timeline.mentions
  • 查看用户信息: twei user {{username}}

  • 查看指定用户的粉丝: twei followers {{username}}

  • 查看 follow 哪些人: twei friends {{username}}

  • follow 某人: twei follow {{username}}

  • 评论

    • 查看@你的评论: twei comments.mentions
    • 查看你发出评论: twei comments.by_me
    • 查看给你的评论: twei comments.to_me
    • 查看某条微博的评论: twei comments {{sid}}
    • 评论微博: twei comment {{sid}} {{comment}}
    • 删除评论: twei comment.remove {{sid}}
    • 回复评论: twei comment.reply {{sid}} {{cid}} {{comment}}
  • 帮助

    • 查看 execute 的帮助内容: twei help execute or twei execute -h

    • 查看新浪微博 api 文档:

      • twei help remind
      • twei help timeline
      • twei help whois

进阶使用

通过管道 twei 可以方便的借用 *nix 其他字符处理程序(诸如: grep xargs cut 等)的强大功能. 如:

  • 用 less 查看微博列表: twei timeline --count 100 | less -R
  • 查看未读微博: twei remind --filter status | xargs twei timeline --count
  • unfollow 你关注列表中没有 follow 你的人: twei friends {{username}} --filter users.follow_me users.name | grep false | cut -f 2 | xargs -i twei unfollow {}

如果你知道有意思的用法, 请告诉我 :)

测试

npm test

access_token

由于新浪的 api 限制, 目前的 access_token 只有数天的有效期. Access_token 过期后需要 输入你重新授权后的新 access_token.

access_token保存在$HOME/.tweirc:

[tsina]
2 access_token = 2.00V_123567abcdefg

twei发布的微博会显示来自twei,如果你希望将twei改成你在新浪微博申请的应用的名称,只需 用你的应用的access_token替换即可。你可以在微博API测试后台 看到access_token

自动补全

twei 从 v0.2.3 版本后开始支持 bash 和 zsh 的自动补全功能. 该功能默认未开启. 使用方法同 npm : twei completion >> ~/.bashrc or twei completion >> ~/.zshrc

execute

相比上面的示例, twei 提供了功能更为完整的微博命令行接口 execute. 使用 execute 命令可以执行较为完整的微博 api 接口.

Usage: twei execute {{apistr}} {{querystring}}

apistr & querystring:

twei 将新浪微博的接口 转接成 group.name 的 apistr 形式. 使用 twei api, 在命令行中即可直接操作微博的接口.

querystring 是 apistr 的请求参数. querystring 可以是普通的请求字符串格式(uid=1488292340), 如果该条 api 定义了expect, querysting 可以省去请求参数头部分(前例中的 "uid=" 部分). 完整的 querysting 请参考新浪微博的接口

Usage: twei timeline.home count=2 page=2 or twei timeline.home "count=2&page=2" or twei timeline --count 2 --page 2, twei execute statuses.user sheepmaker count=5 page=2 feature=1

自定义

alias 和 shower 是 twei 提供的自定义命令和样式功能.

  • command alias 可以将常用命令改写成较短的命令.
  • 默认的 twei 只提供了有限类型的数据. 通过 shower 则可以自定义内容的显示样式. 自定义的 shower 可以通过 --shower 指定使用. Example: twei timeline --shower json

联系

如果你对 twei 有任何的建议, 可以使用 issue, 或者直接联系 @sheepmaker