Advertisement
Good_Pudge

Pastebin Library

Oct 15th, 2016
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. local internet = require("internet")
  2.  
  3. pastebin = {}
  4. pastebin.doc = {}
  5.  
  6. pastebin.dev_key = ""
  7. pastebin.user_key = ""
  8. pastebin.post_url = "http://pastebin.com/api/api_post.php"
  9. pastebin.login_url = "http://pastebin.com/api/api_login.php"
  10. pastebin.raw_url = ""
  11.  
  12. function pastebin.init(dev_key,user_key)
  13.     pastebin.dev_key = dev_key
  14.     pastebin.user_key = user_key or ""
  15. end
  16.  
  17. function pastebin.create(name,text,private,time,syntax)
  18.     private = private or 2
  19.     time = time or "10M"
  20.     syntax = syntax or "text"
  21.  
  22.     for k,_ in internet.request(pastebin.post_url,'api_option=paste&api_user_key='..pastebin.user_key..'&api_paste_private='..private..'&api_paste_name='..name..'&api_paste_expire_date='..time..'&api_paste_format='..syntax..'&api_dev_key='..pastebin.dev_key..'&api_paste_code='..text..'') do
  23.         return k
  24.     end
  25. end
  26.  
  27. function pastebin.login(login,password)
  28.     for k,_ in internet.request(pastebin.login_url,'api_dev_key='..pastebin.dev_key..'&api_user_name='..login..'&api_user_password='..password..'') do
  29.         return k
  30.     end
  31. end
  32.  
  33. function pastebin.getList(results_limit)
  34.     results_limit = results_limit or "100"
  35.     return internet.request(pastebin.post_url,'api_option=list&api_user_key='..pastebin.user_key..'&api_dev_key='..pastebin.dev_key..'&api_results_limit='..results_limit..'')
  36. end
  37.  
  38. function pastebin.getPasteInfo()
  39.     return internet.request(pastebin.post_url,'api_option=trends&api_dev_key='..pastebin.dev_key..'')
  40. end
  41.  
  42. function pastebin.delete(paste_key)
  43.     for k,_ in internet.request(pastebin.post_url,'api_option=delete&api_user_key='..pastebin.user_key..'&api_dev_key='..pastebin.dev_key..'&api_paste_key='..paste_key..'') do
  44.         return k
  45.     end
  46. end
  47.  
  48. function pastebin.getUserInfo(user_key)
  49.     user_key = user_key or pastebin.user_key
  50.     return internet.request(pastebin.post_url,'api_option=userdetails&api_user_key='..pastebin.user_key..'&api_dev_key='..pastebin.dev_key..'')
  51. end
  52.  
  53. function pastebin.getRaw(paste_key,private)
  54.     private = private or nil
  55.     if private ~= nil then
  56.         return internet.request(pastebin.raw_url,'api_option=show_paste&api_user_key='..pastebin.user_key..'&api_dev_key='..pastebin.dev_key..'&api_paste_key='..paste_key)
  57.     else
  58.         return internet.request('http://pastebin.com/raw/'..paste_key)
  59.     end
  60. end
  61.  
  62. return pastebin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement