Discuss Scratch

BGMead
Scratcher
1000+ posts

AutoUOC Testing & Discussion

WE'VE MOVED THREADS
See this for the latest info.

Banner by GrahamSH
AutoUOC
Official Testing & Discussion Topic


Heyo! My name is BGMead and I'm the dev behind AutoUOC, a work-in-progress website that will make shop management extremely easy with an auto-updating Unclaimed Orders Center, or UOC for short! I got the idea for the it when I was messing around with HTTP POST requests and decided to see if I could write some code which posted to the Scratch forums and comments, and it worked! Sadly, the ST is too cool for bots I guess, so now we're website-only.

Current Status
Updated Sep. 10, 2020
The API can currently: post comments, forum posts, edit posts (untested), get message counts, and get forum data.
Starting work on the main website.

How to Contribute
Simply make a pull request on any of the GitHub repos linked below! All contributions are welcomed. If you don't know how to code, opening an issue is just as wonderful. If you don't have a GitHub account, you can leave any issues or feature requests in this thread as well.


FAQ
How can I add the it to my shop?
It is still under development and not available to the public yet, sorry. Beta applications should be open soon though - follow the thread for more info!

Can I use the API for my own project?
Technically yes since it's open sourced, but you'll need to have a good idea of what you're doing since the auth stuff is not available to the public.

Will you ever make the API available to the public?
No, never. Releasing this could lead to a lot of abuse.

How will it work?
Shop owners will have to sign up on the website to then add their shop. On the shop dashboard, they can edit the style of the UOC post. The site will look for orders and display them when necessary.

Has the ST approved this?
See this post.

Do I need to enter my Scratch password?
No, AutoUOC will never ask for your Scratch password and you won't need to enter it ever. You will need a separate AutoUOC password (different than your Scratch password).

Last edited by BGMead (July 11, 2021 00:57:07)

BGMead
Scratcher
1000+ posts

AutoUOC Testing & Discussion

AutoUOC Needs Your Help!


We need to gather as many posts from shops as possible! We need three categories of posts:
  • New shop orders
  • Employees taking orders
  • Employees completing orders

What to do
  1. Make three text files, one for each category above
  2. Find a post that meets any of the categories above
  3. Click the post time stamp (Example: Today 19:27:33)
  4. Copy the little number at the end of the URL you were sent to (this is the post ID) and paste it into the text document!
  5. Use a site like pastebin.com to paste the text docs!
  6. Post the links here!

CLICK HERE FOR AN EXAMPLE

Thanks for the help!

Last edited by BGMead (Aug. 29, 2020 02:44:12)

Pufferfish_Test
Scratcher
500+ posts

AutoUOC Testing & Discussion

This looks really great! I've just forked the repo and am working on the post api. I'll make a pull request when I'm done.
However, this won't be testable until you get alproval from the ST, will it?
BGMead
Scratcher
1000+ posts

AutoUOC Testing & Discussion

Pufferfish_Test wrote:

This looks really great! I've just forked the repo and am working on the post api. I'll make a pull request when I'm done.
However, this won't be testable until you get alproval from the ST, will it?
I think it should be fine for now. I was testing comments and it was working just fine.
BGMead
Scratcher
1000+ posts

AutoUOC Testing & Discussion

Ok, I made a neat discovery. Turns out the CSRF token is stored with the cookie. Only one issue - the token updates every 24 hours or so. We're going to need something that keeps the token up to date - perhaps a browser extension that POSTs to the website?

Last edited by BGMead (Aug. 25, 2020 14:33:34)

BGMead
Scratcher
1000+ posts

AutoUOC Testing & Discussion

AutoUOC wrote:

Hello! This is a test post. If you are seeing this, it means the forum post API endpoint is working!
Ayyyyy!!!! Post is working!
BGMead
Scratcher
1000+ posts

AutoUOC Testing & Discussion

Shoot, I forgot that new Scratchers can't edit posts lol. The edit endpoint should be the same as the post endpoint though so we should be ok.
Nambaseking01
Scratcher
1000+ posts

AutoUOC Testing & Discussion

This is definitely a very interesting project! I'll keep following the discussion and remain in touch to see how well everything goes - I'll definitely try to include the system in my shop when it launches.
BGMead
Scratcher
1000+ posts

AutoUOC Testing & Discussion

Nambaseking01 wrote:

This is definitely a very interesting project! I'll keep following the discussion and remain in touch to see how well everything goes - I'll definitely try to include the system in my shop when it launches.
Awesome, thanks! Beta should be rolling out very soon actually, since development is going a lot smoother than expected!
Nambaseking01
Scratcher
1000+ posts

AutoUOC Testing & Discussion

BGMead wrote:

Nambaseking01 wrote:

This is definitely a very interesting project! I'll keep following the discussion and remain in touch to see how well everything goes - I'll definitely try to include the system in my shop when it launches.
Awesome, thanks! Beta should be rolling out very soon actually, since development is going a lot smoother than expected!

I have a question though: will it also be possible to have one UOC post and have this bot constantly update it with orders? Because my shop works differently from TIPS and we don't repost the UOC on every single page.
BGMead
Scratcher
1000+ posts

AutoUOC Testing & Discussion

Nambaseking01 wrote:

BGMead wrote:

Nambaseking01 wrote:

This is definitely a very interesting project! I'll keep following the discussion and remain in touch to see how well everything goes - I'll definitely try to include the system in my shop when it launches.
Awesome, thanks! Beta should be rolling out very soon actually, since development is going a lot smoother than expected!
I have a question though: will it also be possible to have one UOC post and have this bot constantly update it with orders? Because my shop works differently from TIPS and we don't repost the UOC on every single page.
Yep, the default behavior is to make one post that you can style with BBCode on the website. The bot will then auto-update it with orders. If we constantly reposted we'd hit the 60-sec rule all the time since the bot runs in multiple shops.

EDIT: I just found a session and messages endpoint that can be used to update the CSRF token!

Last edited by BGMead (Aug. 25, 2020 15:17:14)

Nambaseking01
Scratcher
1000+ posts

AutoUOC Testing & Discussion

BGMead wrote:

Yep, the default behavior is to make one post that you can style with BBCode on the website. The bot will then auto-update it with orders. If we constantly reposted we'd hit the 60-sec rule all the time since the bot runs in multiple shops.

Hm, OK, that's convenient. But that does mean that TIPS can't use this bot though
BGMead
Scratcher
1000+ posts

AutoUOC Testing & Discussion

Nambaseking01 wrote:

BGMead wrote:

Yep, the default behavior is to make one post that you can style with BBCode on the website. The bot will then auto-update it with orders. If we constantly reposted we'd hit the 60-sec rule all the time since the bot runs in multiple shops.
Hm, OK, that's convenient. But that does mean that TIPS can't use this bot though
Lol yeah. I may add it later as an optional feature but I don't see it happening too soon.
BGMead
Scratcher
1000+ posts

AutoUOC Testing & Discussion

The official bot repo has been created: https://github.com/BreMea/AutoUOC
_nix
Scratcher
1000+ posts

AutoUOC Testing & Discussion

BGMead wrote:

Ok, I made a neat discovery. Turns out the CSRF token is stored with the cookie. Only one issue - the token updates every 24 hours or so. We're going to need something that keeps the token up to date - perhaps a browser extension that POSTs to the website?
assuming the csrf token changes but the session id stays the same (which i think is a fair assumption, since otherwise how else do you stay logged in on the site every day ) maybe you could periodically (as well as when running into authorization errors) request to scratch.mit.edu/csrf_token/ and read the cookie set there? no need for post requests or browser extensions then, assuming your code has access to a session id!

….
….that said im just remembering that i dont think the CSRF token is actually necessary at all. test your code and see if it works when you set the header X-CSRFToken=a (or the cookie scratchcsrftoken=a) – i feel like i remember that working in the past without issue. if thats still the case, you can just skip dealing with csrf tokens at all.

edit: btw, this is a really neat project idea and im excited to see where it goes :0
edit 2: im just going to drop a link to my api docs if you havent seen them already, because they could come in handy! im pretty experienced with api stuff so if theres anything youre stumped trying to figure out please feel free to poke me!

Last edited by _nix (Aug. 25, 2020 15:39:35)

BGMead
Scratcher
1000+ posts

AutoUOC Testing & Discussion

_nix wrote:

BGMead wrote:

Ok, I made a neat discovery. Turns out the CSRF token is stored with the cookie. Only one issue - the token updates every 24 hours or so. We're going to need something that keeps the token up to date - perhaps a browser extension that POSTs to the website?
assuming the csrf token changes but the session id stays the same (which i think is a fair assumption, since otherwise how else do you stay logged in on the site every day ) maybe you could periodically (as well as when running into authorization errors) request to scratch.mit.edu/csrf_token/ and read the cookie set there? no need for post requests or browser extensions then, assuming your code has access to a session id!

….
….that said im just remembering that i dont think the CSRF token is actually necessary at all. test your code and see if it works when you set the header X-CSRFToken=a (or the cookie scratchcsrftoken=a) – i feel like i remember that working in the past without issue. if thats still the case, you can just skip dealing with csrf tokens at all.

edit: btw, this is a really neat project idea and im excited to see where it goes :0
edit 2: im just going to drop a link to my api docs if you havent seen them already, because they could come in handy! im pretty experienced with api stuff so if theres anything youre stumped trying to figure out please feel free to poke me!
Epic, thanks so much! I opened this issue an hour ago trying to resolve the issue. I'll try your workaround.
BGMead
Scratcher
1000+ posts

AutoUOC Testing & Discussion

BGMead wrote:

_nix wrote:

BGMead wrote:

Ok, I made a neat discovery. Turns out the CSRF token is stored with the cookie. Only one issue - the token updates every 24 hours or so. We're going to need something that keeps the token up to date - perhaps a browser extension that POSTs to the website?
assuming the csrf token changes but the session id stays the same (which i think is a fair assumption, since otherwise how else do you stay logged in on the site every day ) maybe you could periodically (as well as when running into authorization errors) request to scratch.mit.edu/csrf_token/ and read the cookie set there? no need for post requests or browser extensions then, assuming your code has access to a session id!

….
….that said im just remembering that i dont think the CSRF token is actually necessary at all. test your code and see if it works when you set the header X-CSRFToken=a (or the cookie scratchcsrftoken=a) – i feel like i remember that working in the past without issue. if thats still the case, you can just skip dealing with csrf tokens at all.

edit: btw, this is a really neat project idea and im excited to see where it goes :0
edit 2: im just going to drop a link to my api docs if you havent seen them already, because they could come in handy! im pretty experienced with api stuff so if theres anything youre stumped trying to figure out please feel free to poke me!
Epic, thanks so much! I opened this issue an hour ago trying to resolve the issue. I'll try your workaround.
Did some testing and it turns out “a” does work! Thanks for the workaround!
BGMead
Scratcher
1000+ posts

AutoUOC Testing & Discussion

If anyone has any suggestions as to how fetch new posts, let me know! Here's my solution:

- Follow the threads of shops that use AutoUOC
- Periodically check bot message count
- If message count > 0, then fetch https://api-scratch-mit-edu.ezproxy.canberra.edu.au/users/AutoUOC/messages
- Filter results for messages that are unread and in forum posts
- Fetch the new posts in that thread with an external API like ScratchDB
- Do bot stuff
Nambaseking01
Scratcher
1000+ posts

AutoUOC Testing & Discussion

Also, do you think I should make a pull request to implement issue templates? It's a thing I do to a couple of repositories just so it's more convenient for the issue-makers - I'll set up a basic template and you can edit it as much as you like
BGMead
Scratcher
1000+ posts

AutoUOC Testing & Discussion

Nambaseking01 wrote:

Also, do you think I should make a pull request to implement issue templates? It's a thing I do to a couple of repositories just so it's more convenient for the issue-makers - I'll set up a basic template and you can edit it as much as you like
Sure thing, that'd be great

Powered by DjangoBB