X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=blobdiff_plain;f=src%2Fmodules%2FNeonServ.mod%2Fbot_NeonServ.c;fp=src%2Fmodules%2FNeonServ.mod%2Fbot_NeonServ.c;h=e6ec912caa8f8b61cf42e3e3780cb41b476f6368;hp=0000000000000000000000000000000000000000;hb=706e48b1e666054030c491d864f740071e390038;hpb=b53d0c5f88063f075a48a0426f9d5d6b3490b9fc diff --git a/src/modules/NeonServ.mod/bot_NeonServ.c b/src/modules/NeonServ.mod/bot_NeonServ.c new file mode 100644 index 0000000..e6ec912 --- /dev/null +++ b/src/modules/NeonServ.mod/bot_NeonServ.c @@ -0,0 +1,537 @@ +/* bot_NeonServ.c - NeonServ v5.3 + * Copyright (C) 2011-2012 Philipp Kreil (pk910) + * + * This program 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 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "../module.h" + +#include "bot_NeonServ.h" +#include "modcmd.h" +#include "IRCEvents.h" +#include "IRCParser.h" +#include "UserNode.h" +#include "ChanNode.h" +#include "ChanUser.h" +#include "BanNode.h" +#include "ModeNode.h" +#include "ClientSocket.h" +#include "mysqlConn.h" +#include "lang.h" +#include "HandleInfoHandler.h" +#include "WHOHandler.h" +#include "DBHelper.h" +#include "tools.h" +#include "timeq.h" +#include "EventLogger.h" +#include "cmd_neonserv.h" +#include "ConfigParser.h" + +#define BOTID 1 +#define BOTALIAS "NeonServ" + +static const struct default_language_entry msgtab[] = { + {"NS_USER_UNKNOWN", "User with nick $b%s$b does not exist."}, /* {ARGS: "TestUser"} */ + {"NS_AUTH_UNKNOWN", "Account $b%s$b has not been registered."}, /* {ARGS: "TestAuth"} */ + {"NS_USER_NEED_AUTH", "%s must first authenticate with $bAuthServ$b."}, /* {ARGS: "TestUser"} */ + {"NS_YOU_NEED_AUTH", "You must first authenticate with $bAuthServ$b."}, + {"NS_INVALID_ACCESS", "$b%d$b is an invalid access level."}, /* {ARGS: 1337} */ + {"NS_ADDUSER_ALREADY_ADDED", "%s is already on the $b%s$b user list (with access %d)."}, /* {ARGS: "TestUser", "#TestChan", 123} */ + {"NS_ADDUSER_DONE", "Added %s to the %s user list with access %d."}, /* {ARGS: "TestUser", "#TestChan", 123} */ + {"NS_NOT_ON_USERLIST", "%s lacks access to $b%s$b."}, /* {ARGS: "TestUser", "#TestChan"} */ + {"NS_NOT_ON_USERLIST_YOU", "You lack access to $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_NOT_ON_CHANNEL", "%s isn't currently in $b%s$b."}, /* {ARGS: "TestUser", "#TestChan"} */ + {"NS_NOT_ON_CHANNEL_YOU", "You aren't currently in $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_DELUSER_DONE", "Deleted %s (with access %d) from the %s user list."}, /* {ARGS: "TestUser", 123, "#TestChan"} */ + {"NS_ACCESS_OUTRANKED", "You cannot give users access greater than or equal to your own."}, + {"NS_USER_OUTRANKED", "$b%s$b outranks you (command has no effect)."}, /* {ARGS: "TestUser"} */ + {"NS_ACCESS_DENIED", "Access denied."}, + {"NS_NO_ACCESS", "You lack sufficient access to use this command."}, + {"NS_USER_PROTECTED", "Sorry, $b%s$b is protected."}, /* {ARGS: "TestUser"} */ + {"NS_SERVICE_IMMUNE", "$b%s$b may not be kicked, killed, banned, or deopped."}, /* {ARGS: "TestUser"} */ + {"NS_YOU_PROTECTED", "You may not kick or ban yourself."}, + {"NS_TABLE_NONE", " None"}, + {"NS_TABLE_COUNT", "Found $b%d$b matches."}, /* {ARGS: 5} */ + {"NS_BAN_ALREADY_ADDED", "$b%s$b is already banned in %s."}, /* {ARGS: "*!*@moeeep.*", "#TestChan"} */ + {"NS_INVALID_ACCESS_RANGE", "Invalid access range; minimum (%d) must be lower than maximum (%d)."}, /* {ARGS: 450, 400} */ + {"NS_CLVL_DONE", "%s now has access $b%d$b in %s."}, /* {ARGS: "TestUser", 123, "#TestChan"} */ + {"NS_A_LACKS_ACCESS_BUT_GOD_NICK", "%s lacks access to %s but has $bsecurity override$b enabled."}, /* {ARGS: "TestAuth", "#TestChan"} */ + {"NS_A_LACKS_ACCESS_BUT_GOD_AUTH", "%s (%s) lacks access to %s but has $bsecurity override$b enabled."}, /* {ARGS: "TestAuth", "TestUser", "#TestChan"} */ + {"NS_A_ACCESS_NICK", "%s has access $b%d$b in %s."}, /* {ARGS: "TestAuth", 123, "#TestChan"} */ + {"NS_A_ACCESS_AUTH", "%s (%s) has access $b%d$b in %s."}, /* {ARGS: "TestAuth", "TestUser", 123, "#TestChan"} */ + {"NS_A_ACCESS_NICK_GOD", "%s has access $b%d$b in %s and has $bsecurity override$b enabled."}, /* {ARGS: "TestAuth", 123, "#TestChan"} */ + {"NS_A_ACCESS_AUTH_GOD", "%s (%s) has access $b%d$b in %s and has $bsecurity override$b enabled."}, /* {ARGS: "TestAuth", "TestUser", 123, "#TestChan"} */ + {"NS_A_SUSPENDED", "$b%s$b's access to %s has been suspended."}, /* {ARGS: "TestAuth", "#TestChan"} */ + {"NS_A_IS_IRCOP", "%s is an $bIRC operator$b."}, /* {ARGS: "TestUser", "#TestChan"} */ + {"NS_USERS_HEADER", "%s users from level %d to %d:"}, /* {ARGS: "#TestChan", 1, 500} */ + {"NS_USERS_HEADER_MATCH", "%s users from level %d to %d matching %s:"}, /* {ARGS: "#TestChan", 1, 500, "Test*"} */ + {"NS_USERS_HEADER_ACCESS", "Access"}, + {"NS_USERS_HEADER_ACCOUNT", "Accout"}, + {"NS_USERS_HEADER_SEEN", "Last Seen"}, + {"NS_USERS_HEADER_STATE", "Status"}, + {"NS_USERS_COUNT", "There are $b%d$b users in %s."}, /* {ARGS: 20, "#TestChan"} */ + {"NS_USERS_COUNT_1", "There is $b%d$b user in %s."}, /* {ARGS: 1, "#TestChan"} */ + {"NS_USERS_COUNT_MATCH", "There are $b%d$b users in %s. ($b%d$b matching your request)"}, /* {ARGS: 20, "#TestChan", 5} */ + {"NS_USERS_COUNT_MATCH_1", "There is $b%d$b user in %s. ($b%d$b matching your request)"}, /* {ARGS: 1, "#TestChan", 1} */ + {"NS_USERS_SEEN_HERE", "Here"}, + {"NS_USERS_SEEN_INVISIBLE", "Here (invisible)"}, + {"NS_USERS_SEEN_NEVER", "Never"}, + {"NS_USERS_STATE_SUSPENDED", "Suspended"}, + {"NS_USERS_STATE_NORMAL", "Normal"}, + {"NS_SUSPEND_ALREADY", "$b%s$b is already suspended." }, /* {ARGS: "TestUser"} */ + {"NS_SUSPEND_NOT", "$b%s$b is not suspended." }, /* {ARGS: "TestUser"} */ + {"NS_SUSPEND_DONE", "$b%s$b's access to $b%s$b has been suspended." }, /* {ARGS: "TestUser", "#TestChan"} */ + {"NS_SUSPEND_RESTORED", "$b%s$b's access to $b%s$b has been restored." }, /* {ARGS: "TestUser", "#TestChan"} */ + {"NS_DELME_OWNER", "You cannot delete your owner access in $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_DELME_KEY", "To really remove yourself, you must use 'deleteme %s'."}, /* {ARGS: "abc123"} */ + {"NS_DELME_DONE", "Your $b%d$b access has been deleted from $b%s$b."}, /* {ARGS: 123, "#TestChan"} */ + {"NS_MYACCESS_SELF_ONLY", "You may only see the list of infolines for yourself (by using $bmyaccess$b with no arguments)."}, + {"NS_MYACCESS_HEADER", "Showing all channel entries for account $b%s$b:"}, /* {ARGS: "TestAuth"} */ + {"NS_MYACCESS_HEADER_MATCH", "Showing all channel entries for account $b%s$b matching %s:"}, /* {ARGS: "TestAuth", "#Test*"} */ + {"NS_MYACCESS_HEADER_NAME", "Name"}, + {"NS_MYACCESS_HEADER_ACCESS", "Access"}, + {"NS_MYACCESS_HEADER_FLAGS", "Flags"}, + {"NS_MYACCESS_HEADER_INFO", "Info"}, + {"NS_MYACCESS_COUNT", "%s has access in $b%d$b channel(s) and is owner of $b%d$b channel(s)."}, /* {ARGS: "TestUser", 15, 5} */ + {"NS_MYACCESS_COUNT_MATCH", "%s has access in $b%d$b channel(s) and is owner of $b%d$b channel(s) ($b%d$b channels matching your request)."}, /* {ARGS: "TestUser", 15, 5, 7} */ + {"NS_UP_ALREADY_OP", "You are already opped in $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_UP_ALREADY_VOICE", "You are already voiced in $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_DOWN_ALREADY", "You are not opped or voiced in $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_MDELUSER_DONE", "Deleted $b%d$b account(s) matching $b%s$b with access from $b%d$b to $b%d$b from the %s user list."}, /* {ARGS: 10, "Test*", 1, 200, "#TestChan"} */ + {"NS_TRIM_DURATION_TOO_SHORT", "You must include a minimum inactivity duration of at least %d seconds to trim."}, + {"NS_TRIM_DONE", "Trimmed $b%d users$b with access from %d to %d from the %s user list who were inactive for at least %s."}, /* {ARGS: 10, 1, 100, "#TestChan", "10 days"} */ + {"NS_TRIM_BAN_DONE", "Trimmed $b%d bans$b from the %s ban list who were banned for at least %s."}, /* {ARGS: 5, "#TestChan", "1 day"} */ + {"NS_GIVEOWNER_SELF", "You cannot give ownership to your own account."}, + {"NS_GIVEOWNER_TIMEOUT", "You must wait %s before you can give ownership of $b%s$b to someone else."}, /* {ARGS: "5 hours", "#TestChan"} */ + {"NS_GIVEOWNER_CONFIRM", "To really give ownership to $b%1$s$b, you must use 'giveownership *%1$s %2$s'."}, /* {ARGS: "TestUser", "abc123"} */ + {"NS_GIVEOWNER_DONE", "Ownership of $b%s$b has been transferred to account $b%s$b."}, /* {ARGS: "#TestChan", "TestUser"} */ + {"NS_OP_FAIL", "$b%s$b could not op some of the nicks you provided."}, /* {ARGS: "NeonServ"} */ + {"NS_OP_DONE", "Opped users in $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_HALFOP_FAIL", "$b%s$b could not halfop some of the nicks you provided."}, /* {ARGS: "NeonServ"} */ + {"NS_HALFOP_DONE", "Half-Opped users in $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_VOICE_FAIL", "$b%s$b could not voice some of the nicks you provided."}, /* {ARGS: "NeonServ"} */ + {"NS_VOICE_DONE", "Voiced users in $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_DEOP_FAIL", "$b%s$b could not deop some of the nicks you provided."}, /* {ARGS: "NeonServ"} */ + {"NS_DEOP_DONE", "Deopped users in $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_DEHALFOP_FAIL", "$b%s$b could not dehalfop some of the nicks you provided."}, /* {ARGS: "NeonServ"} */ + {"NS_DEHALFOP_DONE", "Dehalfopped users in $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_DEVOICE_FAIL", "$b%s$b could not devoice some of the nicks you provided."}, /* {ARGS: "NeonServ"} */ + {"NS_DEVOICE_DONE", "Devoiced users in $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_OPALL_SECURITY", "$bWARNING$b: Opping all users on a channel is very insecure! If you still want do op all users on %s use: '$bopall FORCE$b [nick mask]'"}, + {"NS_OPALL_DONE", "Opped $b%d$b users in %s."}, /* {ARGS: 20, "#TestChan"} */ + {"NS_HALFOPALL_DONE", "Half-Opped $b%d$b users in %s."}, /* {ARGS: 20, "#TestChan"} */ + {"NS_VOICEALL_DONE", "Voiced $b%d$b users in %s."}, /* {ARGS: 20, "#TestChan"} */ + {"NS_DEOPALL_DONE", "Deopped $b%d$b users in %s."}, /* {ARGS: 20, "#TestChan"} */ + {"NS_DEHALFOPALL_DONE", "Dehalfopped $b%d$b users in %s."}, /* {ARGS: 20, "#TestChan"} */ + {"NS_DEVOICEALL_DONE", "Devoiced $b%d$b users in %s."}, /* {ARGS: 20, "#TestChan"} */ + {"NS_KICK_DONE", "Kicked $b%d$b users from %s"}, /* {ARGS: 20, "#TestChan"} */ + {"NS_KICK_FAIL", "$b%s$b could not kick some of the nicks you provided."}, /* {ARGS: "NeonServ"} */ + {"NS_KICKBAN_DONE", "KickBanned $b%d$b users from %s"}, /* {ARGS: 10, "#TestChan"} */ + {"NS_KICKBAN_FAIL", "$b%s$b could not kickban some of the nicks you provided."}, /* {ARGS: "NeonServ"} */ + {"NS_BAN_DONE", "$b%d$b masks added to the %s ban list. (matching %d users)"}, /* {ARGS: 5, "#TestChan", 15} */ + {"NS_BAN_FAIL", "$b%s$b could not ban some of the nicks you provided."}, /* {ARGS: "NeonServ"} */ + {"NS_LAME_MASK", "$b%s$b is a little too general. Try making it more specific."}, /* {ARGS: "*!*@*"} */ + {"NS_LAME_MASK_WARNING", "$k4WARNING$k: $b%s$b is very general. (matches %d users)"}, + {"NS_SET_HEADER", "Channel Settings for %s:"}, /* {ARGS: "#TestChan"} */ + {"NS_SET_ON", "on"}, + {"NS_SET_OFF", "off"}, + {"NS_SET_UNKNOWN_SETTING", "$b%s$b is an unknown channel setting."}, /* {ARGS: "TestSetting"} */ + {"NS_SET_CANNOT_SET", "That setting is above your current level, so you cannot change it."}, + {"NS_SET_BADLEVEL", "You cannot change any setting to above your level."}, + {"NS_SET_INVALID_OPTION", "$b%d$b is not a valid choice. Choose one:"}, /* {ARGS: 5} */ + {"NS_SET_INVALID_BOOLEAN", "$b%s$b is an invalid binary value."}, /* {ARGS: 2} */ + {"NS_SET_DEFAULTS_OWNER", "You must have access 500 in %s to reset it to the default options."}, /* {ARGS: "#TestChan"} */ + {"NS_SET_DEFAULTS_CODE", "To reset %s's settings to the defaults, you must use 'set defaults %s'."}, /* {ARGS: "#TestChan", "abc123"} */ + {"NS_SET_DEFAULTS_DONE", "All settings for %s have been reset to default values."}, /* {ARGS: "#TestChan"} */ + {"NS_SET_TRIGGER_OWNER", "You must have access 500 in %s to change the channel trigger."}, /* {ARGS: "#TestChan"} */ + {"NS_SET_HELP_USERINFO","(access to set the userinfo)"}, + {"NS_SET_HELP_WIPEINFO","(access to clear the userinfo of other users)"}, + {"NS_SET_HELP_INVITEME","(access to get invited by the bot)"}, + {"NS_SET_HELP_ENFVOICE","(access to give voice to other users)"}, + {"NS_SET_HELP_ENFOPS","(access to give op to their users)"}, + {"NS_SET_HELP_GIVEOPS","(access to get op by the bot)"}, + {"NS_SET_HELP_GIVEVOICE","(access to get voice by the bot)"}, + {"NS_SET_HELP_KICK","(access to kick other users from the channel)"}, + {"NS_SET_HELP_BAN","(access to ban other users from the channel)"}, + {"NS_SET_HELP_STATICBAN","(access to add static bans to the channel banlist e.g. +addban)"}, + {"NS_SET_HELP_PUBCMD","(access to do public commands in the channel e.g. +users)"}, + {"NS_SET_HELP_ENFMODES","(access to override the modelock)"}, + {"NS_SET_HELP_ENFTOPIC","(access to override the topicmask)"}, + {"NS_SET_HELP_TOPICSNARF","(access to set the default topic by changing the topic with /TOPIC)"}, + {"NS_SET_HELP_CHANGETOPIC","(access to change the topic)"}, + {"NS_SET_HELP_SETTERS","(access to change this settings)"}, + {"NS_SET_HELP_ADDUSER","(access to add an user to the userlist)"}, + {"NS_SET_HELP_DELUSER","(access to delete an user from the userlist)"}, + {"NS_SET_HELP_CLVL","(access to change the access of an user in the userlist)"}, + {"NS_SET_HELP_RESYNC","(access to synchronize the channelrights (@,+) with the userlist)"}, + {"NS_SET_HELP_SUSPEND","(access to suspend an user on the userlist)"}, + {"NS_SET_OPTION_CTCPREACTION_0","Kick on disallowed CTCPs"}, + {"NS_SET_OPTION_CTCPREACTION_1","Kickban on disallowed CTCPs"}, + {"NS_SET_OPTION_CTCPREACTION_2","Short timed ban on disallowed CTCPs"}, + {"NS_SET_OPTION_CTCPREACTION_3","Long timed ban on disallowed CTCPs"}, + {"NS_SET_OPTION_NOTICEREACTION_0","Kick on disallowed NOTICEs"}, + {"NS_SET_OPTION_NOTICEREACTION_1","Kickban on disallowed NOTICEs"}, + {"NS_SET_OPTION_NOTICEREACTION_2","Short timed ban on disallowed NOTICEs"}, + {"NS_SET_OPTION_NOTICEREACTION_3","Long timed ban on disallowed NOTICEs"}, + {"NS_SET_OPTION_PROTECT_0","All users will be protected from users with equal or lower access."}, + {"NS_SET_OPTION_PROTECT_1","All users with access will be protected from users with equal or lower access."}, + {"NS_SET_OPTION_PROTECT_2","All users with access will be protected from user with lower access."}, + {"NS_SET_OPTION_PROTECT_3","Nobody will be protected."}, + {"NS_SET_OPTION_TOYS_0","Funcommands can't be used."}, + {"NS_SET_OPTION_TOYS_1","Funcommands are possible but the reply will be sent as a notice."}, + {"NS_SET_OPTION_TOYS_2","Funcommands are possible and the reply will be sent to the channel."}, + {"NS_SET_OPTION_DYNLIMIT_0","off"}, + {"NS_SET_OPTION_NODELETE_0","off (only bot masters)"}, + {"NS_SET_OPTION_NODELETE_1","on (only bot masters)"}, + {"NS_WIPEINFO_DONE", "Removed $b%s$b's infoline in $b%s$b."}, /* {ARGS: "TestUser", "#TestChan"} */ + {"NS_TRACE_HEADER", "The following users were found:"}, + {"NS_ADDBAN_DONE", "$b%s$b permantly added to the %s ban list. (matching %d users)"}, /* {ARGS: "*!*@Test.*", "#TestChan", 4} */ + {"NS_BANS_HEADER_MASK", "Mask"}, + {"NS_BANS_HEADER_SETBY", "Set By"}, + {"NS_BANS_HEADER_TRIGGERED", "Triggered"}, + {"NS_BANS_HEADER_EXPIRES", "Expires"}, + {"NS_BANS_HEADER_REASON", "Reason"}, + {"NS_DELBAN_BANNED_BY", "%s is banned by %s."}, /* {ARGS: "*!*@bla*", "*!*@b*"} */ + {"NS_DELBAN_FAIL", "Sorry, no ban found for $b%s$b."}, /* {ARGS: "*!*@bla*"} */ + {"NS_DELBAN_DONE", "Removed $b%s$b from the %s ban list."}, /* {ARGS: "*!*@bla.*", "#TestChan"} */ + {"NS_NETINFO_HEADER", "$bNetwork information$b"}, + {"NS_NETINFO_BOTS", "Bots:"}, + {"NS_NETINFO_UPTIME", "Uptime:"}, + {"NS_NETINFO_TRAFFIC", "Traffic:"}, + {"NS_NETINFO_CACHE", "Cache:"}, + {"NS_NETINFO_DATABASE", "Database:"}, + {"NS_NETINFO_CHANNEL", " Channel:"}, + {"NS_NETINFO_CHANNEL_BAN", " Bans:"}, + {"NS_NETINFO_USER", " User:"}, + {"NS_NETINFO_CHANUSER", " Channel-User:"}, + {"NS_NETINFO_OTHER", " Other:"}, + {"NS_NETINFO_THREADS", "Threads:"}, + {"NS_NETINFO_VERSION", "Version:"}, + {"NS_NETINFO_CODE", "Code:"}, + {"NS_NETINFO_CODE_VALUE", "%s lines c code (view it at http://dev.pk910.de/NeonServ)"}, /* {ARGS: 20} */ + {"NS_NETINFO_COMPILER", "Compiler:"}, + {"NS_NETINFO_COMPILER_VALUE", "%s (%s)"}, /* {ARGS: "GCC 4.4.5", "Sun Sep 18 2011 at 05:21:33 CEST"} */ + {"NS_EXTTOPIC_INVALID_ID", "ADVANCEDTOPIC is enabled and $b%s$b is an invalid TOPIC ID. Valid topic id's are: 1-9"}, /* {ARGS: 10} */ + {"NS_EXTTOPIC_TOPICID", "Topic %d: %s"}, /* {ARGS: 5, "topic"} */ + {"NS_TOPIC_DONE", "Topic is now '%s'."}, /* {ARGS: "i like you :D"} */ + {"NS_CHANSERVSYNC_UNSUPPORTED", "\0034WARNING\003: the user list style of %s is not known. %s can try to synchronize the userlist, but there is no guarantee that it is successful!"}, /* {ARGS: "CowBot"} */ + {"NS_CHANSERVSYNC_KEY", "If you really want to synchronize the %s userlist with %s use: chanservsync %s %s"}, /* {ARGS: "#TestChan", "CowBot", "CowBot", "abc123"} */ + {"NS_CHANSERVSYNC_INUSE", "$bchanservsync$b is already in use by someone else. Please try again in a few seconds..."}, + {"NS_CHANSERVSYNC_SYNCHRONIZING", "Synchronizing userlist in %s with $b%s$b..."}, /* {ARGS: "#TestChan", "CowBot"} */ + {"NS_CHANSERVSYNC_SYNCHRONIZED", "Synchronized user $b%s$b: access $b%d$b"}, /* {ARGS: "TestUser", 123} */ + {"NS_REGISTER_ALREADY", "%s is already registered with %s."}, /* {ARGS: "#TestChan", "NeonServ"} */ + {"NS_INVALID_CHANNEL_NAME", "%s is not a valid channel name."}, /* {ARGS: "#invalid"} */ + {"NS_REGISTER_FULL", "the bot can not join more channels."}, + {"NS_REGISTER_DISCONNECTED", "%s has been registered with a Bot, that is currently NOT connected. The Bot should join the channel, when it reconnects to the IRC-Network."}, /* {ARGS: "#TestChan"} */ + {"NS_REGISTER_DONE", "$b%s$b is now registered to $b%s$b."}, /* {ARGS: "#TestChan", "TestUser"} */ + {"NS_REGISTER_DONE_NOAUTH", "$b%s$b is now registered."}, /* {ARGS: "#TestChan"} */ + {"NS_UNREGISTER_NOT_REGISTERED", "$b%s$b is not registered with %s."}, /* {ARGS: "#TestChan", "NeonServ"} */ + {"NS_UNREGISTER_DONE", "$b%s$b unregistered."}, /* {ARGS: "#TestChan"} */ + {"NS_RECOVER_DONE", "$b%s$b has been recovered."}, /* {ARGS: "#TestChan"} */ + {"NS_RESYNC_DONE", "Synchronized users in $b%s$b with the userlist."}, /* {ARGS: "#TestChan"} */ + {"NS_TIMEBAN_DURATION_TOO_SHORT", "You must specify a ban duration of at least %d seconds."}, /* {ARGS: 30} */ + {"NS_TIMEBAN_DONE", "Banned $b%s$b from %s for %s. (matching %d users)"}, /* {ARGS: "*!*@bla*", "#TestChan", "2 hours", 5} */ + {"NS_MODE_INVALID", "$b%c$b is an invalid set of channel modes."}, /* {ARGS: "+xyz"} */ + {"NS_MODE_LOCKED", "Modes conflicting with $b%s$b are not allowed in %s."}, /* {ARGS: "+xyz", "#TestChan"} */ + {"NS_MODE_DONE", "Channel modes are now $b%s$b."}, /* {ARGS: "+xyz"} */ + {"NS_MODE_ENFOPS", "You may not op or deop users on $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_MODE_ENFVOICE", "You may not voice or devoice users on $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_MODE_CANBAN", "You may not ban or unban users on $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_GOD_ON", "Security override has been enabled."}, + {"NS_GOD_OFF", "Security override has been disabled."}, + {"NS_PEEK_HEADER", "$b%s$b Status:"}, /* {ARGS: "#TestChan"} */ + {"NS_PEEK_TOPIC", "Topic: %s"}, /* {ARGS: "TOPIC"} */ + {"NS_PEEK_MODES", "Modes: %s"}, /* {ARGS: "+xyz"} */ + {"NS_PEEK_USERS", "Total Users: %d (%d ops, %d voices, %d regulars, %d invisible)"}, /* {ARGS: 20, 4, 6, 8, 2} */ + {"NS_PEEK_USERS_HALFOP", "Total Users: %d (%d ops, %d halfops, %d voices, %d regulars, %d invisible)"}, /* {ARGS: 25, 5, 4, 6, 8, 2} */ + {"NS_PEEK_OPS", "Ops:"}, + {"NS_USET_GLOBAL", "$b--- Global ---$b"}, + {"NS_USET_CHANNEL", "$b--- User options (channel) ---$b"}, + {"NS_USET_NO_ACCESS", "no access"}, + {"NS_USET_UNKNOWN_SETTING", "$b%s$b is an unknown uset setting."}, /* {ARGS: "TestSetting"} */ + {"NS_RELOADLANG_UNKNOWN", "$b%s$b is an unknown language tag."}, /* {ARGS: "de"} */ + {"NS_RELOADLANG_DONE", "$b%s$b (%s) reloaded."}, /* {ARGS: "Deutsch", "de"} */ + {"NS_UNBAN_DONE", "$b%d$b masks removed from the %s ban list."}, /* {ARGS: 5, "#TestChan"} */ + {"NS_UNBAN_FAIL", "$b%s$b could not unban some of the masks you provided."}, /* {ARGS: "NeonServ"} */ + {"NS_UNBANALL_DONE", "all $b%d$b masks removed from the %s ban list."}, /* {ARGS: 5, "#TestChan"} */ + {"NS_UNBANALL_FAIL", "$b%s$b could not find any bans in %s."}, /* {ARGS: "NeonServ", "#TestChan"} */ + {"NS_UNBANME_DONE", "removed $b%d$b masks from the %s ban list."}, /* {ARGS: 5, "#TestChan"} */ + {"NS_UNBANME_FAIL", "$b%s$b could not find any bans matching %s."}, /* {ARGS: "NeonServ", "TestUser!TestIdent@TestUser.user.WebGamesNet"} */ + {"NS_INVITE_RESTRICTION", "%s doesn't want to be invited to %s."}, /* {ARGS: "TestUser", "#TestChan"} */ + {"NS_INVITE_TIMEOUT", "%s has already been invited to $b%s$b."}, /* {ARGS: "TestUser", "#TestChan"} */ + {"NS_INVITE_ON_CHAN", "%s is already in $b%s$b."}, /* {ARGS: "TestUser", "#TestChan"} */ + {"NS_INVITE_DONE_USER", "You have been invited to join $b%s$b by %s. (Do $b/msg %s %1$s uset noinvite 1$b if you don't want to be invited to %1$s anymore.)"}, /* {ARGS: "#TestChan", "TestUser", "NeonServ"} */ + {"NS_INVITE_DONE", "Invited $b%s$b to join %s."}, /* {ARGS: "TestUser", "#TestChan"} */ + {"NS_INVITEME_ON_CHAN", "You are already in $b%s$b."}, /* {ARGS: "#TestChan"} */ + {"NS_INVITEME_DONE", "You have been invited to join %s."}, /* {ARGS: "#TestChan"} */ + {"NS_HELP_TOPIC", "No help on that topic."}, + {"NS_CSUSPEND_ALREADY", "$b%s$b is already suspended."}, /* {ARGS: "#TestChan"} */ + {"NS_CSUSPEND_DONE", "Channel $b%s$b has been temporarily suspended."}, /* {ARGS: "#TestChan"} */ + {"NS_CUNSUSPEND_NOT", "$b%s$b is not suspended."}, /* {ARGS: "#TestChan"} */ + {"NS_CUNSUSPEND_DONE", "Channel $b%s$b has been restored."}, /* {ARGS: "#TestChan"} */ + {"NS_MOVE_SUSPENDED", "Moving cannot be performed if the source channel is suspended."}, + {"NS_MOVE_SELF", "Moving cannot be performed if the source and target channels are the same."}, + {"NS_MOVE_DONE", "Channel $b%s$b has been moved to $b%s$b."}, /* {ARGS: "#TestChan", "#NewTestChan"} */ + {"NS_BIND_ALREADY", "$b%s$b is already bound to %s."}, /* {ARGS: "TestCommand", "TestFunction"} */ + {"NS_BIND_UNKNOWN", "$b%s$b is an undefined function."}, /* {ARGS: "TestFunction"} */ + {"NS_BIND_DONE", "New command $b%s$b bound to %s."}, /* {ARGS: "TestCommand", "TestFunction"} */ + {"NS_UNBIND_NOT_FOUND", "There is no command called $b%s$b bound."}, /* {ARGS: "TestCommand"} */ + {"NS_UNBIND_DONE", "Unbound command $b%s$b."}, /* {ARGS: "TestCommand"} */ + {"NS_EVENTS_HEADER", "The following channel events were found:"}, + {"NS_OPLOG_HEADER", "The following oper events were found:"}, + {"NS_SEARCH_HEADER", "The following channels were found:"}, + {"NS_COMMAND_BINDING", "$b%s$b is a binding of %s %s"}, /* {ARGS: "TestCommand", "TestFunction", "TestParameters"} */ + {"NS_COMMAND_ACCESS", "You need at least %d channel access and %d oper access to execute this command."}, /* {ARGS: 500, 100} */ + {"NS_TOPIC_ACCESS", "You lack sufficient access in %s to change the topic."}, /* {ARGS: "#TestChan"} */ + {"NS_BOTWAR_DETECTED", "$b$k4BOTWAR DETECTED!$k Please check the channel configuration!$b"}, + {"NS_BOTWAR_REPORTED", "A supporter has been informed to help you preventing botwars in the future."}, + {"NS_BOTWAR_ALERT", "$b$k4BOTWAR ALERT:$k$b Botwar in $b%s$b detected. (opponent: $b%s$b) Please join and help them preventing Botwars."}, /* {ARGS: "#TestChan", "OtherBot"} */ + {"NS_INVITE_FAIL", "$b%s$b is not registered with %s or suspended."}, /* {ARGS: "#TestChan", "NeonServ"} */ + {"NS_SETACCESS_DONE", "$b%s$b has now %d global access."}, /* {ARGS: "TestUser", 1000} */ + {"NS_ADDRANK_EXISTS", "Another support ranking called '$b%s$b' already exists."}, /* {ARGS: "Supporter"} */ + {"NS_ADDRANK_DONE", "Support ranking '$b%s$b' created."}, /* {ARGS: "Supporter"} */ + {"NS_DELRANK_NOT_FOUND", "There is no support ranking called '$b%s$b'."}, /* {ARGS: "Supporter"} */ + {"NS_DELRANK_DELETED", "Support ranking called '$b%s$b' removed."}, /* {ARGS: "Supporter"} */ + {"NS_LISTRANK_ID", "Id"}, + {"NS_LISTRANK_NAME", "Name"}, + {"NS_LISTRANK_ASSIGNED", "Assigned to"}, + {"NS_LISTRANK_UNRANKED", "There are also %d unranked users with global access."}, /* {ARGS: 10} */ + {"NS_SETRANK_NOT_FOUND", "There is no support ranking with ID '$b%s$b'."}, /* {ARGS: 42} */ + {"NS_SETRANK_HEAD", "Support ranking settings for Id %s:"}, /* {ARGS: 42} */ + {"NS_SETRANK_UNKNOWN_SETTING", "$b%s$b is an unknown support rank setting."}, /* {ARGS: "moep"} */ + {"NS_SETRANK_ORDER_INVALID", "%d is an invalid numeric value. (valid: 1-99)"}, /* {ARGS: 100} */ + {"NS_ASSIGNRANK_DONE", "$b%s$b is now ranked as '$b%s$b'."}, /* {ARGS: "TestUser", "Supporter"} */ + {"NS_INFO_HEADER", "$b%s$b Information:"}, /* {ARGS: "#TestChan"} */ + {"NS_INFO_DEFAULTTOPIC", "Default Topic:"}, + {"NS_INFO_MODELOCK", "Mode Lock:"}, + {"NS_INFO_RECORD", "Record Visitors:"}, + {"NS_INFO_OWNER", "Owner:"}, + {"NS_INFO_USERS", "Total User Count:"}, + {"NS_INFO_BANS", "Ban Count:"}, + {"NS_INFO_VISITED", "Visited:"}, + {"NS_INFO_REGISTERED", "Registered:"}, + {"NS_INFO_REGISTRAR", "Registered by:"}, + {"NS_INFO_OWNERLOG", "Ownership transfer history for $b%s$b:"}, /* {ARGS: "#TestChan"} */ + {"NS_INFO_OWNERCHANGE", " from %s to %s on %s"}, + {"NS_RENAME_DONE", "Renamed $b%s$b to $b%s$b."}, /* {ARGS: "TestUser", "TestUser2"} */ + {"NS_RENAME_FAIL", "Failed renaming $b%s$b."}, /* {ARGS: "TestUser"} */ + {"NS_FUN_DISABLED", "Fun commands are disabled in %s."}, /* {ARGS: "#TestChan"} */ + {"NS_UNBIND_REQUIRED", "%1$s is a required function and there is no other command bound to %1$s. Bind another command to %1$s first."}, /* {ARGS: "bind"} */ + {"NS_COMMANDS_NAME", "Name"}, + {"NS_COMMANDS_ACCESS", "Access"}, + {"NS_COMMANDS_GACCESS", "GodAccess"}, + {"NS_COMMANDS_TRIGGERED", "Triggered"}, + {"NS_COMMANDS_FUNCTION", "Function"}, + {"NS_DNR_SET", "$b%s$b is do-not-register (by $b%s$b): %s" }, /* {ARGS: "#TestChan", "TestUser", "because of it is like it is"} */ + {"NS_DNR_SET_EXPIRES", "$b%s$b is do-not-register (by $b%s$b; expires %s): %s" }, /* {ARGS: "#TestChan", "TestUser", "1 day", "because of it is like it is"} */ + {"NS_DNR_SET_ANONYM", "$b%s$b is do-not-register. Please contact the support to get more information."}, /* {ARGS: "TestUser"} */ + {"NS_NOREGISTER_INVALID_DURATION", "$b%s$b is not a valid duration."}, /* {ARGS: "möp"} */ + {"NS_NOREGISTER_REGISTERED", "$b%s$b is currently registered and can't be added to the do-not-register list."}, /* {ARGS: "#TestChan"} */ + {"NS_NOREGISTER_DONE", "added $b%s$b to the do-not-register list."}, /* {ARGS: "#TestChan"} */ + {"NS_NOREGISTER_HEAD", "The following do-not-registers were found:"}, + {"NS_DNR_TARGET", "Target"}, + {"NS_DNR_USER", "Issuer"}, + {"NS_DNR_EXPIRES", "Expires"}, + {"NS_DNR_REASON", "Reason"}, + {"NS_STAFF_LOGGEDIN", "Logged in as"}, + {"NS_BOTS_ID", "Id"}, + {"NS_BOTS_NICK", "Nick"}, + {"NS_BOTS_SERVER", "Server:Port(:Pass)"}, + {"NS_BOTS_CLASS", "Bot Class"}, + {"NS_BOTS_FLAGS", "Flags"}, + {"NS_BOTS_CHANNELS", "Channels"}, + {"NS_BOTS_TRIGGER", "Trigger"}, + {"NS_NICKLIST_NICK", "Nick"}, + {"NS_NICKLIST_STATE", "State"}, + {"NS_NICKLIST_ACCESS", "Access"}, + {"NS_NICKLIST_SYNC", "use `nicklist sync` to fix all red and orange entrys in the list above (add opped users with %d and voiced with %d access)"}, + {"NS_SETBOT_UNKNOWN", "`%d` is an unknown botid."}, /* {ARGS: 50} */ + {"NS_SETBOT_HEADER", "$bSettings for botid `%d`:$b"}, /* {ARGS: 50} */ + {"NS_SETBOT_SETTING", "$b%s$b is an unknown bot setting."}, /* {ARGS: "strangeSetting"} */ + {"NS_SETBOT_NICK_INVALID", "`%s` is an invalid botnick."}, /* {ARGS: "-SuperMagicBananaBotWithManyFunctions"} */ + {"NS_SETBOT_NEED_RESTART", "You need to reconnect the bot to apply this setting."}, + {"NS_SETBOT_PORT_INVALID", "`%s` is an invalid port number."}, /* {ARGS: "-1"} */ + {"NS_SETBOT_INVALID_CLASS", "`%s` is an invalid botclass."}, /* {ARGS: "MistColaLeer"} */ + {"NS_SETBOT_MAXCHAN_INVALID", "`%s` is an invalid maxchan value."}, /* {ARGS: "-1"} */ + {"NS_SETBOT_PRIORITY_INVALID", "`%s` is an invalid priority value."}, /* {ARGS: "-1"} */ + {"NS_SETBOT_TRIGGER_INVALID", "`%s` is an invalid bot trigger."}, /* {ARGS: "tooLongTrigger"} */ + {"NS_SETBOT_TRIGGER_NOTE", "Please note: This Setting will only affect new channels."}, + {"NS_ADDBOT_EXISTING", "A bot with nick %s does already exist."}, /* {ARGS: "NeonServ"} */ + {"NS_ADDBOT_DONE", "Added %s with BotID $b%d$b."}, /* {ARGS: "NeonServ", 2} */ + {"NS_DELBOT_NOT_FOUND", "Bot with BotID / nick $b%s$b not found."}, /* {ARGS: "NeonServ"} */ + {"NS_DELBOT_DONE", "Bot deleted."}, + {"NS_RECONNECT_DONE", "Reconnected bot."}, + {"NS_MODCMD_SETTING", "$b%s$b is an unknown modcmd setting."}, /* {ARGS: "strangeSetting"} */ + {"NS_MODCMD_HEADER", "$bSettings for command %s:$b"}, /* {ARGS: "access"} */ + {"NS_MODCMD_OUTRANKED", "$b%s$b outranks you. (required access: %d)"}, /* {ARGS: "die", 1000} */ + {"NS_MODCMD_STATIC_FLAG", "This Flag is added statically. It can't be modified manually."}, + {"NS_MEMINFO_DISABLED", "Memory Debugger is disabled!"}, + {"NS_MEMINFO_NAME", "Name"}, + {"NS_MEMINFO_COUNT", "Count"}, + {"NS_MEMINFO_SIZE", "Size"}, + {"NS_MEMINFO_LINE", "Line"}, + {"NS_MEMINFO_TOTAL", "Total"}, + {NULL, NULL} +}; + +/* TODO: +cmd_neonserv_open.c +set modelock +cmd_neonserv_modcmd.c +cmd_neonserv_allowregister.c +cmd_neonserv_noregister.c +cmd_neonserv_expire.c +cmd_neonserv_unvisited.c +cmd_neonserv_merge.c +cmd_neonserv_dnrsearch.c +cmd_neonserv_iplocate.c +cmd_neonserv_calc.c +*/ +//EVENTS +#include "event_neonserv_join.c" +#include "event_neonserv_part.c" +#include "event_neonserv_quit.c" +#include "event_neonserv_kick.c" +#include "event_neonserv_mode.c" +#include "event_neonserv_ctcp.c" +#include "event_neonserv_notice.c" +#include "event_neonserv_invite.c" +#include "event_neonserv_topic.c" + + +struct ClientSocket *getBotForChannel(struct ChanNode *chan) { + return getChannelBot(chan, BOTID); +} + +static void neonserv_bot_ready(struct ClientSocket *client) { + MYSQL_RES *res; + MYSQL_ROW row; + + printf_mysql_query("SELECT `automodes` FROM `bots` WHERE `id` = '%d'", client->clientid); + res = mysql_use(); + if ((row = mysql_fetch_row(res)) != NULL) { + putsock(client, "MODE %s +%s", client->user->nick, row[0]); + } + + printf_mysql_query("SELECT `channel_name`, `channel_key` FROM `bot_channels` LEFT JOIN `channels` ON `chanid` = `channel_id` WHERE `botid` = '%d' AND `suspended` = '0'", client->clientid); + res = mysql_use(); + + while ((row = mysql_fetch_row(res)) != NULL) { + putsock(client, "JOIN %s %s", row[0], row[1]); + } +} + +static void neonserv_trigger_callback(int clientid, struct ChanNode *chan, char *trigger) { + MYSQL_RES *res; + MYSQL_ROW row; + loadChannelSettings(chan); + if(!(chan->flags & CHANFLAG_CHAN_REGISTERED)) { + strcpy(trigger, "+"); + return; + } + printf_mysql_query("SELECT `trigger`, `defaulttrigger` FROM `bot_channels` LEFT JOIN `bots` ON `botid` = `bots`.`id` WHERE `chanid` = '%d' AND `botclass` = '%d'", chan->channel_id, BOTID); + res = mysql_use(); + if(!(row = mysql_fetch_row(res))) { + strcpy(trigger, "+"); + return; + } + if(row[0] && *row[0]) + strcpy(trigger, row[0]); + else + strcpy(trigger, ((row[1] && *row[1]) ? row[1] : "~")); +} + +static void start_bots(int type) { + struct ClientSocket *client; + MYSQL_RES *res, *res2; + MYSQL_ROW row; + + if(type == MODSTATE_STARTSTOP) { + printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID); + res = mysql_use(); + while ((row = mysql_fetch_row(res)) != NULL) { + client = create_socket(row[3], atoi(row[4]), row[10], row[5], row[0], row[1], row[2]); + client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0); + client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0); + client->flags |= (strcmp(row[9], "0") ? SOCKET_FLAG_SSL : 0); + client->botid = BOTID; + client->clientid = atoi(row[7]); + connect_socket(client); + } + } + + printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access`, `chan_access`, `flags` FROM `bot_binds` WHERE `botclass` = '%d'", BOTID); + res2 = mysql_use(); + while ((row = mysql_fetch_row(res2)) != NULL) { + if(bind_cmd_to_command(BOTID, row[0], row[1])) { + if(row[2] && strcmp(row[2], "")) { + bind_set_parameters(BOTID, row[0], row[2]); + } + if(row[3]) { + bind_set_global_access(BOTID, row[0], atoi(row[3])); + } + if(row[4]) { + bind_set_channel_access(BOTID, row[0], row[4]); + } + if(strcmp(row[5], "0")) + bind_set_bind_flags(BOTID, row[0], atoi(row[5])); + } + } + bind_unbound_required_functions(BOTID); +} + +void init_NeonServ(int type) { + set_bot_alias(BOTID, BOTALIAS); + start_bots(type); + + if(type == MODSTATE_REBIND) return; + + //register events + bind_bot_ready(neonserv_bot_ready, module_id); + bind_join(neonserv_event_join, module_id); + bind_part(neonserv_event_part, module_id); + bind_quit(neonserv_event_quit, module_id); + bind_chanctcp(neonserv_event_chanctcp, module_id); + bind_privctcp(general_event_privctcp, module_id); + bind_channotice(neonserv_event_channotice, module_id); + bind_topic(neonserv_event_topic, module_id); + bind_invite(neonserv_event_invite, module_id); + bind_mode(neonserv_event_mode, module_id); + bind_kick(neonserv_event_kick, module_id); + + set_trigger_callback(BOTID, module_id, neonserv_trigger_callback); + + register_default_language_table(msgtab); +} + +void loop_NeonServ() { + +} + +void free_NeonServ(int type) { + unbind_allcmd(BOTID); + if(type == MODSTATE_STARTSTOP) { + //disconnect all our bots + struct ClientSocket *client; + for(client = getBots(0, NULL); client; client = getBots(0, client)) { + if(client->botid == BOTID) { + unbind_botwise_allcmd(0, client->clientid); + close_socket(client); + break; + } + } + } +} + +#undef BOTID +#undef BOTALIAS