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
38 #include "BotThreading.H"
49 std::string regex_str;
54 Hook(int t, std::string rs, SCM r, SCM f, int p, bool ft, std::string n="DEFAULT")
55 : type(t), priority (p), fallthru (ft), regex_str(rs),
56 name (n), regex(r), function(f) { }
58 bool operator< (const Hook & h) const;
61 ACTION, NICKNAME, SIGNOFF, CTCP, CTCP_REPLY,
62 DISCONNECT, FLOOD, INVITE, JOIN, KICK, MODE,
63 MESSAGE, NAMES, NOTICE, PART, PUBLIC,
64 PUBLIC_NOTICE, RAW, TIMER, TOPIC,
66 SEND_ACTION, SEND_CTCP, SEND_PUBLIC, SEND_MESSAGE,
69 DCC_CHAT_BEGIN, DCC_CHAT_END, DCC_CHAT_MESSAGE
78 Timer(int c, std::time_t t, SCM f)
79 : count(c), when(t), function(f) { }
81 bool operator< (const Timer & other) const
82 { return when < other.when; }
86 typedef std::list<Timer *> TimerList;
87 typedef std::list<Hook *> HookList;
88 typedef std::map<int, HookList, std::less<int> > HookMap;
97 Utils::IndirectPred<Timer, std::less<Timer> > timer_sort_p;
98 Utils::IndirectPred<Hook, std::less<Hook> > hook_sort_p;
101 BotMutex timer_mutex; // NOTE: recursive lock
104 BotInterp(Bot *, String);
108 void Execute(String);
109 void LoadScript(String);
111 bool AddHook(int, SCM, SCM, int, bool, std::string);
112 bool RunHooks(int, std::string, SCM);
114 SCM AddTimer(int, SCM);
119 friend class ScriptCommands;