Posted February 14, 2021 (edited) Halo 1 (PC/CE) Discord Bot (for SAPP servers) A Discord bot framework built using the Discordia API and Luvit runtime environment. - features - 1). Easily connect one (or more) Halo servers to a Discord server. -- 2). Sends a message to your Discord server when the following events are fired: Event Description ----- ------------------------ * event_join Player connected to the server. * event_quit Player disconnected from the server. * event_game_start A new game starts (shows map & mode). * event_game_end The current game ends (and shows who won). * event_chat Chat messages sent to defined global-channel. * event_score Message sent when player scores. * event_command Command logs sent to defined command-log channel. * event_death killed by the server, squashed by a vehicle, run over, betrayal, PVP, suicide, zombie-infect, first blood, guardians, killed from the grave, unknown. [note] The bot will ignore commands containing sensitive information (namely passwords). -- 3). Two-way chat integration - Send messages directory to the Halo server from Discord (and visa versa): Halo to Discord (as seen on Discord): [CHAT] Chalwk: This is epic! Discord to halo (as seen in-game): [Discord] Chalwk: This is epic! -- 4). The bot will feedback on the name of the winning player (or team) on Discord after each game. -- 5). The bot will automatically create and periodically edit an embedded status message. The embed will include the current map, mode, game type, player names and more. -- 6). Chat integration whitelist: Only users who have a specific role will be able to send messages to Halo from Discord. =========================================== FULL INSTALLATION INSTRUCTIONS AND UPDATES: DOWNLOAD PAGE Current version: 1.0.23 =========================================== Edited March 8, 2022 by Chalwk aLTis, Enclusion, Kavawuvi and 4 others like this - I invite you to join my Halo Discord Server. - Add me on discord: Chalwk#9284 - HSP Repo Wiki (new) Share this post Link to post Share on other sites
Posted February 14, 2021 Good work! I haven't read the whole release page yet so sorry if this is covered but is it possible to use webhooks for those who don't need a full bot but just want to post to a channel? Share this post Link to post Share on other sites
Posted February 14, 2021 (edited) 12 minutes ago, Enclusion said: Good work! I haven't read the whole release page yet so sorry if this is covered but is it possible to use webhooks for those who don't need a full bot but just want to post to a channel? Yes, it is. See the following docs: webhooks and D-API W/Hooks For additional support I recommend joining the Discordia discord server: https://discord.gg/discord-api Edited February 14, 2021 by Chalwk Enclusion likes this - I invite you to join my Halo Discord Server. - Add me on discord: Chalwk#9284 - HSP Repo Wiki (new) Share this post Link to post Share on other sites
Posted February 14, 2021 Awesome dude! It would be awesome if you could add more of the information from your Git to the OP. I'll add ya to the shortlist! Enclusion likes this Oddly, this is familiar to you... as if from an old dream. Share this post Link to post Share on other sites
Posted February 14, 2021 (edited) On 2/14/2021 at 3:26 PM, Enclusion said: Good work! I haven't read the whole release page yet so sorry if this is covered but is it possible to use webhooks for those who don't need a full bot but just want to post to a channel? Webhooks use an array of embed objects called embeds. Here is a functional example of a practical webhook fetch using embeds. local function WhoWon() local str = "No Winner" local r_score = get_var(0, "$redscore") local b_score = get_var(0, "$bluescore") if (r_score > b_score) then str = "Red Team won!" elseif (b_score > r_score) then str = "Blue Team won!" elseif (b_score == r_score) then str = "IT WAS A TIE!" end return str end -- Note that you don't need to coroutine-wrap if you're executing the webhook in a discordia event since they're already in a coroutine -- Make a GET request to your Webhook URL and fetch the ID and Token from it using JSON. client._api:executeWebhook(id, token, { embeds = { { title = "Game Over", description = WhoWon() }, { title = "New Game Started", description = get_var(0, "$map") .. " - " .. get_var(0, "$mode") } } }) Edited February 15, 2021 by Chalwk Enclusion likes this - I invite you to join my Halo Discord Server. - Add me on discord: Chalwk#9284 - HSP Repo Wiki (new) Share this post Link to post Share on other sites
Posted February 15, 2021 I am rather annoyed because I really wanted to implement a function that periodically updates a defined channel's topic with a live player count. For example 1/5000 players online | 1000 unique players ever joined | Server online for 2130 minutes | Last update: Tue, 16. Feb 2021 09:21:44 NZDT It turns out that the Discord API has a hardcoded rate limit for channel name and topic updates of 2 per 10 minutes. This time frame is too long to make this functionality practical. So, instead of a live player count, I could instead implement something like a MOTD, or output the current MVP of the day. Thoughts? Enclusion likes this - I invite you to join my Halo Discord Server. - Add me on discord: Chalwk#9284 - HSP Repo Wiki (new) Share this post Link to post Share on other sites
Posted February 15, 2021 That's really lame. I know Discord's rate limits are a pain; we hardly deal with their dynamic limit for the Discord web viewer on the sidebar ..so it's often 30 minutes behind because we got temp blocked for trying to refresh every 5 or 10 minutes. That rant over.. I'd personally prefer seeing MVP of the day up there. Small bragging right for some people and thus incentive for the server. I've never seen a server with a useful MoTD. Chalwk and Enclusion like this Oddly, this is familiar to you... as if from an old dream. Share this post Link to post Share on other sites
Posted February 20, 2021 (edited) A handful of bugs have been reported since releasing this project and will be fixed in an upcoming release so stay tuned. Notable issues: Inbound text messages from Discord occasionally fail to reach their destination (the halo server). Names containing certain special characters can result in the client returning an Error 400 message. Edited February 21, 2021 by Chalwk Enclusion, mouseboyx and Takka like this - I invite you to join my Halo Discord Server. - Add me on discord: Chalwk#9284 - HSP Repo Wiki (new) Share this post Link to post Share on other sites
Posted February 22, 2021 (edited) On 2/20/2021 at 2:09 PM, Chalwk said: A handful of bugs have been reported since releasing this project and will be fixed in an upcoming release so stay tuned. Notable issues: Inbound text messages from Discord occasionally fail to reach their destination (the halo server). Names containing certain special characters can result in the client returning an Error 400 message. I was having issues with halo names with special characters for the web stats. I've used these two lua functions, I can't remember where I found them, probably stackoverflow. function encodeChar(chr) return string.format("%%%X",string.byte(chr)) end function encodeString(str) local output, t = string.gsub(str,"[^%w]",encodeChar) return output end It works without a hitch when encoding something to be used in a query string like "http://mouseboyx.xyz/halo-stats/halo.php?exampleName="..encodeString(nameWithSpecialChars) Discordia is already doing a url encode for making an http get request, but I was looking at the discordia dependencies and how it makes http post requests to send messages to discord. I couldn't find whether it was actually url encoding post data that is sent out, so it may be worth checking out. It definitely is doing a json encode though, that I know for sure. If discordia already is url encoding post requests then using this function might be even worse because it will be double encoded and might produce some strange effects. Edit: Nevermind disregard this post I thought that the post request was being sent as "application/x-www-form-urlencoded" but it's being sent as "Content-Type: application/json" which work differently. Edited February 22, 2021 by mouseboyx Disregard Share this post Link to post Share on other sites
Posted March 16, 2021 (edited) The original post has been edited to include a description of the various features. Also, this Discord Bot was updated today (at 10:12 AM NZST) with a couple of minor bug fixes and tweaks. If anyone is interested in seeing this bot in action, I invite you to join my Halo: CE / Minecraft network (JeriCraft): https://discord.gg/mEjbFJWpe5 Edited March 17, 2021 by Chalwk AntiMomentum, Enclusion and Takka like this - I invite you to join my Halo Discord Server. - Add me on discord: Chalwk#9284 - HSP Repo Wiki (new) Share this post Link to post Share on other sites