• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Beta Release [Mod] WebAdmin AutoAnnouncer (JavaScript Chat Mod)

Patros

Grizzled Veteran
Apr 23, 2015
370
20
Germany
Here we go, my first "Mod". :D While modifying some WebAdmin files to show player levels and such, I was thinking about ways to make use of the admin interface. It's not very clean code, but it get's the job done and could be extended to be a bit more power- and useful.

Project: AutoAnnouncer for Chat


Link
Download link and description on GitHub
https://github.com/wookiefriseur/KF2AutoAnnouncer


Category
Mod/Plugin for WebAdminInterface

Code
Javascript, HTML

Neccessary Tools
Tampermonkey, Greasemonkey, or Standalone

Difficulty
Medium, when using Tampermonkey - has to be installed, default variables have to be changed
Medium to Advanced when customising further

Screenshots
http://imgur.com/a/MgXnP

Current Features
  • automatically post messages to your WebAdminInterface
  • keep your server ranked, no whitelist needed
  • set number of seconds the message will be posted at
  • enter multiple messages in one textarea and set a delay for each post in addition to global cooldown
  • extract variables from current site and post them to chat (advanced)
  • let the bot autorespond to certain commands
  • default commands are !help, !time, !insz (insult zeds), !insp (insult players), SC, FP (KF1 style sc and fp message), !status (current wave status in browser), !motd (current auto announce message)
  • you can change current commands (medium difficulty)
  • or add new commands and functions yourself (medium to advanced difficulty)

Known Issues
  • default values can only be saved in code (Tampermonkey/Greasemonkey), when a page is reloaded they revert back to what you set in the source code.. but the browser doesn't ever reload unless you do it
  • there may be functions without error handling, resulting in no issues at all or script crashes
  • I had to implement the delay using a freeze / sleep.. the script and UI sleep during the wait, so don't set the delay too high (max is 10 seconds atm)
  • when using FireFox there is an infopopup when you're in the wrong folder, instead of the builtin error message element with the horzine icon
  • the left hand menus in FireFox and Chrome look different and some layout is different

Possibilities for Improvement
I'm not on friendly terms with Javascript. So imagine what people who know what they're doing could accomplish. I can see map and difficulty voting, workarounds for broken map cycle and several other autoresponder features being possible. See GitHub description and code comments for more. And I didn't even hook into the API that seems to be there. I'm just too dumb, but maybe someone else isn't. ^^

Let's have some fun as long as there aren't whitelisted mutators. ;)

If you have problems with the installation or any questions I can try to help you.


Changes, current version: 0.9d (2015-10-20)
  • fixed getAllMessages and the subprocesses it depended on (they were using an old version of a process that was no longer there)
  • added autoresponder functionality (!help, !status, !insultplayer and stuff)
  • added visual indicators for parsing status of messages
  • improved some timings, JS is still not good for time critical applications
  • Fixed !status command outputting wave and zeds only, instead of players too
  • Changed to only auto announce when there are people on server (takes info from html, so it laggs a bit)
  • Fixed script crashing by being called too often when game info updates
  • Lowered reaction time of autoresponder to max 10 sec, could be lowered to max 5 if I knew how to parse received message immediately without flooding chat
  • lowered autoresponder latency down to max 5 sec, should be more useful now
  • fixed another crash issue
  • new command: !dice <sides> - rolls a dice with x sides, if no parameter is given it rolls a d6
  • new cmd: !slap <target> - slaps target with a random object, slaps everyone if no argument given
  • new cmd: !dostuff <target> - forms a random action with target, target is random also if no argument is given
  • changed commands !insz and !insp to !iz and !ip to ease access
  • reduced some console output
  • "streamlined" default messages a bit
 
Last edited:
Ok, just an info. Probably my final update for this mod, even though the mod is far from being anywhere near "final". It has most of the features I imagined it to have and I feel like that's a good point to stop. Besides that I really hate javascript now. ;)

New screenshots and a new version on github are online.

Autoresponder now works, only the last message is being read at all times. It is on by default and can be switched off with a checkbox click. Commands I implemented:

  • !help: Lists available commands
  • !time: Displays current local time chatbot is in
  • !status: Show Wave, x/6 Players and y/z Zeds
  • !motd: Posts the automessage that is currently in the textarea
  • SC: Displays a random KF1 sc comment (command is case sensitive)
  • FP: Displays a random KF1 fp comment (command is case sensitive)
  • !insultzeds: Random line from KF1 zed insults
  • !insultplayers: Random line from KF1 player insults

You can add new commands in code only and I am not planning on making an interface for it because in the end there are only a handful of useful commands that could be done and most of them would need an individual approach in coding them, like for instance mapvotes.

Known issues:
  • It can happen that messages are skipped when there is a lot of chatting going on. I was not able to set it to lower latency or else the bot would answer 10-150 times within a second and flood the chat.
  • Sometimes the bot will answer twice. That's just how it rolls.
  • The chat messages body is a bit fiddly and does scroll up and down when checkboxes or other input fields are being clicked

Even though I stop development now I'm still here to help if anyone has problems with installation or use. Or if you have an idea for another feature.

PS:
One more thing I would like to add though is a warning when the zed numbers fall below a certain threshold. Anyone know the numbers or percentage for HoE? I won't bother with grabbing difficulty from browser because that would take some work and I didn't want to continue with this project. I'll set the HoE values and for easier difficulties the warning will just be a bit early ^^
 
Upvote 0
New version: 0.9

Fixed a crash issue and improved autoresponder latency to 5 seconds max. Commands will be processed a lot faster now.
Had to fix the crash, but now that it seems to work fine I will leave the code alone for a while.

It shouldn't be that hard to implement a map change command, or with some work implement a map voting mechanism.

Tell me if you have any issues or problems with it.
 
Last edited:
Upvote 0
New version 0.9d

Just minor changes:
Streamlined some of the default info messages, added new autorespond functions to roll a dice with x sides, slap a target with a random object, and perform a random chat action with a random or custom target

See changelog of opening post for details and use !help ingame or from webadminchat using a different webadmin account to display available commands.

Have fun
 
Upvote 0
Are you kidding?! I made the same exact thing, in Javascript, came here to post it. This is what I get for not searching first... UGH

Yours seems to be better by a long shot. I need to take a look at how you got it to work in Greasemonkey, I tried that and failed because I couldn't access frames in JS.
 
Upvote 0
Nice, would love to see yours.

And mine is not very good, really. My dream was to work with classes and load all messages into an array and all that stuff, so that the bot really answers to every post. But I just didn't have the time at first and then didn't want to continue this project. Because while javascript is a very robust and nice language, I hate it and it hates me. :D

I'll gladly help you though.

PS: After I posted mine I saw that the autokick interface uses JS too, just that it's embedded in the webserver files and a new menu has been added.

I did not yet have a look at the code, but that one might be better if you look for a nice embedded solution:

http://forums.tripwireinteractive.com/showthread.php?t=112828
 
Upvote 0
voting

voting

i started tinkering with this and wondered if you had implemented a map voting functionality into this? if not do you know know of something like this that has this functionality? thanks

EDIT: the web chat keeps locking up the page and stops responding. idk what is causing it.
 
Last edited:
Upvote 0
Darkis
Ah, I scrapped it, because it was not compatible with the new webinterface anymore (the code wasn't very good anyways) and I didn't expect anyone to be interested in it anymore. Didn't have the time to improve it either.

I should have a backup in my private repository though... let's see... yeah.

Can't upload zips, js, or txt here..so I'll just pastebin the code for you:

kf2autochat.js

Readme.md

g3412
Uhh, no, I hadn't implemented map change because I didn't know how to send the command. But when I look at the code now it doesn't seem that hard anymore. I see in line 746+ of kf2autochat.js that I had some thoughts on how to do it. The change should be possible with a simple POST. The voting logic is a thing that wouldn't take much time to implement, but some time to fine tune to prevent abuse, bugs and timing problems.
 
  • Like
Reactions: Darkis
Upvote 0