// BotInterp.H -*- C++ -*-
// Copyright (c) 1998 Etienne BERNARD
// Copyright (C) 2002 Clinton Ebadi
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#ifndef BOTINTERP_H
#define BOTINTERP_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef USESCRIPTS
#include <ctime>
#include <libguile.h>
#include "String.H"
class Bot;
struct Hook {
int type;
String regex_str;
SCM regex;
SCM function;
Hook(int t, String rs, SCM r, SCM f)
: type(t), regex_str(rs), regex(r), function(f) { }
enum {
ACTION, NICKNAME, SIGNOFF, CTCP, CTCP_REPLY,
DISCONNECT, FLOOD, INVITE, JOIN, KICK, LEAVE,
MODE, MESSAGE, NAMES, NOTICE, PUBLIC,
PUBLIC_NOTICE, RAW, TIMER, TOPIC
};
};
struct Timer {
int count;
std::time_t when;
SCM function;
Timer(int c, std::time_t t, SCM f)
: count(c), when(t), function(f) { }
};
class BotInterp {
Bot * bot;
SCM logPort;
std::map<int, std::list<Hook *>, std::less<int> > hooksMap;
std::list<Timer *> timersList;
int counter;
public:
BotInterp(Bot *, String);
void ScriptLog(SCM);
void Execute(String);
void LoadScript(String);
bool AddHook(int, SCM, SCM);
bool RunHooks(int, String, SCM);
SCM AddTimer(int, SCM);
bool DelTimer(SCM);
bool RunTimers(int);
friend class Interp;
friend class ScriptCommands;
};
#endif
#endif
syntax highlighted by Code2HTML, v. 0.9.1