Git Product home page Git Product logo

sb-slash's Introduction

sb-slash

Retrieve SponsorBlock segments and user info with slash commands, buttons and message commands.

Invite

slash commands

# users
/userinfo publicid: user:
/showoff publicid:
/userstats publicid: sort:
/userid username: exact:

# segments
/skipsegments videoid: categories: json:
/segmentinfo segmentid:
/lockcategories videoid:
/searchsegments videoid:
/status
/responsetime

# /me
userid set / get
userinfo
showoff
userstats

# /automod
get
share videoid:
info
acceptterms

# /vip
category uuid: category:
cache videoid:
purge videoid:
downvote uuid:
undovote uuid:
addvip userID: videoID:
banstatus publicid:

# misc
/formatunsubmitted binid:
/shareunsubmitted binid: videoid:
/previewvideo videoid: spots:
/invite
/github

more details here

  • Mass stat related commands were not included
  • Anonymous lookup was not included
  • Most commands can have their response be ephemeral by setting the hide parameter to true

Cloudflare Environment Variables (Handling Interactions)

CLIENT_ID - Client ID from bot portal
CLIENT_PUBLIC_KEY - Public Key from bot portal
LOGGING_WEBHOOK - Webhook URL for VIP logging
VIP_USER_ID - Private userID for VIP commands
ML_AUTH - sb-ml auth token
VIP_NONCE - nonce to check VIP users against

Local Environment Variables (Populating slash commands & options)

CLIENT_ID - Client ID from bot portal
BOT_TOKEN - Bot Token from bot portal
CLIENT_PUBLIC_KEY - Public key from bot portal

PR Testing

If you would like to test your PR on a dev environment, please contact me on discord and I can give you access to the private testing repository

Credit

API follows CC BY-NC-SA 4.0 Documentation at wiki.sponsor.ajay.app

utilities from MRuy/sponsorBlockControl

Logo from ajayyy/SponsorBlock, created by @munadikieh

Formatting and Links from Lartza/SBbrowser

sb-slash's People

Contributors

awesomenessz avatar caneleex avatar dependabot[bot] avatar mchangrh avatar mini-bomba avatar risedsky avatar roki100 avatar thejzoli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sb-slash's Issues

ShareUnsubmitted links don't work correctly when pasted into Discord

I used /shareunsubmitted and it generated this URL:

https://www.youtube.com/watch?v=56J0wOTll5c#segments=[%7B%22segment%22:[0,7.947],%22category%22:%22intro%22,%22actionType%22:%22skip%22%7D]

When this link is pasted into a discord channel, notice the white un-linked ] on the end:

image

Without that bracket, clicking the link doesn't correctly load the segment. This can be resolved in general without damaging the URL by appending an ampersand:

https://www.youtube.com/watch?v=56J0wOTll5c#segments=[%7B%22segment%22:[0,7.947],%22category%22:%22intro%22,%22actionType%22:%22skip%22%7D]&

So the bot should probably automatically add the & so that when it's pasted in discord it works correctly when clicked. It's easy to miss the white ]

Demo here: https://discord.com/channels/603643120093233162/603643205552177155/1014877479548227614

Lookup Segments message-command doesn't return all segments

Looks like the current implementation of the Lookup Segments message-command uses getSkipSegments(), which returns a random non-ignored segment in case of overlapping segments with the same category (basically the same as the extension).

I think using getSearchSegments() instead to show all segment versions would prove useful in situations like requests in the #incorrect-submissions channel, where there may be multiple versions of the same segment, some incorrect.
The implementation could just be copied from commands/searchsegments.js

VIP utils

  • purgeSegments (purge)
  • clearCache (clearcache)
  • changeCategory (category)
  • downvote (downvote)
  • undoVote (undovote)
  • addTempVIP (addvip)

logging

  • downvote and undoVote attributed to user.

username#discriminator
downvote/undovote | UUID

example:

blabdude#9793
downvote | 8..6

The bot ignores text messages

I'm trying to use the bot, but it doesn't give me commands to use

image

Since I can't send messages of type body.type == InteractionType.APPLICATION_COMMAND for some reason, the bot completely ignores me when I try to use commands.

The issue starts at the bottom of this code

// Process a Discord interaction POST request
const handleInteraction = async ({ request, wait }) => {
  // Get the body as a buffer and as text
  const bodyBuffer = await request.arrayBuffer();
  const bodyText = (new TextDecoder("utf-8")).decode(bodyBuffer);

  // Verify a legitimate request
  if (!handleInteractionVerification(request, bodyBuffer))
    return new Response(null, { status: 401 });

  // Work with JSON body going forward
  const body = JSON.parse(bodyText);

  // Handle a PING
  if (body.type === InteractionType.PING)
    return jsonResponse({
      type: InteractionResponseType.PONG
    });
  try {
    if (body.type == InteractionType.APPLICATION_COMMAND) { // handle commands

Wrong regex

const isValidUserUUID = (str) => /^[a-f0-9]{64}$/.test(str);

Here, we have a regex that don't catch the userID in the command /userinfo :
image

image


Replacing with this work :
[a-f0-9]{64}
image

chapters support

  • add chapters type
  • add chapters category

commands

  • lockCategories
  • lockReason
  • searchSegments
  • segmentInfo
  • userStats (changes downstream)

downstream

  • sb-category-type
  • port matrix
  • wiki
  • openAPI

[FEAT] /convertlinks

convert all strictly youtube links to sb.ltn.fi links & remove any additional parameters for a message

Fix Nan%

if 0 segments, return 0% instead of NaN%

Lookup buttons give errors

As shown below whenever I click on either button "Lookup Last Submission" or "Lookup User" it results in an error. (Not tested on official sb server)
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.