Uses Tweepy, Heroku, and PostgreSQL to build Lilt, a Twitter text adventure.
How To Run:
- Clone this repo.
- Install Homebrew if you haven't yet.
- Run
brew install postgresql
. pip3 install psycopg2-binary
(Note: This is why runningpip install -r requirements.txt
will not work - I'm running thepsycopg2-binary
locally, notpsycopg2
)pip3 install tweepy
pip3 install urllib3
- Export environment variables -
DATABASE_URL
& Twitter auth tokens. - Run the app once:
python3 bot.py
, or start the clock:python3 clock.py
.
NOTE: SOMETIMES DATABASE_URL
WILL CHANGE. From Heroku's PostgreSQL
administration page:
Heroku rotates credentials periodically and updates applications where this database is attached.
I believe Heroku would manage this automatically if the database had been set up under the same app as this bot. In the case of Lilt, however, the database is under a separate app called "lilt-game". If an error occurs due to a permissions issue, I will likely need to go to lilt-game -> Resources -> Heroku Postgres -> Settings and get the new URI from there.
Lilt includes admin functionality for certain Twitter users that allows them to have full access to Lilt's databases through tweets. Available commands are detailed below.
Example insert
tweet: @familiarlilt la do~insert~moves~move|look around~response|You're in an empty room.
liltadd
(la
): Initiates an admin-level PostgreSQL statement. Restricted to @liltbuilder and @mknepprath exclusively.do
: Calls the most flexible db function available, allowing one to SELECT FROM, UPDATE, INSERT INTO, and DELETE FROM any table in Lilt's database.~
: Arguments for the database statement are delineated by tildes.insert
(select
,update
,delete
): Specifies the type of statement being made.moves
(items
,users
, etc): Specifies the table being manipulated.move|look around
: Column/value pairs that will be added to the specified table.
Example update
tweet: @familiarlilt la do~update~moves~drop|marbles~response|You trip and drop your marbles.
drop|marbles
: The first column/value pair in anupdate
statement is the one that will be updated. In this example, thedrop
column will be updated where the response to a player'smove
is set to "You trip and drop your marbles."
Example select
tweet: @familiarlilt la do~select~item~max~name|banana
trigger
: The value in this column is what will be returned for rows that have the namebanana
. In this example, it would return5
, as that is the max amount of bananas one can carry.
Example delete
tweet: @familiarlilt la do~delete~moves~move|look at cat~response|What cat?
move|look at cat~response|What cat?
: Deletes rows that match these conditions in the table specified.
Example copy
tweet: @familiarlilt la copy~look around~scan room~room
Creates new move with all the same data as move being copied, so scan room
would have the same response, condition, etc.