Code: Select all
/*
*
*
*
*
*/
#define MODULE_NAME "al"
#define MAKING_AL
#include "src/mod/module.h"
#include <mysql.h>
#include <stdio.h>
#undef global
static Function *global = NULL;
static void do_list();
static int al_expmem()
{
return 0;
}
static int pub_al(char *nick, char *host, char *hand, char *channel, char *text)
{
dprintf(DP_HELP, "PRIVMSG %s :Test :: %s :: %s :: %s :: %s :: %s", nick, nick, host, hand, channel, text);
do_list(nick, text);
return 0;
}
static int msg_al(char *nick, char *host, struct userrec *u, char *text)
{
dprintf(DP_SERVER, "PRIVMSG %s : Test :: %s :: %s :: %s", nick, nick, host, text);
do_list(nick, text);
return 0;
}
static void do_list(char *nick, char *text)
{
dprintf(DP_SERVER, "PRIVMSG %s : Test :: %s :: %s", nick, nick, text);
/*
* SQL stuff start
*/
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char *server = "localhost";
char *user = "eggdrop-xxxx";
char *password = "xxxxxxx"; /* set me first */
char *database = "eggdrop_al";
conn = mysql_init(NULL);
/* Connect to database */
if (!mysql_real_connect(conn, server, user, password, database, 0, NULL, 0)) {
dprintf(DP_SERVER, "PRIVMSG %s : There was an error of some kind please report to an owner: %s\n", nick, mysql_error(conn));
exit(1);
}
/* send SQL query */
if (mysql_query(conn, "SELECT * FROM `eggdrop_al`.`denylist`")) {
dprintf(DP_SERVER, "PRIVMSG %s : There was an error of some kind please report to an owner: %s\n", nick, mysql_error(conn));
exit(1);
}
res = mysql_use_result(conn);
/* output table name */
dprintf(DP_SERVER, "PRIVMSG %s :id :: nick :: date :: reason :: by:\n");
while ((row = mysql_fetch_row(res)) != NULL)
dprintf(DP_SERVER, "PRIVMSG %s :%s %s %s %s %s\n", nick, row[0], row[1], row[2], row[3], row[4]);
/* close connection */
mysql_free_result(res);
mysql_close(conn);
/*
* SQL stuff end
*/
}
static cmd_t al_pub[] = {
/* command flags function tcl-name */
{"!list", "", pub_al, NULL},
{NULL, NULL, NULL, NULL} /* Mark end. */
};
static cmd_t al_msg[] = {
{"!list", "", msg_al, NULL},
{NULL, NULL, NULL, NULL}
};
static void al_report(int idx, int details)
{
if (details) {
int size = al_expmem();
dprintf(idx, " Using %d byte%s of memory\n", size,
(size != 1) ? "s" : "");
}
}
static char *al_close()
{
//Context;
p_tcl_bind_list H_temp;
if ((H_temp = find_bind_table("pub")))
rem_builtins(H_temp, al_pub);
if ((H_temp = find_bind_table("msg")))
rem_builtins(H_temp, al_msg);
module_undepend(MODULE_NAME);
return NULL;
}
EXPORT_SCOPE char *al_start();
static Function al_table[] = {
(Function) al_start,
(Function) al_close,
(Function) al_expmem,
(Function) al_report,
};
char *al_start(Function *global_funcs)
{
/* Assign the core function table. After this point you use all normal
* functions defined in src/mod/modules.h
*/
global = global_funcs;
Context;
/* Register the module. */
module_register(MODULE_NAME, al_table, 1, 0);
if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) {
module_undepend(MODULE_NAME);
return "This module requires Eggdrop 1.6.0 or later.";
}
p_tcl_bind_list H_temp;
if ((H_temp = find_bind_table("msg")))
add_builtins(H_temp, al_msg);
if ((H_temp = find_bind_table("pub")))
add_builtins(H_temp, al_pub);
return NULL;
}