Automate replies to Tweets for the authorized user
NOTE: You will need to create a Twitter Developer account and create an API Key/Secret in order to use this software.
This is a modular Twitter reply bot written in Swift.
At a high-level, that means you create Module
s consisting of a single function that return an output string for some input Tweet:
func output(for reply: Reply, _ completion: @escaping ((String) -> Void))
The Bot
calls its module's output
method anytime it detects a new Tweet and automatically posts a reply (from the bot) with the string it received.
This project was motivated by a contest I've been running on Twitter called Codebreaker
:
https://github.com/JUSTINMKAUFMAN/TwitterCodebreaker
The idea is to have a bot monitor a Tweet (or an account more generally) and process all replies into a coded response from the bot. Users then compete to be first to figure out the bot's encryption algorithm.
The modules I have included in this app as examples are from the first two rounds of that contest.
Option 1: Clone this repository and build the app with Xcode 11.3. Option 2: Download the latest built binary from releases, unzip, and run.
- Run the app and enter your Twitter API Key/Secret in the input fields at the bottom of the window
- Click
Update
- Send a tweet to the bot and watch it reply!
- Add your own
Module
(change modules by updating the definition inConstants.swift
)
In order to authorize and communicate with the Twitter API, this app copies and modifies source from the excellent Swifter library by Matt Donnelly.
In the future - and assuming there is interest in this project - I will probably try to fork the Swifter library properly; this was just easier when I wasn't sure where the project was going.