Skip to content
/ twict Public

A library for Twitter Account Activity API written in TypeScript

License

Notifications You must be signed in to change notification settings

hota1024/twict

Repository files navigation

🐦 twict

A library for Twitter Account Activity API written in TypeScript

🚀 Installation

yarn add twict
# or
npm install twict

🗺️ Tutorial

1. Install twict

yarn add twict
# or
npm install twict

2. ngrok

download ngrok to your environment.

start http tunnel on port 5000 and copy https://*.ngrok.io url.

ngrok http 5000

3. Like detection

// like-detection.ts
import { Activity, isExpectEventType } from 'twict'

async function main() {
  const activity = new Activity('your environment label', {
    consumerKey: 'your consumer key',
    consumerSecret: 'your consumer secret',
    token: 'your access token',
    tokenSecret: 'your access token secret',
  })

  activity.onFavorite((event) => {
    for (const like of event.favorite_events) {
      console.log(
        `${like.user.screen_name} liked your tweet (${like.favorited_status.text})`
      )
    }
  })

  await activity.listen(5000)

  await activity.deleteAllWebhooks()
  await activity.registerWebhook('your ngrok url here')
  await activity.subscribe()
}

main()

and run with ts-node.

npx ts-node like-detection.ts

About

A library for Twitter Account Activity API written in TypeScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published