#include "config.h"
#endif
+#include "Parser.H"
+
#include <cstdlib>
+
#include <sys/types.h>
#include <netinet/in.h>
-#include "StringTokenizer.H"
-#include "Parser.H"
-#include "UserCommands.H"
+#ifdef USESCRIPTS
+#include <libguile.h>
+#include "BotInterp.H"
+#include "Interp.H"
+#endif
+
+#include "Bot.H"
+#include "Channel.H"
+#include "ChannelList.H"
#include "Commands.H"
#include "Macros.H"
-#include "Utils.H"
+#include "Message.H"
+#include "Person.H"
+#include "Server.H"
+#include "ServerConnection.H"
+#include "ServerList.H"
+#include "ShitEntry.H"
#include "ShitList.H"
+#include "StringTokenizer.H"
+#include "UserCommands.H"
+#include "User.H"
+#include "UserList.H"
+#include "Utils.H"
+
typedef void (*fptr) (ServerConnection *, Person *, String);
std::map < std::string, fptr, std::less < std::string > > Parser::functions;
if (st.rest ().length ())
{
st.next_token ('=');
- String parameters = st.rest ();
- parameters = parameters.substr (1);
- cnx->bot->userhostMap[num] = parameters;
+ cnx->bot->userhostMap[num] = Utils::trim_str (st.rest().substr(1));
}
else
cnx->bot->userhostMap[num] = "";
st.next_token ();
String ch = st.next_token ();
if (Channel * c = cnx->bot->channelList->getChannel (ch))
- c->addBan (st.next_token (), -1);
+ c->addBan (Mask(st.next_token ()), -1);
}
void
return;
}
ch->addNick (n, uh, 0, cnx->bot->userList);
- if (ch->getUser (n)->getAop ()
- && !(ch->getUser (n)->mode & User::OP_MODE) && cnx->bot->iAmOp (c))
+ if (ch->getUser (n).getAop ()
+ && !(ch->getUser (n).mode & User::OP_MODE) && cnx->bot->iAmOp (c))
{
// This is a part of the antispoof code
- ch->getUser(n)->userkey = Utils::get_key ();
+ ch->change_user_key (n, Utils::get_key ());
Commands::CTCP (cnx->bot, n, "PING",
- ch->getUser(n)->userkey + " " + c);
+ ch->getUser(n).userkey + " " + c);
}
}
{
if (!cnx->bot->channelList->getChannel (channel))
return;
- User *u = cnx->bot->channelList->getChannel (channel)->getUser (target);
- if (u && u->getProt () >= User::NO_KICK)
+ try
{
- String fromNick = from->getNick ();
- User *v =
- cnx->bot->channelList->getChannel (channel)->getUser (fromNick);
- if (v->getProt () < User::NO_KICK)
+ User u = cnx->bot->channelList->getChannel (channel)->getUser (target);
+ if (u.getProt () >= User::NO_KICK)
{
- cnx->bot->logLine (from->getAddress () + " kicked " + target +
- " (protected) out of channel " + channel +
- " (" + reason + ").");
- cnx->queue->sendKick (channel, fromNick,
- target + " \002is protected !\002");
+ String fromNick = from->getNick ();
+ User v =
+ cnx->bot->channelList->getChannel (channel)->getUser (fromNick);
+ if (v.getProt () < User::NO_KICK)
+ {
+ cnx->bot->logLine (from->getAddress () + " kicked " + target +
+ " (protected) out of channel " + channel +
+ " (" + reason + ").");
+ cnx->queue->sendKick (channel, fromNick,
+ target + " \002is protected !\002");
+ }
}
}
+ catch (const ChannelUserList::user_not_found &e)
+ {
+
+ }
cnx->bot->channelList->getChannel (channel)->delNick (target);
}
}
StringTokenizer st3 (rest);
rest = st3.next_token ();
String c = st3.rest ();
- if (cnx->bot->channelList->getChannel (c) &&
- cnx->bot->channelList->getChannel (c)->getUser (nick) &&
- cnx->bot->channelList->getChannel (c)->getUser (nick)->
- getAop ()
- && !(cnx->bot->channelList->getChannel (c)->
- getUser (nick)->mode & User::OP_MODE)
- && cnx->bot->channelList->getChannel (c)->getUser (nick)->
- userkey == rest)
- cnx->queue->sendChannelMode (c, "+o", nick);
+ Channel *channel = cnx->bot->channelList->getChannel (c);
+
+ if (channel && channel->hasNick (nick))
+ {
+ User u = cnx->bot->channelList->getChannel(c)->getUser(nick);
+ if (u.getAop () && !(u.mode & User::OP_MODE) && u.userkey == rest)
+ cnx->queue->sendChannelMode (c, "+o", nick);
+ }
}
}
if (!c)
return;
c->delNick (n);
- if (c->countOp == 0 && c->count == 1)
+ if (c->operator_count () == 0 && c->user_count () == 1)
{
cnx->queue->sendPart (channel);
cnx->queue->sendJoin (channel,
return;
}
level = Utils::get_level (cnx->bot, from->getAddress (), to);
- User *u = 0;
- if (Channel * c = cnx->bot->channelList->getChannel (to))
- u = c->getUser (from->getNick ());
- if (!u || !u->userListItem)
- identified = true;
+
+ Channel * c = cnx->bot->channelList->getChannel (to);
+ if (c && c->hasNick (from->getNick ()))
+ {
+ User u = c->getUser (from->getNick ());
+ if (!u.userListItem)
+ identified = true;
+ else
+ identified = u.userListItem->passwd == ""
+ || u.userListItem->identified > 0;
+ }
else
- identified = u->userListItem->passwd == ""
- || u->userListItem->identified > 0;
+ {
+ identified = true;
+ }
}
else
{
struct wrapper_data wd;
wd.func = scmFunc;
wd.args = args_list;
- scm_internal_catch (SCM_BOOL_T,
- (scm_t_catch_body) Interp::LazyApplyWrapper,
- (void *) &wd,
- (scm_t_catch_handler) Interp::EmptyHandler, 0);
+ scm_c_with_throw_handler (SCM_BOOL_T,
+ (scm_t_catch_body) Interp::LazyApplyWrapper,
+ (void *) &wd,
+ (scm_t_catch_handler) Interp::EmptyHandler,
+ 0,
+ 0);
}
#endif