*
* x3 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
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
{ "WBMSG_NICK_INVALID", "The nickname $b%s$b is invalid." },
{ "WBMSG_NICK_IN_USE", "The nickname $b%s$b is in use, please choose another." },
+ { "WBMSG_CHANNEL_BANNED", "You are banned on %s." },
+ { "WBMSG_CHANNEL_LIMIT", "%s has reached the maximum allowed chatters." },
+ { "WBMSG_CHANNEL_INVITE", "%s is invite only." },
+ { "WBMSG_CHANNEL_PASSWORD", "%s is password protected." },
+
{ "WBMSG_WHOIS_NICKIDENT", "[%s] (%s@%s): %s" },
{ "WBMSG_WHOIS_CHANNELS", "On %s" },
{ "WBMSG_WHOIS_SERVER", "[%s] %s : %s" },
{ "WBMSG_WHOIS_CONNECTED", "[%s] %s" },
{ "WBMSG_WHOIS_END", "[%s] End of WHOIS list." },
+ { "WBMSG_ALREADY_JOINED", "I am already in $b%s$b." },
+ { "WBMSG_JOIN_DONE", "I have joined $b%s$b." },
+
{ NULL, NULL }
};
{
unsigned int y = 0;
- if (webtv_conf.required_mark == 0)
+ if ((webtv_conf.required_mark == 0) || IsOper(user))
return 1;
else {
if (!user->mark) {
return 1;
}
+void
+part_all_channels(struct userNode *target)
+{
+ unsigned int n=0;
+ struct modeNode *mn;
+
+ for (n=0; n<target->channels.used; n++) {
+ mn = target->channels.list[n];
+ irc_svspart(webtv, target, mn->channel);
+ }
+
+ return;
+}
+
+static MODCMD_FUNC(cmd_sjoin)
+{
+ struct userNode *bot = cmd->parent->bot;
+
+ if (!IsChannelName(argv[1])) {
+ reply("MSG_NOT_CHANNEL_NAME");
+ return 0;
+ } else if (!(channel = GetChannel(argv[1]))) {
+ channel = AddChannel(argv[1], now, NULL, NULL, NULL);
+ AddChannelUser(bot, channel)->modes |= MODE_CHANOP;
+ } else if (GetUserMode(channel, bot)) {
+ reply("WBMSG_ALREADY_JOINED", channel->name);
+ return 0;
+ } else {
+ struct mod_chanmode change;
+ mod_chanmode_init(&change);
+ change.argc = 1;
+ change.args[0].mode = MODE_CHANOP;
+ change.args[0].u.member = AddChannelUser(bot, channel);
+ modcmd_chanmode_announce(&change);
+ }
+ irc_fetchtopic(bot, channel->name);
+ reply("WBMSG_JOIN_DONE", channel->name);
+ return 1;
+}
+
+static MODCMD_FUNC(cmd_join)
+{
+ struct chanNode *target;
+
+ if (!check_mark(cmd, user, NULL, 0, 0, NULL))
+ return 0;
+
+ if(!(target = GetChannel(argv[1])))
+ {
+ reply("MSG_INVALID_CHANNEL");
+ return 0;
+ }
+
+ if (trace_check_bans(user, target) == 1) {
+ reply("WBMSG_CHANNEL_BANNED", argv[1]);
+ return 0;
+ }
+
+ if (target->modes & MODE_INVITEONLY) {
+ reply("WBMSG_CHANNEL_INVITE", argv[1]);
+ return 0;
+ }
+
+
+ if (target->limit > 0) {
+ if (target->members.used >= target->limit) {
+ reply("WBMSG_CHANNEL_LIMIT", argv[1]);
+ return 0;
+ }
+ }
+
+
+ if (*target->key) {
+ if (argc > 2) {
+ if (strcmp(argv[2], target->key)) {
+ reply("WBMSG_CHANNEL_PASSWORD", argv[1]);
+ return 0;
+ }
+ } else {
+ reply("WBMSG_CHANNEL_PASSWORD", argv[1]);
+ return 0;
+ }
+ }
+
+ part_all_channels(user);
+ irc_svsjoin(webtv, user, target);
+ return 1;
+}
+
+static MODCMD_FUNC(cmd_part)
+{
+ struct mod_chanmode change;
+ struct chanNode *target;
+
+ if (!check_mark(cmd, user, NULL, 0, 0, NULL))
+ return 0;
+
+ if(!(target = GetChannel(argv[1])))
+ {
+ reply("MSG_INVALID_CHANNEL");
+ return 0;
+ }
+
+ mod_chanmode_init(&change);
+ change.argc = 1;
+ change.args[0].u.member = GetUserMode(target, user);
+ if(!change.args[0].u.member)
+ {
+ if(argc)
+ reply("MSG_CHANNEL_ABSENT", target->name);
+ return 0;
+ }
+
+ irc_svspart(webtv, user, target);
+ return 1;
+}
+
static void
webtv_conf_read(void)
{
WB_LOG = log_register_type("WebTV", "file:webtv.log");
conf_register_reload(webtv_conf_read);
- reg_exit_func(webtv_cleanup);
+ reg_exit_func(webtv_cleanup, NULL);
webtv_module = module_register("WebTV", WB_LOG, "mod-webtv.help", NULL);
modcmd_register(webtv_module, "nick", cmd_nick, 1, 0, NULL);
- modcmd_register(webtv_module, "whois", cmd_whois, 1, 0, NULL);
+ modcmd_register(webtv_module, "join", cmd_join, 1, 0, NULL);
+ modcmd_register(webtv_module, "part", cmd_part, 1, 0, NULL);
+ modcmd_register(webtv_module, "whois", cmd_whois, 1, 0, NULL);
+
+ modcmd_register(webtv_module, "sjoin", cmd_sjoin, 1, MODCMD_REQUIRE_AUTHED, "flags", "+oper", NULL);
message_register_table(msgtab);
return 1;
if (str) {
webtv = webtv_conf.bot;
const char *modes = conf_get_data("modules/webtv/modes", RECDB_QSTRING);
- webtv = AddService(str, modes ? modes : NULL, "WebTV IRC Service", NULL);
+ webtv = AddLocalUser(str, str, NULL, "WebTV IRC Service", modes);
} else {
log_module(WB_LOG, LOG_ERROR, "database_get_data for webtv_conf.bot failed!");
exit(1);