Pastebin

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

bobby

Active Member
Jan 28, 2017
61
0
6
26
Hey, Idk if this is too much to ask for but how could I make it with reqn so if I set a file address it will upload the text in the address to pastebin or whatever and send me the link to it via chat? I'm using 1.10.2 and Skript 2.2 Dev-25
 
I don't know anything about skript api's :emoji_frowning:
[doublepost=1505058983,1505054780][/doublepost]
Could you help me with the code? Please.
If you really need it, learn api, else do with Variables or somethings?

i don't really understand what youre trying
 
Last edited by a moderator:
If you really need it, learn api, else do with Variables or somethings?

i don't really understand what youre trying
I'm trying to make it so on /pastebin <plugin file address> it will upload the text in the address so lets say it's settings.yml, it will upload the text in it and send me a link to the text file.
 
I'm trying to make it so on /pastebin <plugin file address> it will upload the text in the address so lets say it's settings.yml, it will upload the text in it and send me a link to the text file.
I don't see a point in that?
Also read the docs, they will be of use to you.
 
If you really need this then put in the work to learn it yourself.
Last time I checked this is a forum where people go if they need skript help, and requests is the place where people could help you with code. So far I haven't even got a single code that could help..
 
Last time I checked this is a forum where people go if they need skript help, and requests is the place where people could help you with code. So far I haven't even got a single code that could help..
This is pretty much the Spigot Forums in a nutshell too. Most people will not spoon feed you, but they will hint you on how to do whatever. The reason why people do not spoon feed 24/7 here is because it will get others to not learn how to solve problems themselves (ex: using docs, searching in forums, changing code, or doing alternative methods).
 
Last time I checked this is a forum where people go if they need skript help, and requests is the place where people could help you with code. So far I haven't even got a single code that could help..

Last time I checked you broke 3 rules on the forum. Don't expect people to help you. Don't expect people to just code everything for you for free even if this is the request forum, because this is something you don't code in a day. This is most probably something you can't do in Skript per se and should code it into Java. If the code is simple you can even expect me to code it for you as it takes no time.

Going passive aggressive here will earn you nothing.
 
Last time I checked you broke 3 rules on the forum. Don't expect people to help you. Don't expect people to just code everything for you for free even if this is the request forum, because this is something you don't code in a day. This is most probably something you can't do in Skript per se and should code it into Java. If the code is simple you can even expect me to code it for you as it takes no time.

Going passive aggressive here will earn you nothing.
Well mate, Fuck off then. someone already gave me the code to this. You little forum whore. :emoji_blush:
 
@xUndefined @White @BrettPlayMC guys, you know this is the request subforum right? Here is where you literally ask for being spoon feed, not where you help people understand something. It doesn't make any sense how you guys are threating the guy with such simple stuff, if you aren't gonna do it then just don't post, it's just not needed to argue about something that doesn't make any sense on this thread.

@bobby you're not being any better than the most part of people on this thread. @xUndefined is correct, you broke 3 rules and 4 now that you've insulted him. If you want something follow the rules as you're supposed to and use the proper request format or no one will even look at your request. And the most important thing, thank the people who are actually trying to help you in some way. For example @GrimEpp linked the Pastebin's API which was useful to me because I totally forgot Pastebin had a RESTful API, it isn't the code but it puts you on the way.

I usually look away when I see this kind of requests which don't use the format and blatantly explain what they want without giving a tiny bit of information and also not even saying "please". But this time, seeing this whole shit thread, I'll make an exception.

Said that, here is it with Reqn and skQuery:
code_language.skript:
options:
 
  #To get your developer key you have to log in on pastebin and then go to this link:
  #https://pastebin.com/api#1
  #It'll tell you your developer key in a code block.
  #DON'T GIVE IT TO ANYONE!
  api-developer-key: <put your developer key here>
  #The following option isn't needed if you're gonna post it as Guest.
  #This is your unique user key, you need this to post a paste as your account. You can get it on the following link:
  #https://pastebin.com/api/api_user_key.html
  #Or you could also use the function I made below
  #This changes every time your request one so make sure to request it once and save it to not publish pastes as guest.
  #DON'T GIVE IT TO ANYONE!
  api-user-key: <put your user key here>

#Why skQuery functions and not vanilla ones? Skript functions don't let you return stuff that is delayed, and as the send request effect takes one or two ticks to return the response
#With vanilla Skript it doesn't work well, so as much as I hate skQuery I have to use its function.
func "pastebinUserKey":
 
  set {_user-name} to url encoded "%parameter 1%"
  set {_user-password} to url encoded "%parameter 2%"

  #Had to double the ampersand and the next character in the body and also make it uncolored so Skript doesn't parse it as color codes, gave me a good one hour headache.
  send "POST" request to "https://pastebin.com/api/api_login.php" with headers "Content-Type: application/x-www-form-urlencoded" and body uncolored "api_dev_key={@api-developer-key}&&aapi_user_name=%{_user-name}%&&aapi_user_password=%{_user-password}%"

  set transient "output" to last response's body
  $ access
  set {_user-key} to transient "output"
  return


func "pastebinPaste":
 
  set {_paste-code} to url encoded "%parameter 1%"
  set {_paste-name} to url encoded "%parameter 2%"
  #You can get a list of available formats (aka syntax highlightings) here:
  #https://pastebin.com/api#5
  #This function defaults it to actionscript if not set.
  set {_paste-format} to parameter 3 ? "actionscript"

  if parameter 4 is "private":
    set {_paste-private} to 2
  else if parameter 4 is "unlisted":
    set {_paste-private} to 1
  else:
    set {_paste-private} to 0

  send "POST" request to "https://pastebin.com/api/api_post.php" with headers "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" and body uncolored "api_option=paste&&aapi_user_key={@api-user-key}&&aapi_paste_private=%{_paste-private}%&&aapi_paste_name=%{_paste-name}%&&aapi_paste_format=%{_paste-format}%&&aapi_dev_key={@api-developer-key}&&aapi_paste_code=%{_paste-code}%"

  set transient "paste-link" to last response's body
  $ access
  set {_paste-link} to transient "paste-link"
  return


command /paste <text>[|<text>][|<text>][|<text>]:
  usage: /paste <file path>|<file name>|[syntax highlight]|[public/private/unlisted]
  trigger:

    set {_paste-contents} to join file contents of arg-1 by new line
    set {_arguments::*} to arg-1, arg-2, arg-3 and arg-4

    #The first parameter is the path of the file you're gonna paste, like plugins/Skript/test.sk
    #The second one is the file name
    #The third one (optional) is the syntax highlight
    #And finally the fourth one (also optional) is if it's private, unlisted or public.
    access "pastebinPaste" from {_arguments::*}
    #As you see, the link will be saved to the variable {_paste-link}
    send {_paste-link}


command /paste-login <text>|<text>:
  usage: /paste-login <username>|<password>
  trigger:

    #The first parameter is the username you use in Pastebin.
    #The second one is the password you use in Pastebin.
    access "pastebinUserKey" from arg-1 and arg-2
    #The new generated user key will be saved to the variable {_user-key}
    send {_user-key}


EDIT: seems that an addon implemented this feature natively, it's skLib for anyone wondering. If you want use it instead of my function here are the syntaxes that it has:
code_language.skript:
[a] [new] public paste[ ][bin] [with] title[d] %string% [with] (text|body|contents) %string%

[a] [new] un[-| ]listed paste[ ][bin] [with] title[d] %string% [with] (text|body|contents) %string%
It doesn't allow user-specific pastes as you can see.
 
Last edited by a moderator:
Hey, Idk if this is too much to ask for but how could I make it with reqn so if I set a file address it will upload the text in the address to pastebin or whatever and send me the link to it via chat? I'm using 1.10.2 and Skript 2.2 Dev-25
Btw just a quick warning. If you give your key out it is like giving your discord token. They can send requests with your account and pastebin has a post limit so if you make to make posts you can get denied with some requests.
 
@xUndefined @White @BrettPlayMC guys, you know this is the request subforum right? Here is where you literally ask for being spoon feed, not where you help people understand something. It doesn't make any sense how you guys are threating the guy with such simple stuff, if you aren't gonna do it then just don't post, it's just not needed to argue about something that doesn't make any sense on this thread.

@bobby you're not being any better than the most part of people on this thread. @xUndefined is correct, you broke 3 rules and 4 now that you've insulted him. If you want something follow the rules as you're supposed to and use the proper request format or no one will even look at your request. And the most important thing, thank the people who are actually trying to help you in some way. For example @GrimEpp linked the Pastebin's API which was useful to me because I totally forgot Pastebin had a RESTful API, it isn't the code but it puts you on the way.

I usually look away when I see this kind of requests which don't use the format and blatantly explain what they want without giving a tiny bit of information and also not even saying "please". But this time, seeing this whole shit thread, I'll make an exception.

Said that, here is it with Reqn and skQuery:
code_language.skript:
options:
 
  #To get your developer key you have to log in on pastebin and then go to this link:
  #https://pastebin.com/api#1
  #It'll tell you your developer key in a code block.
  #DON'T GIVE IT TO ANYONE!
  api-developer-key: <put your developer key here>
  #The following option isn't needed if you're gonna post it as Guest.
  #This is your unique user key, you need this to post a paste as your account. You can get it on the following link:
  #https://pastebin.com/api/api_user_key.html
  #Or you could also use the function I made below
  #This changes every time your request one so make sure to request it once and save it to not publish pastes as guest.
  #DON'T GIVE IT TO ANYONE!
  api-user-key: <put your user key here>

#Why skQuery functions and not vanilla ones? Skript functions don't let you return stuff that is delayed, and as the send request effect takes one or two ticks to return the response
#With vanilla Skript it doesn't work well, so as much as I hate skQuery I have to use its function.
func "pastebinUserKey":
 
  set {_user-name} to url encoded "%parameter 1%"
  set {_user-password} to url encoded "%parameter 2%"

  #Had to double the ampersand and the next character in the body and also make it uncolored so Skript doesn't parse it as color codes, gave me a good one hour headache.
  send "POST" request to "https://pastebin.com/api/api_login.php" with headers "Content-Type: application/x-www-form-urlencoded" and body uncolored "api_dev_key={@api-developer-key}&&aapi_user_name=%{_user-name}%&&aapi_user_password=%{_user-password}%"

  set transient "output" to last response's body
  $ access
  set {_user-key} to transient "output"
  return


func "pastebinPaste":
 
  set {_paste-code} to url encoded "%parameter 1%"
  set {_paste-name} to url encoded "%parameter 2%"
  #You can get a list of available formats (aka syntax highlightings) here:
  #https://pastebin.com/api#5
  #This function defaults it to actionscript if not set.
  set {_paste-format} to parameter 3 ? "actionscript"

  if parameter 4 is "private":
    set {_paste-private} to 2
  else if parameter 4 is "unlisted":
    set {_paste-private} to 1
  else:
    set {_paste-private} to 0

  send "POST" request to "https://pastebin.com/api/api_post.php" with headers "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" and body uncolored "api_option=paste&&aapi_user_key={@api-user-key}&&aapi_paste_private=%{_paste-private}%&&aapi_paste_name=%{_paste-name}%&&aapi_paste_format=%{_paste-format}%&&aapi_dev_key={@api-developer-key}&&aapi_paste_code=%{_paste-code}%"

  set transient "paste-link" to last response's body
  $ access
  set {_paste-link} to transient "paste-link"
  return


command /paste <text>[|<text>][|<text>][|<text>]:
  usage: /paste <file path>|<file name>|[syntax highlight]|[public/private/unlisted]
  trigger:

    set {_paste-contents} to join file contents of arg-1 by new line
    set {_arguments::*} to arg-1, arg-2, arg-3 and arg-4

    #The first parameter is the path of the file you're gonna paste, like plugins/Skript/test.sk
    #The second one is the file name
    #The third one (optional) is the syntax highlight
    #And finally the fourth one (also optional) is if it's private, unlisted or public.
    access "pastebinPaste" from {_arguments::*}
    #As you see, the link will be saved to the variable {_paste-link}
    send {_paste-link}


command /paste-login <text>|<text>:
  usage: /paste-login <username>|<password>
  trigger:

    #The first parameter is the username you use in Pastebin.
    #The second one is the password you use in Pastebin.
    access "pastebinUserKey" from arg-1 and arg-2
    #The new generated user key will be saved to the variable {_user-key}
    send {_user-key}


EDIT: seems that an addon implemented this feature natively, it's skLib for anyone wondering. If you want use it instead of my function here are the syntaxes that it has:
code_language.skript:
[a] [new] public paste[ ][bin] [with] title[d] %string% [with] (text|body|contents) %string%

[a] [new] un[-| ]listed paste[ ][bin] [with] title[d] %string% [with] (text|body|contents) %string%
It doesn't allow user-specific pastes as you can see.

How could I change this to gist since pastebin has a annoying post limit?