cswendrowski / HumbleBundleBot

Scrapes HumbleBundle.com for new Bundles and posts new bundles to different Discord channels or generic webhooks whenever a new Bundle shows up.
56 stars 21 forks source link

Possibilty to add a hook outside of discord #1

Closed gsabater closed 6 years ago

gsabater commented 6 years ago

Hello Cody,

I would love to use your app , but i don't want to apply for a discord hook. Instead i would love to have a hook on my own webapp to use the data.

Do you plan on implement this sometime?

Thanks

cswendrowski commented 6 years ago

Hello @gsabater and thanks for reaching out!

Would the JSON of this object be acceptable as the payload?

You can see how I consume it here: https://github.com/cswendrowski/HumbleBundleBot/blob/master/HumbleBundleServerless/Functions/DiscordMessageGenerator.cs

gsabater commented 6 years ago

hi @cswendrowski,

I'm sorry but i don't know much C to know how the payload is sent, but i can see that the message sent to discord is pretty useful.

What i meant though with another webhook is that if I try to register with a hook on my own app (eg: https://myapp.com/humble-hook), your endpoint returns 400: "Please pass in a valid Discord Webhook URL in the request body"

What i wanted to know is that if you will maybe allow for any webhook outside of discord and you could send a JSON containing information about the bundle data, and bundled games. For example:

[
    {
        "url": "http://humblenbundle.com/indie-6",
        "name": "Humble Indie Bundle 6",
        "apps": [
            {
                "appid": 440,
                "name": "Team fortress 2",
                "image": "http://humblenbundle.com/images/humble-tf2.jpg",
                "author": "Valve"
            },
            {
                "appid": 72850,
                "name": "Skyrim",
                "image": "http://humblenbundle.com/images/humble-skyrim.jpg",
                "author": "Bethesda"
            }
        ]
    }
]
cswendrowski commented 6 years ago

@gsabater With my current setup, the JSON payload you would currently get would look like so:

{
  "Bundle": {
    "Name": "Humble Indie Bundle 19",
    "URL": "https://www.humblebundle.com/games/humble-indie-bundle-19",
    "Description": "SUPERHOT, JYDGE, SOMA, and more – cross-platform, DRM-free, and on Steam!",
    "ImageUrl": "https://humblebundle.imgix.net/misc/files/hashed/632a3bceaaede04cf3d0dee88cfaa7f473cc3fb8.png?auto=compress&h=630&w=1200&s=98e4c242fff7139eceb2bee5740b605b",
    "Type": 0,
    "Sections": [
      {
        "Title": "Pay what you want!",
        "Items": [
          {
            "Name": "Halcyon 6: Lightspeed Edition"
          },
          {
            "Name": "Mini Metro"
          },
          {
            "Name": "Rakuen"
          }
        ]
      },
      {
        "Title": "Beat the Average!",
        "Items": [
          {
            "Name": "Keep Talking and Nobody Explodes"
          },
          {
            "Name": "SOMA"
          },
          {
            "Name": "Poly Bridge"
          },
          {
            "Name": "Action Henk"
          },
          {
            "Name": "JYDGE"
          }
        ]
      },
      {
        "Title": "Pay $14 or more to also unlock!",
        "Items": [
          {
            "Name": "SUPERHOT"
          },
          {
            "Name": "$2 Humble Wallet credit for Monthly subscribers"
          }
        ]
      }
    ],
    "Items": [
      {
        "Name": "Halcyon 6: Lightspeed Edition"
      },
      {
        "Name": "Mini Metro"
      },
      {
        "Name": "Rakuen"
      },
      {
        "Name": "Keep Talking and Nobody Explodes"
      },
      {
        "Name": "SOMA"
      },
      {
        "Name": "Poly Bridge"
      },
      {
        "Name": "Action Henk"
      },
      {
        "Name": "JYDGE"
      },
      {
        "Name": "SUPERHOT"
      },
      {
        "Name": "$2 Humble Wallet credit for Monthly subscribers"
      }
    ]
  },
  "IsUpdate": false
}

Updating this service to send this JSON would be fairly easy for me to do.

If there is additional data you would like captured and sent, I am happy to try and scrape it as well (I also accept PR's!). I can pull any data that is available from the bundle page's HTML

cswendrowski commented 6 years ago

@gsabater I have deployed an update that allows you to register a webhook to receive the Raw Json. I hope this helps you out - please share what you end up building with it!

I am closing this issue with this implementation - if you want to request further enhancements, please open a new issue.

Thanks!