Skip to content

Instantly share code, notes, and snippets.

@DavidRyan
Created March 26, 2014 18:25
Show Gist options
  • Save DavidRyan/9789929 to your computer and use it in GitHub Desktop.
Save DavidRyan/9789929 to your computer and use it in GitHub Desktop.
import json
import urllib2
import urllib
from flask import Flask
from flask import request
app = Flask(__name__)
post_url = 'https://api.groupme.com/v3/bots/post'
bot_id = 'a63fa8c46207f5b791ae25b3f8'
@app.route('/', methods=['GET', 'POST'])
def bot():
if request.method == 'POST':
msg = json.loads(request.data)
if msg['user_id'] == '164215':
return
route(msg)
return " "
def route(msg):
text = msg['text'].lower()
if 'im gay' in text:
post("ur gay")
if 'amirite' in text:
post("You are right")
return " "
if '/slap' in text:
fish(text)
return
if 'ugh' in text:
if text.__len__() != 3:
return " "
post("dying")
post("literally")
return " "
if 'i\'m gay' in text:
post("ur gay")
post("ur gay")
if 'jamie' in text:
post("...")
if 'sean' in text:
post("Blasterjaxx")
if 'bull' in text:
post("Cali Dabs")
if 'josh' in text:
post("mimis")
if 'cam' in text:
post("cahhmm kinnah")
if 'cleveland' in text:
post("sage")
if 'podbot' in text:
if text.__len__() != 6:
return " "
if 'love' not in text:
post("Yes?")
if 'browns' in text:
post("sage")
if 'dead' in text:
if "soooooooo" in text:
return
post("soooooooo fucking dead ugghhh")
post("literally")
if 'i love you podbot' in text:
post("<3")
if 'blasterjaxx' in text:
post("sage")
if 'the council has spoken' in text:
cats()
if '/number' in text:
numbers(text)
return " "
if __name__ == "__main__":
app.run()
def fish(message):
end = message[5:]
if '/slap' in end:
return
post("*slaps " + end + " around a bit with a large trout*")
def post(message):
payload = get_payload(message)
data = urllib.urlencode(payload)
req = urllib2.Request(post_url, data)
response = urllib2.urlopen(req)
def cats():
post('http://i.imgur.com/hfmy8.jpg')
def get_payload(msg):
payload= {'text' : msg,
'bot_id' : bot_id}
return payload
def numbers(message):
number = message[8:]
url = 'http://numbersapi.com/' + number
response = urllib2.urlopen(url)
html = response.read()
post(html)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment