Jump to content
Sign in to follow this  
  • entries
    5
  • comments
    3
  • views
    1241

General That Is Right, Discord Update Automation in AWS

Martin H Hollstein

877 views

 

Originally posted on Troll Purse Dev Blog

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.

Discord Logo

Using A Simple Webhook

Usually, the pattern at Troll Purse to push to third party accounts follows this pattern:

  1. Sign up for the third party account
  2. Register an application
  3. Find an API wrapper library for said third party account
  4. Publish an AWS Lambda
  5. 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!

Originally posted on Troll Purse Dev Blog



0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Advertisement
  • Blog Entries

  • Similar Content

    • By pseudomarvin
      I want to distributy a game I've made as a simple self extracting zip file. After extraction, the structure should look like this:
      MyGame (shortcut to MyGame/Release/MyGame.exe) MyGame (folder)  --- /assets (folder) --- / Release (folder)       --- MyGame.exe I have already managed to make the shortcut point to the relative path of MyGame.exe by setting its target as: %windir%\explorer.exe "MyGame\Release\MyGame.exe". But I would also like to set its icon from a file in the assets folder in a relative way so that upon extracting on a different PC,
      the icon is already set. Is this possible? Or how is it usually done?
    • By Yoshirouuu
      I don’t know if I’m allowed ask this, so direct me to the right forum if I’m wrong please! I have an lcvp class and we need to interview someone in the line of work we want to go into, so I have some questions if anyone would like to answer :)
      My discord is @Yoshirouuu#7378 if you can’t answer here.
      What studio do you work for? What is the starting Salary?  What do you enjoy about the job? What are the working hours? Is there much overtime? How much are you paid for overtime? What games have you worked on? What do you dislike about your job? What type of work is involved? What happens in a typical day? How did you get the job? (College course, Qualifications etc) When you got your job did you have to learn anything? (Programming language, applications?) Is there many opportunities for promotions?  What days do you work? How many holidays are you allowed? Is there opportunity for travel in your job? Are there specific rules in your job? (Uniform?) What other areas/studios do you work with? Do you deal with public often? What is your favourite part about working on a game? Does your job have any benefits? Is there ever any conflicts or arguments? Were you able to make friends quickly? Thanks very much!
    • By dandoherty94
      Hi all,
      I'm looking for a career change as the job that i currently do is neither a passion or something that i really want to be doing for the rest of my life. I would ideally like to begin a career in the gaming industry as like most others i have a strong passion for gaming and all things related. I have been looking into a junior test analyst QA job and was wondering if this is the correct place to start. I'm a dedicated worker so don't mind working my way up and I love being hands on with things. I was wondering if anyone had any advice regarding this or how i can go about gaining experience in this field to give myself the best chance. I'm more than willing to do either weekend work or free work to get my foot in the door so if there is any advice or help anyone could give me that would be great. 
      Thanks for reading,
      Dan 
    • By Adeilton Alves
      Hello everyone, I'm new here and sorry if this isn't the right place to ask but i asked in a few forums around the internet and no one yet help with it.. I'm have been trying to mod this game for years, but I still stuck with the raw files from RACJIN games, 
      Raw Files [ Mod edit: Removed ]
      I would like to identify the compression algorithm used to compress these files so that they can be decompressed and analyzed.

      Game : Naruto Uzumaki Chronicles 2... A.K.A Naruto Konoha Spirits in Japan.
    • By MakeIndieGreatAgain
      Game developers will be able to become pioneers in the development of decentralized games for the gambling industry using DAO.Casino protocol.
      On September 17, 2018, DAO.Casino is opening Sandbox for developers, independent teams and game development studios that choose to harness the power of the rapidly developing DApp industry.
      Starting today everyone may submit their application for Sandbox on the official Sandbox page.
      The Sandbox project is designed by DAO.Casino developers. Participants of Sandbox will learn the basics of decentralized applications development on DAO.Casino protocol. Developers participating in Sandbox will learn to create, design and deploy decentralized games and applications on Ethereum blockchain.
      DAO.Casino is planning to reward most active developers for their constructive feedback on the improvement and optimization of the SDK and related documentation. The company will separately announce the details of the rewards program later this fall.
      “We are confident that the Sandbox project will play an important role in our collaboration with studios and independent game developers. We cannot wait to see our product helping developers unleash their creative and entrepreneurial talents and apply those to one of the most groundbreaking technologies of the XXI century. — states Ilya Tarutov, CEO, DAO.Casino. – I am sure that the products we’re developing will transform the online gambling into a fair and transparent industry for all of the involved parties: casino operators, developers, and affiliate marketers. “
      “We are launching the Sandbox with the goal of enabling as many developers as possible to learn to create decentralized games. We have achieved an important milestone by starting to accept applications from developers all around the world who share our idea to make online gambling fair and transparent. With our technology, developers can take the whole gambling industry to the next level” – says Alexandra Fetisova from DAO.Casino.
      DAO.Casino is disrupting the online gambling industry by developing the protocol based on Ethereum blockchain technology. The protocol ensures the automation of transactions and facilitates interactions between all the industry participants: casino operators, game developers, and affiliate marketers. DAO.Casino team is fully dedicated to developing the best products and making the gambling industry a better place.

      View full story
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!