WEBUI_MODULE brainstorming

If you have created a 3rd party module you'd like other people to use, post it here
nagahiro
Member
Posts: 41
Joined: Mon Oct 03, 2011 6:42 pm
antispam: Rimor

WEBUI_MODULE brainstorming

Postby nagahiro » Tue Nov 22, 2011 10:12 pm

I saw this idea mentioned in other threads but there doesn't seem to be a thread for it yet. Since I intend to make this my first real project this is a dedicated thread for it, finally.

The basic idea: Create an addon for Budabot that equips the user with everything needed to access their bot via a web ui. This means primarily the ui itself and a rudimentary webserver. For the server I'm thinking about packaging xampp for windoze users and providing some basic shell scripts for linux people. I don't know squat about MacOS so yall are SOL unless someone steps up on your behalf :)

The UI is divided into 3 basic components each of which has a variety of features and sub-features:
1. Login

2. Bot Admin

+Bot Overview
--Status
--Error Logs
--Online Stats
--Basic Controls
----Start
----Stop
----Restart

+Member Admin
--Add/Remove Members (non-guildbot only)
--Add/Remove Guests

+Mod Admin
--Add/Remove Moderators

+Modules Admin
--Activate/Deactivate Modules
--Change module minimum access levels
--Module Installer

+Console

3. User Admin
+Alts Management

Budabot already offers all of this functionality, with exception of the Login functionality. The login is achieved quite easy, simply add a command !password to WEBUI_MODULE that allows users to define a password associated with their defined main (which acts as the username). Users without a defined password cannot login and the admin PW is hard-coded via an install script.

Questions for users: What am I missing? Any other functionality you would like to see for this?

Questions for devs: Any suggestions on how best to implement this? Should it be designed to be incorporated into Budabot's base package, distributed as a separate version (e.g. Budabot_WU), or as a downloadable addon package? If it is distributed as an addon package does anyone have suggestions on how best to handle the installation process for different OSes? I realize that this is a quite extensive undertaking; anyone willing to actively participate? :) Other suggestions??
User avatar
Arguru
The Team
Posts: 83
Joined: Fri Aug 05, 2011 10:02 pm
antispam: Rimor
Location: Kloetinge, The Netherlands
Contact:

Re: WEBUI_MODULE brainstorming

Postby Arguru » Thu Nov 24, 2011 12:39 am

Mac OS runs a modified UNIX kernel which is, surprisingly very similar to Linux. Also it uses a bash shell by default (who uses sh anyway?), if you code it for bash it should work fine on both platforms, provided they use the bash shell ofcourse.

From what I can see you only need to perform shell functions for error logs and start/stop as these are neither on the php or db level. For everything else you can simply use the webadmin's database and the bot's database to perform functions on eachother. See SMF_MODULE for an example on how to have two databases communicate with eachother.

Keep in mind though that not everybody uses MySQL as their database of choice. In fact, most Budabot instances run using Sqlite, and to be honest I don't see a reason to use MySQL for those people unless you are an advanced user or have a MySQL database running anyway.

Then there's PostgreSQL, whatever the hell Oracle uses at this point, that weird MS Access approach, etc. etc. While not used by Budabot these will be used in some webservers so keep in mind that your web UI would need to be cross compatible between those platforms, at least for the most widely used ones.
Rigger Faxing "Argufix" Berlin | 187/21/35 Omni Male Opifex Fixer <-- Screw S10, on the way to 220!
I "Argutrai" Remember | 15/2/3 Omni Male Atrox Trader <-- TL1 tower twink in progress.
Everything "Arguageii" Before | 6/2/0 Omni Male Opifex Agent <-- TL2 tower twink in progress.

Communications General of Pack of Noobs
Noobnet Administrator | Budabot Developer | Twinkbot Raidleader | Warcouncil Representative
Tyrence
Posts: 1959
Joined: Sat Jan 09, 2010 1:32 am

Re: WEBUI_MODULE brainstorming

Postby Tyrence » Thu Nov 24, 2011 1:09 am

The problem with writing to the bot database is that a lot of those things are cached in memory (eg, active commands, settings, etc) so just changing the database won't do it. The bot will have to listen on a socket and you'll have to implement a protocol to handle all the actions you'd like to be able to perform using the bot's API. But certainly doable.
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases
nagahiro
Member
Posts: 41
Joined: Mon Oct 03, 2011 6:42 pm
antispam: Rimor

Re: WEBUI_MODULE brainstorming

Postby nagahiro » Thu Nov 24, 2011 3:36 am

Arguru wrote:Mac OS runs a modified UNIX kernel which is, surprisingly very similar to Linux. Also it uses a bash shell by default (who uses sh anyway?), if you code it for bash it should work fine on both platforms, provided they use the bash shell ofcourse.


Hmm I was thinking mostly about offering a narrow scope of preconfigured options for the most common use scenarios; e.g.: a shell script that installs the missing pieces of a LAMP server on an Ubuntu machine, a bundled copy of xamp (http://www.apachefriends.org/en/xampp.html) minus the database component for windows users and an as of yet unknown comparable solution for Mac.

Arguru wrote: See SMF_MODULE for an example on how to have two databases communicate with eachother.

Keep in mind though that not everybody uses MySQL as their database of choice. In fact, most Budabot instances run using Sqlite, and to be honest I don't see a reason to use MySQL for those people unless you are an advanced user or have a MySQL database running anyway.


I was planning to have the Web UI package add to Budabot's existing database, not create a separate one. That way the UI can inherit username, password, and server address from the existing config.php and operate within the existing permissions without hassle. While I'm not at all familiar with the idiosyncrasies of Sqlite (yes, I admit, Im a MySQL guy) I figure extending Budabot's built-in accommodations for both can't be that difficult once the basic structure is in place.


Arguru wrote:Then there's PostgreSQL, whatever the hell Oracle uses at this point, that weird MS Access approach, etc. etc.


In my book, anyone who uses MS Access in conjunction with their web server is SOL and JWF Shit Outta Luck and Jolly Well Fucked. I mean, seriously ^^
nagahiro
Member
Posts: 41
Joined: Mon Oct 03, 2011 6:42 pm
antispam: Rimor

Re: WEBUI_MODULE brainstorming

Postby nagahiro » Thu Nov 24, 2011 4:04 am

Tyrence wrote:The problem with writing to the bot database is that a lot of those things are cached in memory (eg, active commands, settings, etc) so just changing the database won't do it. The bot will have to listen on a socket and you'll have to implement a protocol to handle all the actions you'd like to be able to perform using the bot's API. But certainly doable.


Ugh! Way to ruin my thanksgiving, mate :P

I see I have to think this through some more...
User avatar
Arguru
The Team
Posts: 83
Joined: Fri Aug 05, 2011 10:02 pm
antispam: Rimor
Location: Kloetinge, The Netherlands
Contact:

Re: WEBUI_MODULE brainstorming

Postby Arguru » Thu Nov 24, 2011 1:21 pm

nagahiro wrote:
Arguru wrote:Mac OS runs a modified UNIX kernel which is, surprisingly very similar to Linux. Also it uses a bash shell by default (who uses sh anyway?), if you code it for bash it should work fine on both platforms, provided they use the bash shell ofcourse.


Hmm I was thinking mostly about offering a narrow scope of preconfigured options for the most common use scenarios; e.g.: a shell script that installs the missing pieces of a LAMP server on an Ubuntu machine, a bundled copy of xamp (http://www.apachefriends.org/en/xampp.html) minus the database component for windows users and an as of yet unknown comparable solution for Mac.

Yet you would need shell scripts (and batch scripts) to perform the start/force stop function and reading out the logs in whichever scenario. :P As for installing the LAMP, there's no easy way to go about this as you will a) have to use a package manager, which isn't the same one on every distro or b) use wget and therefore bypassing the package manager (which is a bad idea). I'd just have users install their web environment on their own.

nagahiro wrote:
Arguru wrote: See SMF_MODULE for an example on how to have two databases communicate with eachother.

Keep in mind though that not everybody uses MySQL as their database of choice. In fact, most Budabot instances run using Sqlite, and to be honest I don't see a reason to use MySQL for those people unless you are an advanced user or have a MySQL database running anyway.


I was planning to have the Web UI package add to Budabot's existing database, not create a separate one. That way the UI can inherit username, password, and server address from the existing config.php and operate within the existing permissions without hassle. While I'm not at all familiar with the idiosyncrasies of Sqlite (yes, I admit, Im a MySQL guy) I figure extending Budabot's built-in accommodations for both can't be that difficult once the basic structure is in place.


The problem here is that you would have to have Apache/Lighttpd/IIS/whatever read out the Sqlite db instead of MySQL which can be rather difficult. I'd just set up a seperate db and cron sync between the two to save both yourself and the user alot of headaches. :P

nagahiro wrote:
Arguru wrote:Then there's PostgreSQL, whatever the hell Oracle uses at this point, that weird MS Access approach, etc. etc.


In my book, anyone who uses MS Access in conjunction with their web server is SOL and JWF Shit Outta Luck and Jolly Well Fucked. I mean, seriously ^^


Hey I agree, but you never know with those Windows users. :P
Rigger Faxing "Argufix" Berlin | 187/21/35 Omni Male Opifex Fixer <-- Screw S10, on the way to 220!
I "Argutrai" Remember | 15/2/3 Omni Male Atrox Trader <-- TL1 tower twink in progress.
Everything "Arguageii" Before | 6/2/0 Omni Male Opifex Agent <-- TL2 tower twink in progress.

Communications General of Pack of Noobs
Noobnet Administrator | Budabot Developer | Twinkbot Raidleader | Warcouncil Representative
nagahiro
Member
Posts: 41
Joined: Mon Oct 03, 2011 6:42 pm
antispam: Rimor

Re: WEBUI_MODULE brainstorming

Postby nagahiro » Thu Nov 24, 2011 4:04 pm

Arguru wrote:
nagahiro wrote:
Hmm I was thinking mostly about offering a narrow scope of preconfigured options for the most common use scenarios; e.g.: a shell script that installs the missing pieces of a LAMP server on an Ubuntu machine, a bundled copy of xamp (http://www.apachefriends.org/en/xampp.html) minus the database component for windows users and an as of yet unknown comparable solution for Mac.

Yet you would need shell scripts (and batch scripts) to perform the start/force stop function and reading out the logs in whichever scenario. :P As for installing the LAMP, there's no easy way to go about this as you will a) have to use a package manager, which isn't the same one on every distro or b) use wget and therefore bypassing the package manager (which is a bad idea). I'd just have users install their web environment on their own.


Yeah, that's why I thought of offering just 3 installer packages: Ubuntu, Windoze, Mac... Maybe supplemented with a 4th diy version that just comes with the needed sequel stuff to do the database.

Arguru wrote:
nagahiro wrote:I was planning to have the Web UI package add to Budabot's existing database, not create a separate one. That way the UI can inherit username, password, and server address from the existing config.php and operate within the existing permissions without hassle. While I'm not at all familiar with the idiosyncrasies of Sqlite (yes, I admit, Im a MySQL guy) I figure extending Budabot's built-in accommodations for both can't be that difficult once the basic structure is in place.


The problem here is that you would have to have Apache/Lighttpd/IIS/whatever read out the Sqlite db instead of MySQL which can be rather difficult. I'd just set up a seperate db and cron sync between the two to save both yourself and the user alot of headaches. :P


While I see how this could be done in theory I've never done something like this in practice.. Do you have a sample implementation of this somewhere by chance?
Tyrence
Posts: 1959
Joined: Sat Jan 09, 2010 1:32 am

Re: WEBUI_MODULE brainstorming

Postby Tyrence » Thu Nov 24, 2011 5:38 pm

Not sure if this helps, but here are some stats about the os and db that is used for the most current installations of Budabot:

Windows - 79
Other(Linux, Mac, etc) -30

Sqlite - 92
Mysql - 17

So anyway, my suggestion would be to write a PHP "website" that does all these things you want, and then additionally you can provide webserver "packages" (ex. LAMP) for people to download, but I would only do that for Windows. For Max and Linux, I would just expect them to set it up themselves.

Anyway, the first page of your website would take the ip address of the bot (usually 127.0.0.1) and the password. It would try to authenticate against the bot using that password at that ip address. If successful, you would store the IP address and password in the PHP session. For every subsequent request, you would pass the password from the session as part of the request.

Like I said before, this would all be done through a socket that the bot was listening on. You could use XML or your own custom format if you wanted, but I would recommend JSON. It's easy and PHP has built in support for it in PHP 5.2+. And you'd implement actions, very similar to a RESTful webservice. So let's say you wanted people to change a setting, alts_inherit_admin for example. You could define a "changeSetting" action like this:

Code: Select all

$request = new stdClass;
$request->password = $_SESSION["bot_password"];
$request->action = "changeSetting";
$request->settingName = "alts_inherit_admin";
$request->settingValue = "1";
$obj = json_encode($request);
fputs($obj, $botSocket);

The bot would handle it like this:

Code: Select all

// TODO read $input from socket
$request = json_decode($input);
if ($request->password != Setting::get("web_password")) {
   // TODO send back failure response
} else if ($request->action == "changeSetting") {
   Setting::save($request->settingName, $request->settingValue);
   // TODO send back success response
}
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases
User avatar
Team_Eli
Member
Posts: 259
Joined: Wed Dec 02, 2009 7:02 am

Re: WEBUI_MODULE brainstorming

Postby Team_Eli » Thu Nov 24, 2011 6:19 pm

A web front-end for the bot? Yes please.
Hmm... hmmm....

No, I'll save my comments for when it works and I can
play with it. I've always wanted to get into the web side
of things, and this could be a nice 'first-step' for me.

So by all means, please, proceed, I'll be watching with
excitement.

Regards,

Eli... non-technical in the extreme.
Image

In case your wondering.. I'm the one with the beard...
Wkdmp
The Team
Posts: 193
Joined: Fri Apr 23, 2010 4:19 pm

Re: WEBUI_MODULE brainstorming

Postby Wkdmp » Fri Nov 25, 2011 9:17 pm

I support this mod :P and would like to help where possible, I currently run 4 bots all on win and linux os, win os is the backup bot at location 2 :P
Yes I found a way to do it :P although would love an easyier way :p I have it set that it checks my main IP and if It cant contact that the monitoring software fires the backups :P

And Eli, I never realised how close u live bud, maybe we could even go halfs on a Dedicated server for our bots your 20miles away :P Scarey Eh :P

Return to “Modules”

Who is online

Users browsing this forum: No registered users and 2 guests