Bot Command List HTML


#1

It would be awesome if there was a feature that would generate a basic HTML page that contains a list of all commands that are available to non-mod base level users. (possibly with the ability to show mod/subscriber commands via a dropdown)

In addition to the basic phantombot commands it could include all bot owner defined commands at the top.

The HTML/CSS would not need to be anything fancy, as ideally the bot owner would be styling it and hosting it on their own site, or pasting the results into another type of document.

Thoughts?

/Chris


#2

Check out this post:


#3

Nice! That’s a good solution for folks that want to develop their own command list printout. I like that folks are using it to expose the top 100 as well, making it into more of a leaderboard.

This just strikes me as functionality that would be of value to everyone, not just developers or people that have their bot running on a server so the API is available to other web apps. Since the bot can’t really print out all commands in chat, users need another way to see what commands are available. And with so many different bot variants floating around things can get confusing.

Otherwise users have to slowly get exposed to all the bot commands (custom or otherwise) one at a time though weeks/months of being active on a channel, which is not a great user experience. Exposing commands to the users would promote more interaction with the bot, adding to its value.

Fortunately I’m a developer, so I have the luxury of being able to take the examples you provided and run with them for rolling my own solution, even if it’s a temporary one.

Thanks!

/Chris


#4

The bot is meant to be a self-hosted solution. The control panel being a web interface is simply so it’s compatible across all devices.

I mean sure, they could include something to generate a page but then what? The users that are self-hosting won’t be able to make use of it; because they’d have to open ports to give people access to the file. And if you’re going to open ports, why not just use the api? The alternate would be they’d have to upload the generated file to a webhost every time it was updated.


#5

You can use the scripts I wrote and run them locally to produce a json file that you manually upload to your hosting. Its a resonable assmption that their hosting will run php that can read from the json and you can use the sample php snippets in the repo as well. This is what I recommend to those who dont have open ports to their bot.
Or, fork the repo and modify the output to generate full-blown HTML pages.


#6

@UsernamesSuck I was not suggesting that the bot host the command list like it does the control panel, more that it would output a static file containing its commands. Right now there is no way for bot users
(aside from the bot owner) to know what commands are available to them, so they are basically in the dark until another user teaches them. Such a list would only need to be generated when ever new commands are added, which would be infrequently for most folks once they have their bot dialed in.

@UpDownLeftDie I’m totally going to give that a shot, thanks for setting that up.

It would still be great if this were a feature that is part of the bot though, so folks don’t have to be developers or jump through hoops to get a list of commands that could be posted on their webpage, discord, etc.

/Chris


#7

I have three thoughts on this.

Thought 1:
Create a feature that dumps the commands to a text file on demand. You can do with that as you wish.

Thought 2:
Create a feature that dumps the commands in a simple HTML table on demand. You can do with that as you wish.

Thought 3:
Have the broadcaster create a dummy JavaScript file with @commandpath entries for all of their commands, along with usage, and the Perl script can be executed that PhantomBot Development runs to generate the table of all of the commands in the bot. You can do with that as you wish.

All of the thoughts could require, depending upon where the bot runs, the user to either manually upload a file to their remote server or host the file on their local server.

Thought 3 is the most complete solution in my mind. Why? Because then the broadcaster would have an HTML table of all commands in their PhantomBot – internal and custom – with usage. However, I am not sure how many people have Perl lying around, at least outside of Linux or macOS. This could mean that a different solution may need to be created. Honestly though, I’d go with Thought 3 and have the Perl script create a table to host.

Also, remember that folks can run the following commands in chat, so I feel it is disingenuous to say that there is no way to know what commands are available:

commands
[08-22-2017 @ 01:40:43.872 MDT] [CHAT] @IllusionaryBot, Current custom commands: !frogyou, !insult, !yourmom, !temp, !weather, !chill, !nasty, !lb, !testurl, !testurl2, !uptime, !followage, !playtime, !title, !game, !age, !testapi, !test2, !testjson, !randfile, !lastfm, !ytapi, !cd, !goal, !tapi, !redeemtwitter, !test, !so, !8ballme, !banana, !purgeuser, !line1, !line2, !testencode, !destiny, !callpoints, !testcmd, !sr, !k, !ku, !l, !purge, !addpoints, !addio, !scare, !addpts, !drumroll, !play
[08-22-2017 @ 01:40:44.246 MDT] [CHAT] @IllusionaryBot, Current custom commands: !group, !grouppoints, !groups, !ahook, !primary, !all, !abuse, !things, !goodgood, !twothings, !bothlines

botcommands
[08-22-2017 @ 01:40:56.513 MDT] [CHAT] @IllusionaryBot, Commands: !chat, !module, !reconnect, !lang, !mute, !toggleme, !log, !togglewhispermode, !permit, !moderation, !mod, !blacklist, !whitelist, !coolcom, !cooldown, !globalcooldown, !toggleglobalcooldown, !togglemodcooldown, !group, !grouppoints, !users, !time, !streamertime, !timezone, !top5, !top5time, !multi, !lastseen, !online, !viewers, !game, !title, !rigged, !dj, !shia, !frogyou, !test2, !insult, !testtags, !yourmom, !temp, !weather
[08-22-2017 @ 01:40:56.889 MDT] [CHAT] @IllusionaryBot, Total Pages: 9 [See also: https://phantombot.tv/commands]

Also note that !botcommands and !commands examines the group of the user running the command list and hides commands that they cannot run based on permissions. No, it isn’t a web page, but there are ways to get the list of commands.


#8

Option 1 has already has a similar implementation, contained in this post there is a Javascript file that will dump commands/points/time to a sub-folder. Also contains the source for a Go-lang program that’ll host the files so they’re view able (you’d have to compile the Go-lang program yourself, or make your own alternative in whatever language).


#9

@UpDownLeftDie Your setup is working pretty good, and should help get me started. Thanks for your work on that!

I did notice that in phantombot-cron.php the sorting for commands does not seem to work properly. line 27: arsort($commands); When the JSON for the commands is output, the commands are not in order. I also tried asort and, and changing that does change the order a bit, but as you might expect.

For example, I changed it to asort, since I want commands to list in alphabetical order. When I do that, the first command listed in the JSON is “age” but the command “about” should be before that. The order I’m seeing is age, followage, uptime, playtime, game, etc. Clearly not in arsort or asort order.

When I switch between asort and arsort the order does appear to reverse, but it’s just not alphabetical for some reason.

Any thoughts on that?

I could always sort the JSON data when I implement it, but I figured you would want the data sorted since you had arsort there.

/Chris


#10

Now that I’m parsing the JSON file into a list it’s a bit more clear what the sorting issue is. It seems to be sorting commands based on their values, rather than their keys (the command names) and the value sorting is case sensitive so even those don’t end up alphabetical.


#11

If you can, please submit bugs as issues on github.

I’ve been meaning update all these commands for a few weeks now, ill look at the sorting issue then, but if you want to sort by keys then it would be ksort().
If you want to do case-insenitive sorting then it might be the combination of uksort() and strcasecmp()


#12

Thanks, I’ll be sure and post on github in the future. Using ksort() gave the result I was after. All commands listed alphabetically by command name. Since command names are all lower case that works great.

Thanks again, this does just what I’m after. Now I just need to automate the running of phantombot-cron.php, which may take a bit of work since I’m running the bot on a computer that is not running a webserver other than phantombot’s.


#13

If you’re on Linux or mac os you can still use cron.
If you’re on windows you can setup a scheduled task.
If you need to upload the output files you could probably write a .sh or .bat (Unix and Windows respectively) that uploads via some kind of FTP cli.


#14

The automation side of things should not be too difficult.

But since phantombot-cron.php needs a web server to run, that’s currently the challenge. Since my install of Phantombot is not visible to the outside world, I can’t run phantombot-cron.php on the webserver I host my site on, as it would not be able to communicate with the bot. So I I need to run it locally as I’m doing now.

In this case I’m running Phantombot (and anything related to this process) on a Windows machine.

For testing all this I’ve been using OSX, so spinning up a webserver to run phantombot-cron.php is as simple as opening a terminal, navigating to the desired folder and running “php -S localhost:8000”

Ideally I would like a 1 click solution on Windows that runs phantombot-cron.php and uploads the resulting JSON files. Or even better, some way to schedule it so I don’t have to remember to update things manually.


#15

Right, that’s what I was referring to using a script file.

Write a .bat script that runs php to generate the files and then call some ftp CLI that uploads the files.
You can 1-click this or add it as a Scheduled Task


#16

Right now a Beta Test is going on for a service that will do this as well. The bot sends the command data over to the service and it renders screens for folks.


#17

The Beta is now live for the Data Rendering Service.

This includes custom commands, points, time, and quotes. While it doesn’t include the PhantomBot commands, that is already hosted on a site and could be linked to.