WEBUI_MODULE brainstorming

If you have created a 3rd party module you'd like other people to use, post it here
Tyrence
Posts: 1950
Joined: Sat Jan 09, 2010 1:32 am

Re: WEBUI_MODULE brainstorming

Postby Tyrence » Mon Dec 19, 2011 8:53 am

Marebone wrote:...but each module developer would need to think their own solution if they wish to have such functionality.

Right. My contention is that was that a lot of those things aren't actually "bot commands" so they shouldn't be handled as such and that we should have something else to handle things like that.

But since we have no plans to write something else, I will add support for those things with the Simple/Advanced flag like I talked about in the previous post. Especially since we are pretty much there anyway. For the issues that come up we'll just work around them for now. And then later someone can come in and write a more permanent solution.
"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 » Mon Dec 19, 2011 6:42 pm

And then later someone can come in and write a more permanent solution.

*chuckle* Nice try, Ty, but I reckon you're just trying to avoid having to write the 'HOWTO' for
this module. :)

Eli.
Image

In case your wondering.. I'm the one with the beard...
Marebone
The Team
Posts: 175
Joined: Sun Sep 04, 2011 7:38 am
antispam: Rimor

Re: WEBUI_MODULE brainstorming

Postby Marebone » Sun Jan 15, 2012 2:55 pm

There is now a PHP SDK for the API in revision 2303.
You can download it from here: http://code.google.com/p/budabot2/source/browse/projects/budapisdk/src/Budapi.php

In order to use the API, you need to know following:
  • bot's ip-address,
  • bot's port (by default 5250),
  • username,
  • password
Password is set with command:

Code: Select all

!apipassword {password}

Username is the player name from where you sent the !apipassword-command.

Example usage:

Code: Select all

require_once 'Budapi.php';
$api = new Budapi();
$api->setHost('127.0.0.1');
$api->setPort(5250);
$api->setUsername('marebone');
$api->setPassword('goofy');
echo $api->sendCommand('is tyrence');

This prints something like:
Character Tyrence is offline.
Marebone
The Team
Posts: 175
Joined: Sun Sep 04, 2011 7:38 am
antispam: Rimor

Re: WEBUI_MODULE brainstorming

Postby Marebone » Tue Jul 17, 2012 6:39 pm

Some brainstorming was seen at #coders today, enjoy :)

(2012-07-17 20:12:09) Marebone: Tyrence: you remember, with the WEBUI discussion, the plan was to package the ui pages with xampp and then the pages would communicate with the bot through budapi, right?
(2012-07-17 20:12:57) Tyrence: umm I didn't think we ever got that far in the discussion
(2012-07-17 20:13:03) Tyrence: cuz I don't remember that
(2012-07-17 20:13:16) Tyrence: I do remember someone mentioning something about xampp
(2012-07-17 20:13:54) Marebone: it was mentioned in quite a many posts in that topic :)
(2012-07-17 20:14:18) Tyrence: hehe ok :)
(2012-07-17 20:14:21) Marebone: since windows doesn't have any easy way to install web server on it
(2012-07-17 20:15:08) Tyrence: anyway what about it?
(2012-07-17 20:15:32) Marebone: well, I think there would be an easier way of doing this
(2012-07-17 20:16:17) Marebone: we could just embed a http server into Budabot
(2012-07-17 20:17:11) Marebone: it already has the budapi server in it, so having a http server shouldn't be impossible
(2012-07-17 20:17:42) Tyrence: hehe yeah um
(2012-07-17 20:18:36) Tyrence: it's possible for sure
(2012-07-17 20:18:52) Tyrence: i don't know how feasible tho
(2012-07-17 20:19:02) Marebone: then there would not be any problems of how to package it for windows
(2012-07-17 20:20:41) Tyrence: http://php.net/manual/en/features.comma ... server.php
(2012-07-17 20:20:45) Tyrence: need 5.4 for that tho
(2012-07-17 20:21:04) Marebone: and the webui could then have access to the bot's database and internal variables with ease
(2012-07-17 20:21:45) Marebone: I was more like thinking this one: http://nodephp.org/
(2012-07-17 20:22:44) Tyrence: ah hmmm
(2012-07-17 20:23:02) Marebone: needs 5.3 though
(2012-07-17 20:23:42) Marebone: although, I had an another idea for that version problem
(2012-07-17 20:23:54) Tyrence: i think budabot will run 5.3 right now
(2012-07-17 20:24:22) Marebone: it does, on windows, but does it on other OSes?
(2012-07-17 20:24:31) Tyrence: well it should
(2012-07-17 20:24:33) Tyrence: the hardest part about 5.3 is that most linux distros don't have that in their standard repos
(2012-07-17 20:24:58) Tyrence: but if u can get 5.3 installed, it should run no problem
(2012-07-17 20:25:51) Marebone: well, I thought we could somehow mark into budabot's modules which php version, at minimum, they require
(2012-07-17 20:26:13) Tyrence: and if it's below that number don't activate them?
(2012-07-17 20:26:16) Tyrence: that's a good idea
(2012-07-17 20:26:42) Marebone: when the modules are being loaded, budabot would ignore modules which require newer version that what is currently in use
(2012-07-17 20:26:52) Tyrence: but i'm pretty confident that they will all run on 5.3 already
(2012-07-17 20:26:53) Marebone: yep
(2012-07-17 20:28:47) Marebone: well, I could use 5.3 from now on.
(2012-07-17 20:29:05) Marebone: if it is a problem to someone, I can add that minimum version feature to fix it
(2012-07-17 20:29:49) Marebone: ofc, might be useful also, if somone wants to use, say 5.4 for module developping
(2012-07-17 20:30:06) Tyrence: yeah
(2012-07-17 20:32:25) Marebone: oh, and about the http server. I thought we could also replace the current budapi with that. We could still sent commands through it, like:
(2012-07-17 20:32:25) Marebone: http://localhost/api/command/?cmd=homer ... assword=...
(2012-07-17 20:33:06) Marebone: and the webui could be found from http://localhost/admin/ for example
(2012-07-17 20:33:22) Tyrence: hmm yeah that would be a lot better i think
(2012-07-17 20:36:02) Marebone: oh and that !say command, which is quite useless for in-game, would be better as a web resource, like: http://localhost/api/guild/message?mess ... assword=...
(2012-07-17 20:36:26) Tyrence: yeah
(2012-07-17 20:36:53) Iriche: http://www.facebook.com/photo.php?v=382 ... eo_comment this is so cool :D
(2012-07-17 20:41:16) Tyrence: so if you changed all that, do you think php could still handle it well?
(2012-07-17 20:44:11) Marebone: no idea really, I guess, when the server is added to budabot's reactor loop, it has to be done so that it doesn't slow down the bot
(2012-07-17 20:44:25) Marebone: even with increased load on http server
(2012-07-17 20:44:25) Tyrence: yeah
(2012-07-17 20:45:14) Iriche: downside with php
(2012-07-17 20:45:19) Iriche: very low support for threading
(2012-07-17 20:45:23) Marebone: yep
(2012-07-17 20:45:38) Iriche: if you have any part of the bot that checks a database i would just leave http seperate but could be php
(2012-07-17 20:45:44) Iriche: and then let them communicate via sql
(2012-07-17 20:45:45) Iriche: or any other
(2012-07-17 20:46:15) Marebone: yea, the communication becomes a lot harder it is a separate process :(
(2012-07-17 20:46:21) Marebone: +if
(2012-07-17 20:55:12) Marebone: I thought that I would actually implement many of those features which I have currently on Bot Manager's backlog into the webui. Like that !config-UI. And I would leave to Bot Manager what cannot be implemented to the webui.
(2012-07-17 20:56:41) Tyrence: ah i see
(2012-07-17 20:58:11) Marebone: this way I don't need to implement same features two times, once into Bot Manager and again to Web UI.
(2012-07-17 20:58:48) Tyrence: yeah
(2012-07-17 20:59:13) Tyrence: and for people that don't want to install python to use the gui they will still get some ui control
(2012-07-17 20:59:25) Marebone: that is true
Marebone
The Team
Posts: 175
Joined: Sun Sep 04, 2011 7:38 am
antispam: Rimor

Re: WEBUI_MODULE brainstorming

Postby Marebone » Wed Jul 25, 2012 10:50 am

Marebone
The Team
Posts: 175
Joined: Sun Sep 04, 2011 7:38 am
antispam: Rimor

Re: WEBUI_MODULE brainstorming

Postby Marebone » Wed Jul 25, 2012 4:06 pm

So, the HTTP server is in the HTTPAPI_MODULE. I didn't add it to the existing API_MODULE as it easier to understand how it works when the old BudAPI stuff isn't there making things complex.
I will, in future remove the API_MODULE and replace it with the HTTPAPI_MODULE. The API_MODULE is there so that Bot Manager will continue to work.

I thought also that I will leave the HTTPAPI_MODULE quite simple. The Web UI shall be in another module, say WEBUI_MODULE.
In order to handle HTTP requests in the WEBUI_MODULE I think I need to add some kind of new handler to modules.

The handler could be something like this:

Code: Select all

/** @Instance */
class SomeController {
   /**
    * @BudapiRequest
    * @Matches("/^/admin/.+$/i")
    */
   public function httpRequest($request, $response, $arr) {
      $response->writeHead(200, array('Content-Type' => 'text/plain'));
      $response->end("Hello Budabot!\n");
   }
}


Then say goto http://localhost/admin/ with web browser and that handler will be called.

What do you think?
Tyrence
Posts: 1950
Joined: Sat Jan 09, 2010 1:32 am

Re: WEBUI_MODULE brainstorming

Postby Tyrence » Thu Oct 04, 2012 9:56 pm

I guess I never saw this post but I think this is a good idea. I can conceive that we should be able to write a WebCommandReply class that implements the CommandReply interface and we can use that to format the results so they will display someone well as html. However, the biggest problem is probably blobs, since they are formatted before being sent. To really make this work, we need to defer formatting to whatever is actually sending the reply back.
"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
Tyrence
Posts: 1950
Joined: Sat Jan 09, 2010 1:32 am

Re: WEBUI_MODULE brainstorming

Postby Tyrence » Wed Apr 16, 2014 11:36 pm

I got bored the other day so I started looking at the WEBUI_MODULE that Marebone built. Looked pretty nice, but all you could do was see the log. So it was good for checking the status of your bot, but you had no way to change the configuration.

So I added support for sending commands to the bot from that page. If anyone uses this module and updates their bot from Git I'd be interested to know how you like the changes.

There are still more improvements that need to be done. For instance, the AOML should be "massaged" into proper HTML so that it can be displayed on the page, clicked on, interacted with, etc.

EDIT: The command output should display mostly correct now. Chatcmds that send tells to the bot are now clickable and item icons are now displayed.

To use:
1) check settings: !config HTTP_SERVER_MODULE and verify that everything is enabled
2) set a password: !apipassword your_password
3) open a web page at: http://localhost:8080/WEBUI_MODULE/login
4) enter the password you set in step 2) and the character you set the password with as the username

You can also use this remotely provided that your firewall is set up to forward a request on that port to the bot.
"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
Tyrence
Posts: 1950
Joined: Sat Jan 09, 2010 1:32 am

Re: WEBUI_MODULE brainstorming

Postby Tyrence » Tue May 19, 2015 11:24 pm

Just curious if anyone is actually using this in their bot. It was a fun project and it has a "cool" factor, but if it is not useful for most people I will probably remove it with the 3.3 release.
"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
iComa
Member
Posts: 17
Joined: Mon Mar 18, 2013 3:21 pm
antispam: Rimor

Re: WEBUI_MODULE brainstorming

Postby iComa » Thu Aug 13, 2015 1:43 pm

Is that module working in 3.4RC1 ? Because to me it's not ;)

To [xxxx]: config mod WEBUI_MODULE enable all
[xxxx]: Could not find Module WEBUI_MODULE.



But in config list its running green. Web page not generating also.

Return to “Modules”

Who is online

Users browsing this forum: No registered users and 1 guest