added command line arguments
This commit is contained in:
parent
48de9741d1
commit
71090d244b
@ -2,6 +2,7 @@
|
|||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "events.h"
|
#include "events.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
#include "channel.h"
|
||||||
#include "timers.h"
|
#include "timers.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -120,6 +121,9 @@ void lua_eval(struct irc_conn *bot, char *user, char *host, char *chan, const ch
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
if (!is_botadmin(user))
|
||||||
|
return;
|
||||||
|
|
||||||
block = 1;
|
block = 1;
|
||||||
printf("lua eval called with %s\n", text);
|
printf("lua eval called with %s\n", text);
|
||||||
if (strstr(text, "!lua") != NULL)
|
if (strstr(text, "!lua") != NULL)
|
||||||
@ -152,7 +156,12 @@ void lua_load_script(struct irc_conn *bot, char *user, char *host, char *chan, c
|
|||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
char *script;
|
char *script;
|
||||||
char *buf = (char *)malloc(sizeof(char *) * 500);
|
char *buf;
|
||||||
|
|
||||||
|
if (!is_botadmin(user))
|
||||||
|
return;
|
||||||
|
|
||||||
|
buf = (char *)malloc(sizeof(char *) * 500);
|
||||||
|
|
||||||
if (strstr(text, "!load") != NULL)
|
if (strstr(text, "!load") != NULL)
|
||||||
{
|
{
|
||||||
@ -267,7 +276,12 @@ void lua_unload_script(struct irc_conn *bot, char *user, char *host, char *chan,
|
|||||||
int i;
|
int i;
|
||||||
char *name;
|
char *name;
|
||||||
char *script;
|
char *script;
|
||||||
char *buf = (char *)malloc(sizeof(char *) * 500);
|
char *buf;
|
||||||
|
|
||||||
|
if (!is_botadmin(user))
|
||||||
|
return;
|
||||||
|
|
||||||
|
buf = (char *)malloc(sizeof(char *) * 500);
|
||||||
|
|
||||||
if (strstr(text, "!unload") != NULL)
|
if (strstr(text, "!unload") != NULL)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* irc.c: IRC connection and parser
|
* irc.c: IRC connection and parser
|
||||||
* xbot: Just another IRC bot
|
* xbot: an advanced IRC bot for *nix and Windows
|
||||||
|
*
|
||||||
|
* This file contains the functions for connecting to an IRC server, sending
|
||||||
|
* and receiving data, and parsing the data received from the server.
|
||||||
*
|
*
|
||||||
* Written by Aaron Blakely <aaron@ephasic.org>
|
* Written by Aaron Blakely <aaron@ephasic.org>
|
||||||
**/
|
**/
|
||||||
|
44
src/main.c
44
src/main.c
@ -4,6 +4,8 @@
|
|||||||
* Written by Aaron Blakely <aaron@ephasic.org>
|
* Written by Aaron Blakely <aaron@ephasic.org>
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
#define VERSION "0.1.0"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -29,14 +31,14 @@
|
|||||||
|
|
||||||
static time_t trespond;
|
static time_t trespond;
|
||||||
|
|
||||||
int main()
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
fd_set rd;
|
fd_set rd;
|
||||||
struct irc_conn bot;
|
struct irc_conn bot;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct timeval last_ping;
|
struct timeval last_ping;
|
||||||
|
char conf[1024];
|
||||||
|
|
||||||
char *p;
|
char *p;
|
||||||
int bytesRecv;
|
int bytesRecv;
|
||||||
@ -59,8 +61,44 @@ int main()
|
|||||||
init_events();
|
init_events();
|
||||||
init_timers();
|
init_timers();
|
||||||
init_mods();
|
init_mods();
|
||||||
|
|
||||||
|
strlcpy(conf, "xbot.cfg", sizeof conf);
|
||||||
|
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
if (argc == 2)
|
||||||
|
{
|
||||||
|
if (!strcmp(argv[1], "-v"))
|
||||||
|
{
|
||||||
|
printf("xbot version: %s\n", VERSION);
|
||||||
|
printf("Compiled on: %s %s\n\n", __DATE__, __TIME__);
|
||||||
|
printf("Written by Aaron Blakely <aaron@ephasic.org>\n");
|
||||||
|
printf("Licensed under the MIT License\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (!strcmp(argv[1], "-h"))
|
||||||
|
{
|
||||||
|
printf("Usage: xbot [-v] [-h] [-c <config file>]\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (argc == 3)
|
||||||
|
{
|
||||||
|
if (!strcmp(argv[1], "-c"))
|
||||||
|
{
|
||||||
|
free(bot.in);
|
||||||
|
free(bot.out);
|
||||||
|
|
||||||
|
bot.in = calloc(INBUF_SIZE, sizeof(char));
|
||||||
|
bot.out = calloc(OUTBUF_SIZE, sizeof(char));
|
||||||
|
|
||||||
|
strlcpy(conf, argv[2], sizeof conf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Read the config
|
// Read the config
|
||||||
bot = read_config(bot, "xbot.cfg");
|
bot = read_config(bot, conf);
|
||||||
|
|
||||||
// check if the db exists, if not, create it
|
// check if the db exists, if not, create it
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
Loading…
Reference in New Issue
Block a user