Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resize command #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def process_message(self, author_id, ma, thread_id, thread_type):
physics switch [name] - switch your current bottle to the bottle with [name]
physics drink [name] - logs a single drink with bottle [name], does not change current bottle
physics rename [name] [newname] - NOT WORKING
physics resize [name] [newsize] - gives bottle [name] a new size [newsize] (this affects all past drink events)
physics list - shows all of your bottles
physics decrement - remove the last drink event
{} - tap emoji to log a drink, uses your current bottle
Expand All @@ -83,6 +84,8 @@ def process_message(self, author_id, ma, thread_id, thread_type):
data.switch_bottle(ma[2], author_id)
elif ma[1] == "rename":
pass
elif ma[1] == "resize":
data.resize_bottle(ma[2], ma[3], author_id)
elif ma[1] == "list":
get_homie_bottles(self, thread_id, thread_type, author_id)
elif ma[1] == "decrement" or ma[1] == "dec":
Expand Down
5 changes: 5 additions & 0 deletions data.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ def get_bottle(homie_fb_id):
def insert_bottle(name, size, homie_fb_id):
new_bottle_sql = """INSERT INTO bottles (homie_fb_id, bottle_name, bottle_size, num_drinks) VALUES(%s, %s, %s, %s);"""
return execute_statement(new_bottle_sql, [homie_fb_id, name, size, 0])

def resize_bottle(name, size, homie_fb_id):
bottle_entry = execute_statement("SELECT * FROM bottles WHERE homie_fb_id = %s AND bottle_name = %s;", args=(homie_fb_id, name), ret=True)
bottle_id = bottle_entry[0][0]
return execute_statement("UPDATE bottles SET bottle_size = %s WHERE bottle_id = %s", (size, bottle_id))

def delete_bottle(name, homie_fb_id):
bottle_entry = execute_statement("SELECT * FROM bottles WHERE homie_fb_id = %s AND bottle_name = %s;", args=(homie_fb_id, name), ret=True)
Expand Down