Skip to content
Permalink
Browse files

GIANT REFACTOR

  • Loading branch information
mknepprath committed Oct 8, 2019
1 parent 0e4da6a commit 285034e77ef43505c119f6f459c87695eff51719
Showing with 848 additions and 536 deletions.
  1. +3 −0 .gitignore
  2. +3 −0 .vscode/settings.json
  3. +0 −7 LICENSE
  4. +44 −20 README.md
  5. +287 −179 bot.py
  6. +13 −3 clock.py
  7. +125 −70 command.py
  8. +43 −0 constants.py
  9. +64 −36 db.py
  10. +35 −8 event.py
  11. +0 −72 init.sh
  12. +187 −121 item.py
  13. +0 −4 setup_env.sh
  14. +44 −16 utils.py
@@ -7,3 +7,6 @@ bin/
include/
lib/
distribute-*

*.pyc
*.pyo
@@ -0,0 +1,3 @@
{
"python.linting.pylintEnabled": false
}

This file was deleted.

@@ -1,33 +1,57 @@
Lilt
====
# Lilt

Working with Tweepy, Heroku, and PostgreSQL to build Lilt, a Twitter text adventure.
Uses Tweepy, Heroku, and PostgreSQL to build Lilt, a Twitter text adventure.

Builder Syntax
----
How To Run:

Example ```insert``` tweet: ```@familiarlilt la do~insert~moves~move|look around~response|You're in an empty room.```
1. Clone this repo.
1. Install [Homebrew](https://brew.sh) if you haven't yet.
1. Run `brew install postgresql`.
1. `pip3 install psycopg2-binary`
1. `pip3 install tweepy`
1. `pip3 install urllib3`
1. Export environment variables - `DATABASE_URL` & Twitter auth tokens.
1. Run the app once: `python3 bot.py`, or start the clock: `python3 clock.py`.

* ```liltadd``` (```la```): Initiates an admin-level PostgreSQL statement. Restricted to [@liltbuilder](http://twitter.com/liltbuilder) and [@mknepprath](http://twitter.com/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.
NOTE: SOMETIMES `DATABASE_URL` WILL CHANGE. From Heroku's PostgreSQL
administration page:

Example ```update``` tweet: ```@familiarlilt la do~update~moves~drop|marbles~response|You trip and drop your marbles.```
> Heroku rotates credentials periodically and updates applications where this database is attached.
* ```drop|marbles```: The first column/value pair in an ```update``` statement is the one that will be updated. In this example, the ```drop``` column will be updated where the response to a player's ```move``` is set to "You trip and drop your marbles."
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.

Example ```select``` tweet: ```@familiarlilt la do~select~item~max~name|banana```
## Builder Syntax

* ```trigger```: The value in this column is what will be returned for rows that have the name ```banana```. In this example, it would return ```5```, as that is the max amount of bananas one can carry.
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 ```delete``` tweet: ```@familiarlilt la do~delete~moves~move|look at cat~response|What cat?```
Example `insert` tweet: `@familiarlilt la do~insert~moves~move|look around~response|You're in an empty room.`

* ```move|look at cat~response|What cat?```: Deletes rows that match these conditions in the table specified.
- `liltadd` (`la`): Initiates an admin-level PostgreSQL statement. Restricted to [@liltbuilder](http://twitter.com/liltbuilder) and [@mknepprath](http://twitter.com/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 an `update` statement is the one that will be updated. In this example, the `drop` column will be updated where the response to a player's `move` 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 name `banana`. In this example, it would return `5`, 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.

#### Other Options

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.
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.

0 comments on commit 285034e

Please sign in to comment.
You can’t perform that action at this time.