···146146 --attach=foo:attendees.db \
147147 --sql="select Twitter from foo.attendees"
148148149149+## Capturing tweets in real-time with track and follow
150150+151151+This functionality is **experimental**. Please [file bug reports](https://github.com/dogsheep/twitter-to-sqlite/issues) if you find any!
152152+153153+Twitter provides a real-time API which can be used to subscribe to tweets as they happen. `twitter-to-sqlite` can use this API to continually update a SQLite database with tweets matching certain keywords, or referencing specific users.
154154+155155+### track
156156+157157+To track keywords, use the `track` command:
158158+159159+ $ twitter-to-sqlite track tweets.db kakapo
160160+161161+This command will continue to run until you hit Ctrl+C. It will capture any tweets mentioning the keyword [kakap](https://en.wikipedia.org/wiki/Kakapo) and store them in the `tweets.db` database file.
162162+163163+You can pass multiple keywords as a space separated list. This will capture tweets matching either of those keywords.
164164+165165+ $ twitter-to-sqlite track tweets.db kakapo raccoon
166166+167167+You can enclose phrases in quotes to search for tweets matching both of those keywords:
168168+169169+ $ twitter-to-sqlite track tweets.db 'trash panda'
170170+171171+See [the Twitter track documentation](https://developer.twitter.com/en/docs/tweets/filter-realtime/guides/basic-stream-parameters#track) for advanced tips on using this command.
172172+173173+Add the `--verbose` option to see matching tweets (in their verbose JSON form) displayed to the terminal as they are captured:
174174+175175+ $ twitter-to-sqlite track tweets.db raccoon --verbose
176176+177177+### follow
178178+179179+The `follow` command will capture all tweets that are relevant to one or more specific Twitter users.
180180+181181+ $ twitter-to-sqlite follow tweets.db nytimes
182182+183183+This includes tweets by those users, tweets that reply to or quote those users and retweets by that user. See [the Twitter follow documentation](https://developer.twitter.com/en/docs/tweets/filter-realtime/guides/basic-stream-parameters#follow) for full details.
184184+185185+This command accepts one or more screen names.
186186+187187+You can feed it numeric Twitter user IDs instead of screen names by using the `--ids` flag.
188188+189189+The command also supports the `--sql` and `--attach` options, and the `--verbose` option for displaying tweets as they are captured.
190190+191191+Here's how to start following tweets from every user ID currently represented as being followed in the `following` table (populated using the `friends-ids` command):
192192+193193+ $ twitter-to-sqlite follow tweets.db \
194194+ --sql="select distinct followed_id from following" \
195195+ --ids
196196+149197## Design notes
150198151199* Tweet IDs are stored as integers, to afford sorting by ID in a sensible way
+1-1
twitter_to_sqlite/cli.py
···363363)
364364@click.option("--verbose", is_flag=True, help="Verbose mode: display every tweet")
365365def follow(db_path, identifiers, attach, sql, ids, auth, verbose):
366366- "Experimental: Follow these Twitter users (numeric user IDs required) and save tweets in real-time"
366366+ "Experimental: Follow these Twitter users and save tweets in real-time"
367367 auth = json.load(open(auth))
368368 session = utils.session_for_auth(auth)
369369 db = sqlite_utils.Database(db_path)