alpineintel / tcrpartybot

A Twitter bot for interacting with a TCR without knowing what a blockchain is
https://www.tcr.party
MIT License
28 stars 5 forks source link
blockchain ethereum token-curated-registry twitter-bot

TCR Party Bot!

This repository implements the brains behind the TCR Party Bot. This bot facilitates all interactions between Twitter and the underlying smart contracts on the blockchain in addition to retweeting all members of the live TCR.

Contributing

Since you're reading this you've probably realized that TCR Party is an open source project! If you're feeling particularly frisky and have a feature that you'd like to see added or a bug that needs to be fixed we'd love for you to contribute.

The best place to get an inside look into our development process is by checking out our issue board and list, which keep track of tasks we're looking to complete. If you notice your request hasn't been already mentioned, feel free to open a ticket to begin discussion. We'd ask that you please open a ticket to discuss feature requests/issues before opening a PR, as we would like to make sure that there is no wasted/duplicated efforts. Nobody likes spending hours building a PR just to see it go stale in the tracker!

Additionally, we require all discussions around TCR Party follow Recurse Center's wonderful code of conduct in order to ensure a welcoming and fun environment for everybody.

Dev environment setup

Prepare dependencies

In order to get started you'll need to first deploy our contracts to a local blockchain. You can find more info on how to do this in the contracts repository.

Additionally, you'll need to have a working installation of Golang and Dep and a local Postgres database to work with.

Set up your environment file

We'll need to set up some variables dependant on your environment to get started. Create a new file in your cloned repository tcrpartybot/.env with the following contents:

API_TOKEN_HASH='some-bcrypt-hash-here'
VIP_BOT_HANDLE=tcrpartyvip
PARTY_BOT_HANDLE=tcrpartybot
DATABASE_URL=postgres://localhost:5432/tcrparty?sslmode=disable
TWITTER_CONSUMER_KEY=
TWITTER_CONSUMER_SECRET=
TWITTER_ENV=
SEND_TWITTER_INTERACTIONS=false
PREREGISTRATION=false
INITIAL_DISTRIBUTION_AMOUNT=3000
GAS_MODIFIER=0
TWITTER_LIST_SLUG=tcr-party-dev

BASE_URL=https://bbd828f3.ngrok.io
SERVER_HOST=0.0.0.0:8080

ETH_NODE_URI=http://localhost:8545
MASTER_PRIVATE_KEY= # Note that this should omit the opening 0x of the private key

TOKEN_ADDRESS=
WALLET_FACTORY_ADDRESS=
TCR_ADDRESS=
START_BLOCK=0

A few notes on the fields:

Database setup

Connect to your postgres instance and create a new database entitled tcrparty:

CREATE DATABASE tcrparty;

Ensure whatever role you're using has permission to connect to and modify this database:

GRANT ALL PRIVILEGES ON DATABASE tcrparty TO steve;

Now let's set up our schema! We use Migrate for database migrations, which you can find installation instructions for in their README. You can find a conveniently preconfigured script for running migration commands in bin/migrate.

Once you have migrate set up, you can set up your database by running:

$ bin/migrate up

Starting the server

Once you have everything set up (reminder: did you clone the contracts repository and deploy them onto your local Ganache instance?) you should be able to run the party bot by cding into the tcrpartybot directory and running:

$ go run *.go -repl

Notice the -repl flag, which tells the bot to start an interactive command line for you to simulate various interactions such as DMs, mentions, etc. without needing to use Twitter's API.