Larry 🐦 is a really simple Twitter bot generator that tweets random repositories from Github built in Go

Larry 🐦

Go Coverage Status Go Report Card MIT License

Larry is a Golang cli bot that tweets random Github repositories.

Disclaimer

I hold no liability for what you do with this bot or what happens to you by using this bot. Abusing this bot can get you banned from Twitter, so make sure to read up on proper usage of the Twitter API.

Running bots

  • GolangRepos: Tweets repositories from Github that contain the "golang" topic
  • RustRepos: Tweets repositories from Github that contain the "rust" topic
  • MLRepositories: Tweets repositories from Github that contain the "machine-learning" topic
  • CryptoRepos: Tweets repositories from Github that contain the "crypto" topic

Installation

You can install Larry by cloning the repo and using go install

git clone https://github.com/ezeoleaf/larry.git
cd larry/cmd/larry
go install

You can also use make for building the project and generating an executable:

git clone https://github.com/ezeoleaf/larry.git
cd larry
make build

Or you can just run it on the go

git clone https://github.com/ezeoleaf/larry.git
cd larry
go run . [options]

Usage

Configuring the bot

Before running the bot, you must first set it up so it can connect to Github and Twitter API.

To do this, you will need to setup the following environment variables:

- GITHUB_ACCESS_TOKEN
- TWITTER_CONSUMER_KEY
- TWITTER_CONSUMER_SECRET
- TWITTER_ACCESS_TOKEN
- TWITTER_ACCESS_SECRET

If you want the content to be publish in a README file on a repo, you also need these variables
- GITHUB_PUBLISH_REPO_OWNER (Your Github username)
- GITHUB_PUBLISH_REPO_NAME (The name of the repo where your README is. It has to be public)
- GITHUB_PUBLISH_REPO_FILE (By default is README)

For generating Github access token you can follow this guide

For getting Twitter keys and secrets you can follow this guide

Note: You will to generate both consumer and access pair of keys/tokens and secrets

Providers and Publishers

For information on publishers and providers click here

Providers (where the information is coming from)

Name Key Environment Variables
Github github GITHUB_ACCESS_TOKEN

NOTE: The key is used in the --provider or --pr option

Publishers (where the information is going to be posted)

Name Key Environment Variables Observation
Twitter twitter TWITTER_CONSUMER_KEY
TWITTER_CONSUMER_SECRET
TWITTER_ACCESS_TOKEN
TWITTER_ACCESS_SECRET
Github github GITHUB_PUBLISH_REPO_OWNER
GITHUB_PUBLISH_REPO_NAME
GITHUB_PUBLISH_REPO_FILE
For now it is only going to be posted in the README file and the repository must be public

NOTE: The key is used in the --publisher or --pub option

Running the bot

To run the bot, you have two ways.

If you have installed the bot, you can run it using larry [options]

If you want to run it without installing it globally you can use go run . [options]

Example:

larry -h

As a response you will see the entire options available

NAME:
   Larry - Twitter bot that publishes random information from providers

USAGE:
   larry [global options] command [command options] [arguments...]

AUTHORS:
   @ezeoleaf <[email protected]>
   @beesaferoot <[email protected]>

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --topic value, -t value         topic for searching repos
   --lang value, -l value          language for searching repos
   --time value, -x value          periodicity of tweet in minutes (default: 15)
   --cache value, -r value         size of cache for no repeating repositories (default: 50)
   --hashtag value, --ht value     list of comma separated hashtags
   --tweet-language, --tl          bool for allowing twetting the language of the repo (default: false)
   --safe-mode, --sf               bool for safe mode. If safe mode is enabled, no repository is published (default: false)
   --provider value, --pr value    provider where publishable content comes from (default: "github")
   --publisher value, --pub value  list of comma separared publishers (default: "twitter")
   --help, -h                      show help (default: false)

For running the bot, the command will depend on whatever you want to tweet, but, for tweeting about React repositories every 30 minutes, you could use

  larry --topic react --time 30 --safe-mode

For running the bot for Rust tweets every 15 minutes

  larry --lang rust --time 15

Have questions? Need help with the bot?

If you're having issues with or have questions about the bot, file an issue in this repository so anyone can get back to you.

Or feel free to contact me [email protected] :)

ko-fi

Owner
Eze Olea Figueroa
Backend Engineer at @schibsted
Eze Olea Figueroa
Comments
  • Improve documentation

    Improve documentation

    Is your feature request related to a problem? Please describe. No

    Describe the solution you'd like Improve documentation to add the providers and publishers supported at the moment and which env variables are needed for them.

    Describe alternatives you've considered -

    Additional context -

  • Add blacklist of repos in cache

    Add blacklist of repos in cache

    Is your feature request related to a problem? Please describe. Yes, sometimes, some tweets are not related to the language itself.

    Describe the solution you'd like The idea is to have a list of blacklisted repositories that must be avoided.

    Describe alternatives you've considered Having the blacklist in a config file, but not a good idea.

  • Allow local file as source of data

    Allow local file as source of data

    Is your feature request related to a problem? Please describe. No

    Describe the solution you'd like Fetch messages from a local file so they can be posted. The file could be in different formats so we may need to specify the format in the params when starting the app. It could be:

    • Json: A list of string texts
    • CSV: An allow to pass a column name as param to publish the text in that column.

    Describe alternatives you've considered Other formats can be included

    Additional context No

  • Tag the owner of the repository in the tweet

    Tag the owner of the repository in the tweet

    Is your feature request related to a problem? Please describe. No

    Describe the solution you'd like Look for the owner's twitter account in the response from Github's API and add it to the generated tweet

  • Retrieving wrong repositories

    Retrieving wrong repositories

    Describe the bug In some cases, repositories are tweeted when they have the golang topic but they are not built with Go.

    To Reproduce Steps to reproduce the behavior:

    1. This tweet: https://twitter.com/GolangRepos/status/1370046758202470403

    Expected behavior All tweets should be related to the topic/language selected for the bot.

  • Add support to Mastodon

    Add support to Mastodon

    Is your feature request related to a problem? Please describe. No

    Describe the solution you'd like Implement the API to Mastodon to publish repos

    Describe alternatives you've considered \ -

    Additional context Docs

  • Added JSON and CSV file providers

    Added JSON and CSV file providers

    This implements #55 to support local file providers with a JSON or CSV file format.

    • Larry now has a new contentfile provider which supports files in the CSV and JSON formats
    • This provider requires a command line arg --content-file which provides the local file and the file extension indicates the format of the file
    • The provider expects the Content struct fields on each record where only the Title field is required
    • The Provider uses the reservoir sampling method to efficiently (one pass) find a random record in the file
    • The provider also has an optional command line arg --skip-csv-header to skip past the header record of the CSV file
    • The CSV file can have an "unlimited" number of ExtraData fields by just including them at the end of each record (note: every CSV record needs the same number of fields.
    • The CSV file can have fields surrounded by double quotes or not
    • The readme has been updated to include the new features

    Update: I updated this comment to reflect the refactoring changes I made

  • Fix issue: Cannot publish tweet if it is too long

    Fix issue: Cannot publish tweet if it is too long

    Fixes #40

    Changes in brief:-

    1. Added a function to check for content to make sure it is within limit(truncates description, if required).
    2. Added test for above function.

    Note --> I am new to both open source and github community. So, I will be happy to receive feedbacks.

  • Larry stopped working due to error in Github API

    Larry stopped working due to error in Github API

    Describe the bug Github API returned 502 and we had an exception and Larry stopped running

    To Reproduce Steps to reproduce the behavior:

    1. Simulare error from Github API when fetching repositories

    Expected behavior Even if an error from Github happens, the application should not stop but just log an error

    Screenshots image

  • Bump github.com/urfave/cli/v2 from 2.23.6 to 2.23.7

    Bump github.com/urfave/cli/v2 from 2.23.6 to 2.23.7

    Bumps github.com/urfave/cli/v2 from 2.23.6 to 2.23.7.

    Release notes

    Sourced from github.com/urfave/cli/v2's releases.

    v2.24.0

    What's Changed

    Full Changelog: https://github.com/urfave/cli/compare/v2.23.6...v2.24.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Bump github.com/dghubble/oauth1 from 0.7.1 to 0.7.2

    Bump github.com/dghubble/oauth1 from 0.7.1 to 0.7.2

    Bumps github.com/dghubble/oauth1 from 0.7.1 to 0.7.2.

    Release notes

    Sourced from github.com/dghubble/oauth1's releases.

    v0.7.2

    • Update minimum Go version from v1.17 to v1.18 (#66)
    Changelog

    Sourced from github.com/dghubble/oauth1's changelog.

    v0.7.2

    • Update minimum Go version from v1.17 to v1.18 (#66)
    Commits
    • 1445aad Update minimum Go version from v1.17 to v1.18
    • 953dec3 Bump github.com/stretchr/testify from 1.8.0 to 1.8.1
    • 56d749b Add go 1.19 to test matrix
    • 6f7198a Bump github.com/stretchr/testify from 1.7.5 to 1.8.0
    • 2e9b39a Bump github.com/stretchr/testify from 1.7.4 to 1.7.5
    • 52fe671 Bump github.com/stretchr/testify from 1.7.2 to 1.7.4
    • 4590427 Bump github.com/stretchr/testify from 1.7.1 to 1.7.2
    • 74c7d89 Update Go test matrix to add Go v1.18
    • dec88a1 Bump github.com/stretchr/testify from 1.7.0 to 1.7.1
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Migrate blacklist functionality to file

    Migrate blacklist functionality to file

    Is your feature request related to a problem? Please describe. Yes, Redis is not keeping the blacklist keys indefinitely, so ideally we will read from a blacklist file every 5 minutes and load the blacklisted repositories in memory to be used as our cache.

    Describe the solution you'd like See above

    Describe alternatives you've considered Perhaps a db but that could be messier. Or instead of a go routine, using an endpoint to accept new repository to blacklist and then update the blacklisted list.

    Additional context -

  • Add latest update date from repository

    Add latest update date from repository

    Is your feature request related to a problem? Please describe. Maybe. Sometimes some repositories are not updated lately and it would be a good idea when was the last update date

    Describe the solution you'd like Read the latest commit date and add it so it can be used when creating a Tweet

    Describe alternatives you've considered Maybe latest update date if it's not possible to get the latest commit date

    Additional context Ideally the update date should be added in ExtraData so if an be used or not

  • Content files read from S3 source

    Content files read from S3 source

    This implements issue #34 by looking for the AWS S3 URI in the content filename, e.g., S3://my-bucket/my-data/example.json, to determine the content file source: local file vs. S3 object.

  • Migrate to twitter oauth2.0 [fixes the previous merge conflict]

    Migrate to twitter oauth2.0 [fixes the previous merge conflict]

    Fixes the issue #45

    Detailed overview of the changes being made:-

    • publisher/twitter/oauth2/ --> The files inside this are handling all the oauth2 flow related stuffs.
      Like authorizing app, authenticating requests, regenerating tokens, etc. Using the package, golang.org/x/oauth2.

    • publisher/twitter/publisher.go --> Removed dependency of dghubble/oauth1, dghubble/twitter package and added our own inbuilt oauth2 handler for twitter.
      Also, changed the working of the function to monitor tweets for exceeding length(to help in testing).

    • publisher/twitter/publisher_test.go --> Commented two test functions for now. As, they are using empty/invalid id and secret for generating config that will result into failed authentication. Have to think for other work around.

    • PublishersAndProviders.md --> Added steps to generate twitter client id and secret.

    • README.md --> Added the information for authorization steps that the user needs to perform while running the bot.

    • img/ --> New folder, it contains images to help visualize the above steps for better understanding and assistance.

    • cmd/larry/main.go --> Changes to integrate with the updated authorization flow.

    • publisher/twitter/oauth2/test_files --> This folder contains file required while testing oauth2 package.

    • docker-compose.yml --> Removed the variables which are not required anymore.

    cc: @ezeoleaf

  • Add Discord as publisher

    Add Discord as publisher

    Is your feature request related to a problem? Please describe. No

    Describe the solution you'd like Integrate Discord API to publish messages

    Describe alternatives you've considered No other alternatives

    Additional context No

  • Add Slack as publisher

    Add Slack as publisher

    Is your feature request related to a problem? Please describe. No

    Describe the solution you'd like Integrate Slack API to publish messages into a channel

    Describe alternatives you've considered No other alternatives

    Additional context No

Bot that tweets posts with the Go tag on Qiita
Bot that tweets posts with the Go tag on Qiita

GoTwitterBot A bot that tweets posts with the Go tag on Qiita

Oct 4, 2021
A REALLY crappy discord bot with golang

DiscordTubeFeeder This is some shitty discord bot that looks at a youtube xml fe

Dec 18, 2021
Bot-template - A simple bot template for creating a bot which includes a config, postgresql database

bot-template This is a simple bot template for creating a bot which includes a c

Sep 9, 2022
A bot to fetch latest leads/resources from Twitter

Covid-Twitter Stream Bot A simple bot that uses Twitter's Stream Search API to send recent tweets that match the filter, to a Telegram group. Steps to

Nov 28, 2022
Golangdogecointicker - Powering the @dogecointicker twitter bot

Written by Damen Knight Copyright 2021 This is just a repo I setup to share some

Jan 25, 2022
Github-trending-bot - Go app to archive daily github trending repos.

GITHUB-TRENDING-BOT Simple application to archive daily github trending repos, written in Go. Project Description Uses Go to parse raw html from the g

Jan 7, 2022
GithubTrackBot - A telegram bot for trending repositories notifications

GithubTrackBot WIP! A telegram bot for trending repositories notifications. Usag

Apr 2, 2022
🦎 A slack bot for random gex quotes

?? A slack bot for random gex quotes

Jan 3, 2022
Golang Based Account Generator Telegram Bot

Account Generator Bot Account Generator Bot, written in GoLang via gotgbot library. Variables Env Vars - BOT_TOKEN - Get it from @BotFather CHANNEL_ID

Nov 21, 2022
Account Generator Bot, written in GoLang via gotgbot library.

Account Generator Bot Account Generator Bot, written in GoLang via gotgbot library. Variables Env Vars - BOT_TOKEN - Get it from @BotFather CHANNEL_ID

Jul 7, 2022
HoloBot β€” An open-source Discord bot for Hololive fans, built with Go.

HoloBot HoloBot β€” An open-source Discord bot for Hololive fans, built with Go. Installation From Binary Download holobot binary here. Create a file ca

Dec 17, 2021
ChatRat is a twitch chat bot built in Go that is a dedicated shitpost machine.

ChatRat ChatRat is a twitch chat bot built in Go that is a dedicated shitpost machine. Also does some other things, but for now the main thing is just

Nov 17, 2022
Snitch - a Slack bot that fetches pending review PRs built in Go
Snitch - a Slack bot that fetches pending review PRs built in Go

Snitch Snitch is a Slack bot that fetches and publish PRs with pendings reviews

Nov 29, 2022
A bot based on Telegram Bot API written in Golang allows users to download public Instagram photos, videos, and albums without receiving the user's credentials.

InstagramRobot InstagramRobot is a bot based on Telegram Bot API written in Golang that allows users to download public Instagram photos, videos, and

Dec 16, 2021
Dlercloud-telegram-bot - A Telegram bot for managing your Dler Cloud account

Dler Cloud Telegram Bot A Telegram bot for managing your Dler Cloud account. Usa

Dec 30, 2021
Discord-bot - A Discord bot with golang

JS discord bots Install Clone repo git clone https://github.com/fu-js/discord-bo

Aug 2, 2022
Bot - Telegram Music Bot in Go

Telegram Music Bot in Go An example bot using gotgcalls. Setup Install the serve

Jun 28, 2022
Pro-bot - A telegram bot to play around with the community telegram channels

pro-bot ?? Pro Bot A Telegram Bot to Play Around With The Community Telegram Cha

Jan 24, 2022
Slack-emoji-bot - This Slack bot will post the newly created custom Slack emojis to the channel of your choice

Slack Emoji Bot This Slack bot will post the newly created custom Slack emojis t

Oct 21, 2022