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 🙏

© 2024 – Pkg Stats / Ryan Hefner

rss-twitter-bot

v0.3.0

Published

This package provides a Twitter bot service with RSS feed integration capabilities.

Downloads

257

Readme

Twitter Bot Service

This package provides a Twitter bot service with RSS feed integration capabilities.

Features

  • Post articles from RSS feeds to Twitter
  • Optional MongoDB integration for tracking posted articles
  • Free access to Twitter API functionality

Usage

typescript

const rssFeeds = [
  {
    feedUrl: 'https://example.com/article',
    twitterHandle: 'example'
  }
] as const satisfies RSSFeed[];

// Initialize the service
const rssFeeds = [
  {
    feedUrl: 'https://example.com/article',
    twitterHandle: 'example'
  }
] as const satisfies RSSFeed[];

// Initialize the service
const twitterBot = new RSSTwitterBotService({
  mongoUri: 'your-mongo-uri',
  twitterTokens: {
    accessToken: 'your-access-token',
    accessSecret: 'your-access-secret',
    appKey: 'your-app-key',
    appSecret: 'your-app-secret'
  },
  rettiwtApiKey: 'your-rettiwt-api-key',
  openaiApiKey: 'your-openai-api-key',
  rssFeeds
});

/* Post a tweet about the article */
twitterBot.postArticleTweet({
  getPrompt: (article) => `You are a social media manager for a Twitter account focused on dogs. Create a unique tweet about the following article snippet. Use the template and example provided below to structure the tweet. Avoid using emojis. Make sure the tweet is concise, informative, and includes a call to action for readers to learn more. Add new lines at the end of each paragraph. Add hashtags at the end of the tweet.
  
  Article Title: "${article.title}"
  Article Link: "${article.link}"
  Article Twitter Handle: "${article.twitterHandle}"
  Article Snippet: "${article.contentSnippet.slice(0, 300)}"
  `
});

It's important to note that the article title, link, content snippet, and associated twitter handle (if provided) will be added to the prompt to generate the tweet.

Configuration

  • mongoUri: (Optional) MongoDB connection URI. If not provided, posted articles will not be tracked. This is useful if you want the bot to avoid posting duplicate articles.
  • rettiwtApiKey: (Optional) API key for rettiwt-api. If not provided, certain features like creating polls will not be available.

Tracking Posted Articles

This package uses MongoDB to track posted articles by default. If you want to use this feature, you need to provide a MongoDB connection URI.

If you don't want to use this feature, you can set mongoUri to undefined. The return object of post functions will contain the article and the tweet/poll object returned by the Twitter API. You can use this object to update your custom database.

Rettiwt API Integration

This package uses the rettiwt-api for free access to Twitter API functionality. To generate a rettiwt API key, follow the instructions provided in the rettiwt-api documentation.