That Is Right, Discord Update Automation in AWS
Recently, Troll Purse setup a public invite for the Troll Purse Discord Server. And, as with all things, we decided to test out using Discord Webhooks to push updates to our members in realtime. This is by far the most effective realtime pushing we have conceived yet. It was so easy, sharing it will be just as easy.
Using A Simple Webhook
Usually, the pattern at Troll Purse to push to third party accounts follows this pattern:
- Sign up for the third party account
- Register an application
- Find an API wrapper library for said third party account
- Publish an AWS Lambda
- Post about it!
This time, we decided to skip step 3. For the most part, the developers at Troll Purse recognized that this push would require very little data transformation and authentication routines. In fact, all of the work was done in one POST
request to the Troll Purse Discord Server.
The Code, Kind Human
public async Task<string> FunctionHandler(SNSEvent input, ILambdaContext context) { try { var messageJSONString = input.Records[0]?.Sns.Message; context?.Logger.LogLine($"Received({input.Records[0]?.Sns.MessageId}): {messageJSONString}"); if (messageJSONString != null) { var messageContent = JsonConvert.DeserializeObject<BlogContentUpdated>(messageJSONString); using (var httpClient = new HttpClient()) { string payload = $"{"content":"{messageContent.PostTitle}. {messageContent.ContentSnippet}... {messageContent.PostLink}"}"; var response = await httpClient.PostAsync(Environment.GetEnvironmentVariable("discord_webhook"), new StringContent(payloadEncoding.UTF8, "application/json")); return response.StatusCode.ToString(); } } else { return null; } } catch (Exception e) { context?.Logger.LogLine("Unable to Discord the SNS message"); context?.Logger.LogLine(e.Message); context?.Logger.LogLine(e.StackTrace); return null; } }
Notes:
BlogContentUpdated
is code defined in an external Troll Purse binary.- WE USE SECURE ENVIRONMENT VARIABLES!!! THIS IS IMPORTANT!!!! (As opposed to plaintext credentials in our source code.)
The Joy of Lambda
All of these features that Troll Purse has blogged about are done within a few hours. This is easily aided by the idea of serverless programming. There is no overhead of provisioning servers, testing different server environments, and configuring a network for these functions. It removes a lot of network infrastructure and enables Troll Purse developers to create fast, reactive, internal services.
Please, if you spend too much time configuring and setting up, try using AWS Lambda to speed up development time.
Would You Look At That
In two lines, without a library or API wrapper, our developers can now push blog updates to our Discord server. This is a nice quick feature that we plan on integrating in our automated build environment to push updates about new versions released to the public. Enjoy!
Get Eight Hours Demo
Eight Hours Demo
Hunt ghosts, banish evil, survive the night.
Status | In development |
Author | Troll Purse |
Genre | Action, Survival |
Tags | 3D, Creepy, Experimental, First-Person, Horror, paranormal, supernatural, Survival Horror, Unreal Engine |
Languages | English |
Accessibility | Subtitles, Configurable controls |
More posts
- Eight Hours & Troll Purse at Midwest Gaming Classic 2023Mar 11, 2023
- Eight Hours & Troll Purse at Midwest Gaming Classic 2022Apr 13, 2022
- Eight Hours Major Release 3.3.0Oct 12, 2021
- Full Gameplay Video (Walkthrough)Oct 12, 2021
- Refreshed Troll Purse (Eight Hours) Discord ServerOct 09, 2021
- Eight Hours 3.2.2 Released!Apr 24, 2021
- Eight Hour Tools: Night Vision CameraFeb 27, 2021
- Eight Hour Tools: Full Spectrum CameraFeb 27, 2021
- Eight Hour Tools: EVP RadioFeb 27, 2021
- Eight Hours 3.2 Released!Oct 27, 2020
Leave a comment
Log in with itch.io to leave a comment.