Earlier in the year, whilst working on Omniworlds RPG, I came across an issue on the Discord Bot where it was constantly throwing an error of
invalid item < at position 0 when trying to access a list of NPCs. On top of this, when calling the same endpoint via Insomniac, I also found that the API was limiting the response to 10 entries for some unknown reason.
After an initial search and attempt at rectifying the error on NodeJS, I decided to give up on that side and move on to the response issue and after a decent search, it was mentioned by a viewer that the potential NodeJS error was to do with
json_encode() failing silently in PHP. I applied some error handling on that function and amazingly it was throwing the following error:
Malformed UTF-8 characters, possibly incorrectly encoded!
I went back further through the code to trace back the errors cause and added
;charset=utf8” to the PDO connection string for the database calls and amazingly both issues were solved! The API was no longer limiting responses to 10 entries and the NodeJS invalid JSON error was suddenly gone. It goes to show that sometimes, there can be a silent bug in your code that you are unaware of that has a knock on effect with other parts of your code!
Since the hassle that was working with the follower event handler, I decided to move onto the raid and host event triggers despite leaving issues in the follower event. After the challenges I had just faced, I thought I had enough in the bank to be able to easily handle the upcoming code challenge. after about 15 minutes of reading and typing, I ended up with the following which compiled fine, the issue was it did not want to trigger.
private void OnRaidNotification(object sender, OnRaidNotificationArgs e)
form.WriteChat(e.RaidNotificaiton.DisplayName + ” raided!!!!!!!!”);
private void OnBeingHosted(object sender, OnBeingHostedArgs e)
form.WriteChat(e.BeingHostedNotification.Channel + ” hosted with ” + e.BeingHostedNotification.Viewers + ” viewers”);
form.AddEvent(e.BeingHostedNotification.Channel + ” hosted (” + e.BeingHostedNotification.Viewers + “)”);
form.AddEvent(e.BeingHostedNotification.HostedByChannel + ” hosted (” + e.BeingHostedNotification.Viewers + “)”);
After testing a few times to see if something is wrong (as you can see with the e.BeingHostedNotification.Channel AND e.BeingHostedNotification.HostedByChannel) to see which would work, it was time to throw in breakpoints. At least this way I would be able to tell if the issue lay with my code of with TwitchLib/Twitch… Recompiled the bot, dropped the host and… The breakpoint never triggered, I even waited a couple of minutes in case it was delayed, it was not. So there is a very likely chance that the issue lies with TwitchLib as neither trigger was fired, I decided to pop a message into the TwitchLib discord but after waiting two days, I still have no response other then “it should work”.
Last night was the first advent stream so I thought I would build the bot and give it a live test and all in all it performed as well as I had expected it to. Certain methods weren’t working, others did and it highlighted a few niggles and bugs that need to be worked on which after the stream caused me to get organised. I ended up creating a feature and bug/niggle tracker, yes I could have used Trello and/or GitHub but I felt like running it this way for now and you can see the results here:
Tomorrow I am on my first day back to work after my holiday so development and posts will slow down but it has been a good bit of progress so far!
After surpassing the challenges I previously mentioned, I started to look at populating both the viewer listbox and the events listbox. After taking a quick look at the non-existent documentation that is provided, it looked like dealing with the viewer listbox was going to be the easiest of the two to populate.
Since my last update a couple of days ago, where I learnt and overcame thread safe calls, I started to feel like I had progressed with the bot slightly. Now I am able to receive chat from Twitch, I thought it should be nice and simple to add our own chat to the screen and Twitch… Well I was kind of right.
This morning I decided that I had done enough research into TwitchLib and that it was time to have something visibly there in the project rather then a blank screen. Finally I had opened Visual Studio and started a new Windows Forms Project and after 10 minutes or so I have a (very rough) design cobbled together that can be seen below.
This week I decided it was finally time to delve into the world of C# properly, I have previously dabbled in the language but never worked on it solidly for a prolonged period of time so that I would be able to learn the system properly.
One project that I have worked on before which would help ease the transition is working on a Twitch Bot. My most recent PHP project on stream was a bot so the general logic is going to be a breeze. After all, Twitch is just an IRC protocol which is easy enough to work with and manipulate. Despite the ease, I had found a library called TwitchLib which has been made by a decent team of C# developers.
Whilst I won’t be able to stream the development of the bot due to the system limitations, I am going to use this blog to show the progress of the development as well as any challenges that I come across in the development, especially as I haven’t found any real tutorials or resources that could help.
Following on from my goals post that I put up the other day, I have decided to kick start the Android development area that I was going to look into. I used to use Java back in the day when applets were prevelent around the internet but that was so long ago I am as good as a noob when it comes to using Java. Continue reading
As some of you know, I have been working on making a couple of Android applications for a couple of side projects.