Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database Implementation #23

Open
ShadowMage121 opened this issue Feb 1, 2013 · 6 comments
Open

Database Implementation #23

ShadowMage121 opened this issue Feb 1, 2013 · 6 comments

Comments

@ShadowMage121
Copy link

A database implementation would be nice to have for if the bot sits in multiple channelse and other various things.

@super3
Copy link
Owner

super3 commented Feb 1, 2013

Issue #22 Includes some of our discussion about logged features. Right now the current goal is to get raw text file logging first, and then add database logging later. When we do go about implementing database logging, is there any particular one you would be interested in?

@FutileFreedom
Copy link
Contributor

For me, this wouldn't be for logging purposes. I tend to manage channels in an access-list sort of way. So just a wrapper for accessing in commands to check say, if they have access to even use the command, or are allowed into a channel. Also good for giving auto-operator, voice etc if someone doesn't know how to do so via XOP

@super3
Copy link
Owner

super3 commented Feb 3, 2013

What both of you are suggesting falls more under the feature sets rather than, pure database. You want the ability to add custom permission and settings for a bot. We could use something like a flatfile database to be able to store this information without adding the additional dependence of a real database(ie we want you to be able just to run the script).

I had made some progress on rough drafting a web admin panel in the web-exp branch. This would allow you to do the features you listed above.

Any ideas on how to specifically implement this, and what we should focus on first would be appreciated.

@FutileFreedom
Copy link
Contributor

I originally made this on the wrong account. No clue why I have that other one. Use a config option as to whether or not use the database. If the config option is not true, or yes, then use flatfile.

@oliveratgithub
Copy link

This is how I added DB-support to the PHP IRC-Bot (it's a dirty hack, but works):

  1. In config.php I defined new variables for my MySQL connection:
return array(
//[...]
    'db_server'      => 'localhost',
    'db_name'        => 'mydatabase',
    'db_user'        => 'root',
    'db_pass'        => 'root',
//[...]
  1. In a custom Command.php, I was now able establishing a MySQL-connection using these config-vars as follows:
public function command() {
    if(!$db = mysqli_connect(
        $this->bot->db_server,
        $this->bot->db_user,
        $this->bot->db_pass,
        $this->bot->db_name)
    ){
        die('Unable to connect to database');
    } else {
        // do all the DB-queries and stuff here
        mysqli_close($db);
    }
}
  1. Alternatively I think one can also simply include the (existing) MySQL-Class via the "config.php" like
require_once('../includes/mysql.inc.php');

There are far better ways, I am sure. I.e. copying a MySQL-Handler Class to the root of the "Classes/" directory?

@NanoSector
Copy link
Contributor

Just some food for thought, if we are going to be logging everything to a database server, we should probably buffer the incoming entries in some way because in a busy channel this could otherwise lead to high I/O and possibly massive lag on the bots side. For settings and such it shouldn't be a problem.

I could work on a simple abstraction layer and a layer for MySQLi, if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants