1 // BotInterp.H -*- C++ -*-
2 // Copyright (c) 1998 Etienne BERNARD
3 // Copyright (C) 2002,2005,2008 Clinton Ebadi
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
37 #include "BotThreading.H"
48 std::string regex_str;
53 Hook(int t, std::string rs, SCM r, SCM f, int p, bool ft, std::string n="DEFAULT")
54 : type(t), priority (p), fallthru (ft), regex_str(rs),
55 name (n), regex(r), function(f) { }
57 bool operator< (const Hook & h) const;
60 ACTION, NICKNAME, SIGNOFF, CTCP, CTCP_REPLY,
61 DISCONNECT, FLOOD, INVITE, JOIN, KICK, MODE,
62 MESSAGE, NAMES, NOTICE, PART, PUBLIC,
63 PUBLIC_NOTICE, RAW, TIMER, TOPIC,
65 SEND_ACTION, SEND_CTCP, SEND_PUBLIC, SEND_MESSAGE,
68 DCC_CHAT_BEGIN, DCC_CHAT_END, DCC_CHAT_MESSAGE
77 Timer(int c, std::time_t t, SCM f)
78 : count(c), when(t), function(f) { }
80 bool operator< (const Timer & other) const
81 { return when < other.when; }
85 typedef std::list<Timer *> TimerList;
86 typedef std::list<Hook *> HookList;
87 typedef std::map<int, HookList, std::less<int> > HookMap;
96 Utils::IndirectPred<Timer, std::less<Timer> > timer_sort_p;
97 Utils::IndirectPred<Hook, std::less<Hook> > hook_sort_p;
100 BotMutex timer_mutex; // NOTE: recursive lock
103 BotInterp(Bot *, String);
107 void Execute(String);
108 void LoadScript(String);
110 bool AddHook(int, SCM, SCM, int, bool, std::string);
111 bool RunHooks(int, std::string, SCM);
113 SCM AddTimer(int, SCM);
118 friend class ScriptCommands;