+static char *his_servername;
+static char *his_servercomment;
+
+
+int check_mark(struct svccmd *cmd, struct userNode *user, UNUSED_ARG(struct handle_info *hi), UNUSED_ARG(unsigned int override), UNUSED_ARG(unsigned int argc), UNUSED_ARG(char *argv[]))
+{
+ unsigned int y = 0;
+
+ if ((webtv_conf.required_mark == 0) || IsOper(user))
+ return 1;
+ else {
+ if (!user->mark) {
+ reply("WBMSG_NOT_MARKED");
+ return 0;
+ }
+ for (y = 0; y < webtv_conf.valid_marks->used; y++) {
+ if (!strcasecmp(webtv_conf.valid_marks->list[y], user->mark))
+ return 1;
+ }
+ reply("WBMSG_NOT_MARKED");
+ return 0;
+ }
+}
+
+static MODCMD_FUNC(cmd_nick)
+{
+ struct userNode *nick;
+
+ if (!check_mark(cmd, user, NULL, 0, 0, NULL))
+ return 0;
+
+ if (argc < 2) {
+ reply("WBMSG_NICK_PARAMS");
+ return 0;
+ }
+
+ if (!strcasecmp(argv[1], user->nick)) {
+ reply("WBMSG_NICK_SAME", argv[1]);
+ return 0;
+ }
+
+ if (!is_valid_nick(argv[1])) {
+ reply("WBMSG_NICK_INVALID", argv[1]);
+ return 0;
+ }
+
+ nick = GetUserH(argv[1]);
+ if (nick) {
+ reply("WBMSG_NICK_IN_USE", argv[1]);
+ return 0;
+ }
+
+ irc_svsnick(webtv, user, argv[1]);
+ return 1;
+}
+
+void
+webtv_ison(struct userNode *bot, struct userNode *tell, struct userNode *target, const char *message)
+{
+ struct modeNode *mn;
+ unsigned int count, here_len, n, maxlen;
+ char buff[MAXLEN];
+
+ maxlen = tell->handle_info ? tell->handle_info->screen_width : 0;
+ if (!maxlen)
+ maxlen = MAX_LINE_SIZE;
+ for (n=count=0; n<target->channels.used; n++) {
+ mn = target->channels.list[n];
+ if ((mn->channel->modes & (MODE_PRIVATE|MODE_SECRET)))
+ continue;
+
+ here_len = strlen(mn->channel->name);
+ if ((count + here_len + 4) > maxlen) {
+ buff[count] = 0;
+ send_message(tell, bot, message, buff);
+ count = 0;
+ }
+ if (mn->modes & MODE_CHANOP)
+ buff[count++] = '@';
+ if (mn->modes & MODE_HALFOP)
+ buff[count++] = '%';
+ if (mn->modes & MODE_VOICE)
+ buff[count++] = '+';
+ memcpy(buff+count, mn->channel->name, here_len);
+ count += here_len;
+ buff[count++] = ' ';
+ }
+ if (count) {
+ buff[count] = 0;
+ send_message(tell, bot, message, buff);
+ }
+}
+
+static MODCMD_FUNC(cmd_whois)
+{
+ struct userNode *target;
+
+ if (!check_mark(cmd, user, NULL, 0, 0, NULL))
+ return 0;
+
+ if (argc < 2) {
+ reply("WBMSG_NICK_PARAMS");
+ return 0;
+ }
+
+ target = GetUserH(argv[1]);
+ if (target) {
+ reply("WBMSG_WHOIS_NICKIDENT", target->nick, target->ident,
+ IsFakeHost(target) ? target->fakehost : target->hostname, target->info);
+
+ if ((target->channels.used <= MAX_CHANNELS_WHOIS) && !IsService(target))
+ webtv_ison(cmd->parent->bot, user, target, "WBMSG_WHOIS_CHANNELS");
+
+ if (target == user)
+ reply("WBMSG_WHOIS_SERVER", target->nick, target->uplink->name, target->uplink->description);
+ else {
+ reply("WBMSG_WHOIS_SERVER", target->nick, his_servername ? his_servername : target->uplink->name,
+ his_servercomment ? his_servercomment : target->uplink->description);
+ }
+
+ if (IsOper(target))
+ reply("WBMSG_WHOIS_OPER", target->nick);
+
+ if (IsService(target))
+ reply("WBMSG_WHOIS_SERVICE", target->nick);
+
+ if (target->handle_info)
+ reply("WBMSG_WHOIS_ACCOUNT", target->nick, target->handle_info->handle);
+
+ if ((target == user) && (target->fakehost || IsHiddenHost(target)))
+ reply("WBMSG_WHOIS_REALHOST", target->nick, target->ident, target->hostname, irc_ntoa(&target->ip));
+
+ if (target->handle_info) {
+ if (target->handle_info->epithet)
+ reply("WBMSG_WHOIS_SWHOIS", target->nick, target->handle_info->epithet);
+ }
+
+ if (target->mark)
+ reply("WBMSG_WHOIS_DNSBL", target->nick, target->mark);