Advertisement
GoldLeej

get defs

Oct 18th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. if cmd == ("getdefs"):
  2. dbc = mysql.connector.connect(user="charizard", password="password", host="localhost", autocommit=True, database="charizard")
  3. db = dbc.cursor()
  4. db.execute("select word, definition from definitions where user = \""+post.user+"\";")
  5. tmp = [[': '.join(x for x in x)][0] for x in db.fetchall()]
  6. tmp.sort()
  7. wordCount = len(tmp)
  8. if wordCount <= 15:
  9. words = ', '.join(tmp)
  10. group.sendPost("You have "+str(wordCount)+" words defined and they are: "+words)
  11. else:
  12. data = urllib.parse.urlencode({
  13. "api_dev_key": "api_dev_key_goes_here",
  14. "api_option": "paste",
  15. "api_paste_code": '\n'.join(tmp),
  16. "api_paste_private": "1",
  17. "api_paste_name": post.user,
  18. "api_user_key": ""}).encode()
  19. group.sendPost("Here are your definitions: "+str(urllib.request.urlopen("http://pastebin.com/api/api_post.php", data).readall().decode("utf-8")))
  20. db.close()
  21. dbc.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement