1 /* bot_NeonServ.c - NeonServ v5.3
2 * Copyright (C) 2011-2012 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "../module.h"
19 #include "bot_NeonServ.h"
20 #include "../../modcmd.h"
21 #include "../../IRCEvents.h"
22 #include "../../IRCParser.h"
23 #include "../../UserNode.h"
24 #include "../../ChanNode.h"
25 #include "../../ChanUser.h"
26 #include "../../BanNode.h"
27 #include "../../ModeNode.h"
28 #include "../../ClientSocket.h"
29 #include "../../mysqlConn.h"
30 #include "../../lang.h"
31 #include "../../HandleInfoHandler.h"
32 #include "../../WHOHandler.h"
33 #include "../../DBHelper.h"
34 #include "../../tools.h"
35 #include "../../timeq.h"
36 #include "../../EventLogger.h"
37 #include "cmd_neonserv.h"
38 #include "../../ConfigParser.h"
41 #define BOTALIAS "NeonServ"
43 static const struct default_language_entry msgtab[] = {
44 {"NS_USER_UNKNOWN", "User with nick $b%s$b does not exist."}, /* {ARGS: "TestUser"} */
45 {"NS_AUTH_UNKNOWN", "Account $b%s$b has not been registered."}, /* {ARGS: "TestAuth"} */
46 {"NS_USER_NEED_AUTH", "%s must first authenticate with $bAuthServ$b."}, /* {ARGS: "TestUser"} */
47 {"NS_YOU_NEED_AUTH", "You must first authenticate with $bAuthServ$b."},
48 {"NS_INVALID_ACCESS", "$b%d$b is an invalid access level."}, /* {ARGS: 1337} */
49 {"NS_ADDUSER_ALREADY_ADDED", "%s is already on the $b%s$b user list (with access %d)."}, /* {ARGS: "TestUser", "#TestChan", 123} */
50 {"NS_ADDUSER_DONE", "Added %s to the %s user list with access %d."}, /* {ARGS: "TestUser", "#TestChan", 123} */
51 {"NS_NOT_ON_USERLIST", "%s lacks access to $b%s$b."}, /* {ARGS: "TestUser", "#TestChan"} */
52 {"NS_NOT_ON_USERLIST_YOU", "You lack access to $b%s$b."}, /* {ARGS: "#TestChan"} */
53 {"NS_NOT_ON_CHANNEL", "%s isn't currently in $b%s$b."}, /* {ARGS: "TestUser", "#TestChan"} */
54 {"NS_NOT_ON_CHANNEL_YOU", "You aren't currently in $b%s$b."}, /* {ARGS: "#TestChan"} */
55 {"NS_DELUSER_DONE", "Deleted %s (with access %d) from the %s user list."}, /* {ARGS: "TestUser", 123, "#TestChan"} */
56 {"NS_ACCESS_OUTRANKED", "You cannot give users access greater than or equal to your own."},
57 {"NS_USER_OUTRANKED", "$b%s$b outranks you (command has no effect)."}, /* {ARGS: "TestUser"} */
58 {"NS_ACCESS_DENIED", "Access denied."},
59 {"NS_NO_ACCESS", "You lack sufficient access to use this command."},
60 {"NS_USER_PROTECTED", "Sorry, $b%s$b is protected."}, /* {ARGS: "TestUser"} */
61 {"NS_SERVICE_IMMUNE", "$b%s$b may not be kicked, killed, banned, or deopped."}, /* {ARGS: "TestUser"} */
62 {"NS_YOU_PROTECTED", "You may not kick or ban yourself."},
63 {"NS_TABLE_NONE", " None"},
64 {"NS_TABLE_COUNT", "Found $b%d$b matches."}, /* {ARGS: 5} */
65 {"NS_BAN_ALREADY_ADDED", "$b%s$b is already banned in %s."}, /* {ARGS: "*!*@moeeep.*", "#TestChan"} */
66 {"NS_INVALID_ACCESS_RANGE", "Invalid access range; minimum (%d) must be lower than maximum (%d)."}, /* {ARGS: 450, 400} */
67 {"NS_CLVL_DONE", "%s now has access $b%d$b in %s."}, /* {ARGS: "TestUser", 123, "#TestChan"} */
68 {"NS_A_LACKS_ACCESS_BUT_GOD_NICK", "%s lacks access to %s but has $bsecurity override$b enabled."}, /* {ARGS: "TestAuth", "#TestChan"} */
69 {"NS_A_LACKS_ACCESS_BUT_GOD_AUTH", "%s (%s) lacks access to %s but has $bsecurity override$b enabled."}, /* {ARGS: "TestAuth", "TestUser", "#TestChan"} */
70 {"NS_A_ACCESS_NICK", "%s has access $b%d$b in %s."}, /* {ARGS: "TestAuth", 123, "#TestChan"} */
71 {"NS_A_ACCESS_AUTH", "%s (%s) has access $b%d$b in %s."}, /* {ARGS: "TestAuth", "TestUser", 123, "#TestChan"} */
72 {"NS_A_ACCESS_NICK_GOD", "%s has access $b%d$b in %s and has $bsecurity override$b enabled."}, /* {ARGS: "TestAuth", 123, "#TestChan"} */
73 {"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"} */
74 {"NS_A_SUSPENDED", "$b%s$b's access to %s has been suspended."}, /* {ARGS: "TestAuth", "#TestChan"} */
75 {"NS_A_IS_IRCOP", "%s is an $bIRC operator$b."}, /* {ARGS: "TestUser", "#TestChan"} */
76 {"NS_USERS_HEADER", "%s users from level %d to %d:"}, /* {ARGS: "#TestChan", 1, 500} */
77 {"NS_USERS_HEADER_MATCH", "%s users from level %d to %d matching %s:"}, /* {ARGS: "#TestChan", 1, 500, "Test*"} */
78 {"NS_USERS_HEADER_ACCESS", "Access"},
79 {"NS_USERS_HEADER_ACCOUNT", "Accout"},
80 {"NS_USERS_HEADER_SEEN", "Last Seen"},
81 {"NS_USERS_HEADER_STATE", "Status"},
82 {"NS_USERS_COUNT", "There are $b%d$b users in %s."}, /* {ARGS: 20, "#TestChan"} */
83 {"NS_USERS_COUNT_1", "There is $b%d$b user in %s."}, /* {ARGS: 1, "#TestChan"} */
84 {"NS_USERS_COUNT_MATCH", "There are $b%d$b users in %s. ($b%d$b matching your request)"}, /* {ARGS: 20, "#TestChan", 5} */
85 {"NS_USERS_COUNT_MATCH_1", "There is $b%d$b user in %s. ($b%d$b matching your request)"}, /* {ARGS: 1, "#TestChan", 1} */
86 {"NS_USERS_SEEN_HERE", "Here"},
87 {"NS_USERS_SEEN_INVISIBLE", "Here (invisible)"},
88 {"NS_USERS_SEEN_NEVER", "Never"},
89 {"NS_USERS_STATE_SUSPENDED", "Suspended"},
90 {"NS_USERS_STATE_NORMAL", "Normal"},
91 {"NS_SUSPEND_ALREADY", "$b%s$b is already suspended." }, /* {ARGS: "TestUser"} */
92 {"NS_SUSPEND_NOT", "$b%s$b is not suspended." }, /* {ARGS: "TestUser"} */
93 {"NS_SUSPEND_DONE", "$b%s$b's access to $b%s$b has been suspended." }, /* {ARGS: "TestUser", "#TestChan"} */
94 {"NS_SUSPEND_RESTORED", "$b%s$b's access to $b%s$b has been restored." }, /* {ARGS: "TestUser", "#TestChan"} */
95 {"NS_DELME_OWNER", "You cannot delete your owner access in $b%s$b."}, /* {ARGS: "#TestChan"} */
96 {"NS_DELME_KEY", "To really remove yourself, you must use 'deleteme %s'."}, /* {ARGS: "abc123"} */
97 {"NS_DELME_DONE", "Your $b%d$b access has been deleted from $b%s$b."}, /* {ARGS: 123, "#TestChan"} */
98 {"NS_MYACCESS_SELF_ONLY", "You may only see the list of infolines for yourself (by using $bmyaccess$b with no arguments)."},
99 {"NS_MYACCESS_HEADER", "Showing all channel entries for account $b%s$b:"}, /* {ARGS: "TestAuth"} */
100 {"NS_MYACCESS_HEADER_MATCH", "Showing all channel entries for account $b%s$b matching %s:"}, /* {ARGS: "TestAuth", "#Test*"} */
101 {"NS_MYACCESS_HEADER_NAME", "Name"},
102 {"NS_MYACCESS_HEADER_ACCESS", "Access"},
103 {"NS_MYACCESS_HEADER_FLAGS", "Flags"},
104 {"NS_MYACCESS_HEADER_INFO", "Info"},
105 {"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} */
106 {"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} */
107 {"NS_UP_ALREADY_OP", "You are already opped in $b%s$b."}, /* {ARGS: "#TestChan"} */
108 {"NS_UP_ALREADY_VOICE", "You are already voiced in $b%s$b."}, /* {ARGS: "#TestChan"} */
109 {"NS_DOWN_ALREADY", "You are not opped or voiced in $b%s$b."}, /* {ARGS: "#TestChan"} */
110 {"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"} */
111 {"NS_TRIM_DURATION_TOO_SHORT", "You must include a minimum inactivity duration of at least %d seconds to trim."},
112 {"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"} */
113 {"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"} */
114 {"NS_GIVEOWNER_SELF", "You cannot give ownership to your own account."},
115 {"NS_GIVEOWNER_TIMEOUT", "You must wait %s before you can give ownership of $b%s$b to someone else."}, /* {ARGS: "5 hours", "#TestChan"} */
116 {"NS_GIVEOWNER_CONFIRM", "To really give ownership to $b%1$s$b, you must use 'giveownership *%1$s %2$s'."}, /* {ARGS: "TestUser", "abc123"} */
117 {"NS_GIVEOWNER_DONE", "Ownership of $b%s$b has been transferred to account $b%s$b."}, /* {ARGS: "#TestChan", "TestUser"} */
118 {"NS_OP_FAIL", "$b%s$b could not op some of the nicks you provided."}, /* {ARGS: "NeonServ"} */
119 {"NS_OP_DONE", "Opped users in $b%s$b."}, /* {ARGS: "#TestChan"} */
120 {"NS_HALFOP_FAIL", "$b%s$b could not halfop some of the nicks you provided."}, /* {ARGS: "NeonServ"} */
121 {"NS_HALFOP_DONE", "Half-Opped users in $b%s$b."}, /* {ARGS: "#TestChan"} */
122 {"NS_VOICE_FAIL", "$b%s$b could not voice some of the nicks you provided."}, /* {ARGS: "NeonServ"} */
123 {"NS_VOICE_DONE", "Voiced users in $b%s$b."}, /* {ARGS: "#TestChan"} */
124 {"NS_DEOP_FAIL", "$b%s$b could not deop some of the nicks you provided."}, /* {ARGS: "NeonServ"} */
125 {"NS_DEOP_DONE", "Deopped users in $b%s$b."}, /* {ARGS: "#TestChan"} */
126 {"NS_DEHALFOP_FAIL", "$b%s$b could not dehalfop some of the nicks you provided."}, /* {ARGS: "NeonServ"} */
127 {"NS_DEHALFOP_DONE", "Dehalfopped users in $b%s$b."}, /* {ARGS: "#TestChan"} */
128 {"NS_DEVOICE_FAIL", "$b%s$b could not devoice some of the nicks you provided."}, /* {ARGS: "NeonServ"} */
129 {"NS_DEVOICE_DONE", "Devoiced users in $b%s$b."}, /* {ARGS: "#TestChan"} */
130 {"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]'"},
131 {"NS_OPALL_DONE", "Opped $b%d$b users in %s."}, /* {ARGS: 20, "#TestChan"} */
132 {"NS_HALFOPALL_DONE", "Half-Opped $b%d$b users in %s."}, /* {ARGS: 20, "#TestChan"} */
133 {"NS_VOICEALL_DONE", "Voiced $b%d$b users in %s."}, /* {ARGS: 20, "#TestChan"} */
134 {"NS_DEOPALL_DONE", "Deopped $b%d$b users in %s."}, /* {ARGS: 20, "#TestChan"} */
135 {"NS_DEHALFOPALL_DONE", "Dehalfopped $b%d$b users in %s."}, /* {ARGS: 20, "#TestChan"} */
136 {"NS_DEVOICEALL_DONE", "Devoiced $b%d$b users in %s."}, /* {ARGS: 20, "#TestChan"} */
137 {"NS_KICK_DONE", "Kicked $b%d$b users from %s"}, /* {ARGS: 20, "#TestChan"} */
138 {"NS_KICK_FAIL", "$b%s$b could not kick some of the nicks you provided."}, /* {ARGS: "NeonServ"} */
139 {"NS_KICKBAN_DONE", "KickBanned $b%d$b users from %s"}, /* {ARGS: 10, "#TestChan"} */
140 {"NS_KICKBAN_FAIL", "$b%s$b could not kickban some of the nicks you provided."}, /* {ARGS: "NeonServ"} */
141 {"NS_BAN_DONE", "$b%d$b masks added to the %s ban list. (matching %d users)"}, /* {ARGS: 5, "#TestChan", 15} */
142 {"NS_BAN_FAIL", "$b%s$b could not ban some of the nicks you provided."}, /* {ARGS: "NeonServ"} */
143 {"NS_LAME_MASK", "$b%s$b is a little too general. Try making it more specific."}, /* {ARGS: "*!*@*"} */
144 {"NS_LAME_MASK_WARNING", "$k4WARNING$k: $b%s$b is very general. (matches %d users)"},
145 {"NS_SET_HEADER", "Channel Settings for %s:"}, /* {ARGS: "#TestChan"} */
147 {"NS_SET_OFF", "off"},
148 {"NS_SET_UNKNOWN_SETTING", "$b%s$b is an unknown channel setting."}, /* {ARGS: "TestSetting"} */
149 {"NS_SET_CANNOT_SET", "That setting is above your current level, so you cannot change it."},
150 {"NS_SET_BADLEVEL", "You cannot change any setting to above your level."},
151 {"NS_SET_INVALID_OPTION", "$b%d$b is not a valid choice. Choose one:"}, /* {ARGS: 5} */
152 {"NS_SET_INVALID_BOOLEAN", "$b%s$b is an invalid binary value."}, /* {ARGS: 2} */
153 {"NS_SET_DEFAULTS_OWNER", "You must have access 500 in %s to reset it to the default options."}, /* {ARGS: "#TestChan"} */
154 {"NS_SET_DEFAULTS_CODE", "To reset %s's settings to the defaults, you must use 'set defaults %s'."}, /* {ARGS: "#TestChan", "abc123"} */
155 {"NS_SET_DEFAULTS_DONE", "All settings for %s have been reset to default values."}, /* {ARGS: "#TestChan"} */
156 {"NS_SET_TRIGGER_OWNER", "You must have access 500 in %s to change the channel trigger."}, /* {ARGS: "#TestChan"} */
157 {"NS_SET_HELP_USERINFO","(access to set the userinfo)"},
158 {"NS_SET_HELP_WIPEINFO","(access to clear the userinfo of other users)"},
159 {"NS_SET_HELP_INVITEME","(access to get invited by the bot)"},
160 {"NS_SET_HELP_ENFVOICE","(access to give voice to other users)"},
161 {"NS_SET_HELP_ENFOPS","(access to give op to their users)"},
162 {"NS_SET_HELP_GIVEOPS","(access to get op by the bot)"},
163 {"NS_SET_HELP_GIVEVOICE","(access to get voice by the bot)"},
164 {"NS_SET_HELP_KICK","(access to kick other users from the channel)"},
165 {"NS_SET_HELP_BAN","(access to ban other users from the channel)"},
166 {"NS_SET_HELP_STATICBAN","(access to add static bans to the channel banlist e.g. +addban)"},
167 {"NS_SET_HELP_PUBCMD","(access to do public commands in the channel e.g. +users)"},
168 {"NS_SET_HELP_ENFMODES","(access to override the modelock)"},
169 {"NS_SET_HELP_ENFTOPIC","(access to override the topicmask)"},
170 {"NS_SET_HELP_TOPICSNARF","(access to set the default topic by changing the topic with /TOPIC)"},
171 {"NS_SET_HELP_CHANGETOPIC","(access to change the topic)"},
172 {"NS_SET_HELP_SETTERS","(access to change this settings)"},
173 {"NS_SET_HELP_ADDUSER","(access to add an user to the userlist)"},
174 {"NS_SET_HELP_DELUSER","(access to delete an user from the userlist)"},
175 {"NS_SET_HELP_CLVL","(access to change the access of an user in the userlist)"},
176 {"NS_SET_HELP_RESYNC","(access to synchronize the channelrights (@,+) with the userlist)"},
177 {"NS_SET_HELP_SUSPEND","(access to suspend an user on the userlist)"},
178 {"NS_SET_OPTION_CTCPREACTION_0","Kick on disallowed CTCPs"},
179 {"NS_SET_OPTION_CTCPREACTION_1","Kickban on disallowed CTCPs"},
180 {"NS_SET_OPTION_CTCPREACTION_2","Short timed ban on disallowed CTCPs"},
181 {"NS_SET_OPTION_CTCPREACTION_3","Long timed ban on disallowed CTCPs"},
182 {"NS_SET_OPTION_NOTICEREACTION_0","Kick on disallowed NOTICEs"},
183 {"NS_SET_OPTION_NOTICEREACTION_1","Kickban on disallowed NOTICEs"},
184 {"NS_SET_OPTION_NOTICEREACTION_2","Short timed ban on disallowed NOTICEs"},
185 {"NS_SET_OPTION_NOTICEREACTION_3","Long timed ban on disallowed NOTICEs"},
186 {"NS_SET_OPTION_PROTECT_0","All users will be protected from users with equal or lower access."},
187 {"NS_SET_OPTION_PROTECT_1","All users with access will be protected from users with equal or lower access."},
188 {"NS_SET_OPTION_PROTECT_2","All users with access will be protected from user with lower access."},
189 {"NS_SET_OPTION_PROTECT_3","Nobody will be protected."},
190 {"NS_SET_OPTION_TOYS_0","Funcommands can't be used."},
191 {"NS_SET_OPTION_TOYS_1","Funcommands are possible but the reply will be sent as a notice."},
192 {"NS_SET_OPTION_TOYS_2","Funcommands are possible and the reply will be sent to the channel."},
193 {"NS_SET_OPTION_DYNLIMIT_0","off"},
194 {"NS_SET_OPTION_NODELETE_0","off (only bot masters)"},
195 {"NS_SET_OPTION_NODELETE_1","on (only bot masters)"},
196 {"NS_WIPEINFO_DONE", "Removed $b%s$b's infoline in $b%s$b."}, /* {ARGS: "TestUser", "#TestChan"} */
197 {"NS_TRACE_HEADER", "The following users were found:"},
198 {"NS_ADDBAN_DONE", "$b%s$b permantly added to the %s ban list. (matching %d users)"}, /* {ARGS: "*!*@Test.*", "#TestChan", 4} */
199 {"NS_BANS_HEADER_MASK", "Mask"},
200 {"NS_BANS_HEADER_SETBY", "Set By"},
201 {"NS_BANS_HEADER_TRIGGERED", "Triggered"},
202 {"NS_BANS_HEADER_EXPIRES", "Expires"},
203 {"NS_BANS_HEADER_REASON", "Reason"},
204 {"NS_DELBAN_BANNED_BY", "%s is banned by %s."}, /* {ARGS: "*!*@bla*", "*!*@b*"} */
205 {"NS_DELBAN_FAIL", "Sorry, no ban found for $b%s$b."}, /* {ARGS: "*!*@bla*"} */
206 {"NS_DELBAN_DONE", "Removed $b%s$b from the %s ban list."}, /* {ARGS: "*!*@bla.*", "#TestChan"} */
207 {"NS_NETINFO_HEADER", "$bNetwork information$b"},
208 {"NS_NETINFO_BOTS", "Bots:"},
209 {"NS_NETINFO_UPTIME", "Uptime:"},
210 {"NS_NETINFO_TRAFFIC", "Traffic:"},
211 {"NS_NETINFO_CACHE", "Cache:"},
212 {"NS_NETINFO_DATABASE", "Database:"},
213 {"NS_NETINFO_CHANNEL", " Channel:"},
214 {"NS_NETINFO_CHANNEL_BAN", " Bans:"},
215 {"NS_NETINFO_USER", " User:"},
216 {"NS_NETINFO_CHANUSER", " Channel-User:"},
217 {"NS_NETINFO_OTHER", " Other:"},
218 {"NS_NETINFO_THREADS", "Threads:"},
219 {"NS_NETINFO_VERSION", "Version:"},
220 {"NS_NETINFO_CODE", "Code:"},
221 {"NS_NETINFO_CODE_VALUE", "%s lines c code (view it at http://dev.pk910.de/NeonServ)"}, /* {ARGS: 20} */
222 {"NS_NETINFO_COMPILER", "Compiler:"},
223 {"NS_NETINFO_COMPILER_VALUE", "%s (%s)"}, /* {ARGS: "GCC 4.4.5", "Sun Sep 18 2011 at 05:21:33 CEST"} */
224 {"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} */
225 {"NS_EXTTOPIC_TOPICID", "Topic %d: %s"}, /* {ARGS: 5, "topic"} */
226 {"NS_TOPIC_DONE", "Topic is now '%s'."}, /* {ARGS: "i like you :D"} */
227 {"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"} */
228 {"NS_CHANSERVSYNC_KEY", "If you really want to synchronize the %s userlist with %s use: chanservsync %s %s"}, /* {ARGS: "#TestChan", "CowBot", "CowBot", "abc123"} */
229 {"NS_CHANSERVSYNC_INUSE", "$bchanservsync$b is already in use by someone else. Please try again in a few seconds..."},
230 {"NS_CHANSERVSYNC_SYNCHRONIZING", "Synchronizing userlist in %s with $b%s$b..."}, /* {ARGS: "#TestChan", "CowBot"} */
231 {"NS_CHANSERVSYNC_SYNCHRONIZED", "Synchronized user $b%s$b: access $b%d$b"}, /* {ARGS: "TestUser", 123} */
232 {"NS_REGISTER_ALREADY", "%s is already registered with %s."}, /* {ARGS: "#TestChan", "NeonServ"} */
233 {"NS_INVALID_CHANNEL_NAME", "%s is not a valid channel name."}, /* {ARGS: "#invalid"} */
234 {"NS_REGISTER_FULL", "the bot can not join more channels."},
235 {"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"} */
236 {"NS_REGISTER_DONE", "$b%s$b is now registered to $b%s$b."}, /* {ARGS: "#TestChan", "TestUser"} */
237 {"NS_REGISTER_DONE_NOAUTH", "$b%s$b is now registered."}, /* {ARGS: "#TestChan"} */
238 {"NS_UNREGISTER_NOT_REGISTERED", "$b%s$b is not registered with %s."}, /* {ARGS: "#TestChan", "NeonServ"} */
239 {"NS_UNREGISTER_DONE", "$b%s$b unregistered."}, /* {ARGS: "#TestChan"} */
240 {"NS_RECOVER_DONE", "$b%s$b has been recovered."}, /* {ARGS: "#TestChan"} */
241 {"NS_RESYNC_DONE", "Synchronized users in $b%s$b with the userlist."}, /* {ARGS: "#TestChan"} */
242 {"NS_TIMEBAN_DURATION_TOO_SHORT", "You must specify a ban duration of at least %d seconds."}, /* {ARGS: 30} */
243 {"NS_TIMEBAN_DONE", "Banned $b%s$b from %s for %s. (matching %d users)"}, /* {ARGS: "*!*@bla*", "#TestChan", "2 hours", 5} */
244 {"NS_MODE_INVALID", "$b%c$b is an invalid set of channel modes."}, /* {ARGS: "+xyz"} */
245 {"NS_MODE_LOCKED", "Modes conflicting with $b%s$b are not allowed in %s."}, /* {ARGS: "+xyz", "#TestChan"} */
246 {"NS_MODE_DONE", "Channel modes are now $b%s$b."}, /* {ARGS: "+xyz"} */
247 {"NS_MODE_ENFOPS", "You may not op or deop users on $b%s$b."}, /* {ARGS: "#TestChan"} */
248 {"NS_MODE_ENFVOICE", "You may not voice or devoice users on $b%s$b."}, /* {ARGS: "#TestChan"} */
249 {"NS_MODE_CANBAN", "You may not ban or unban users on $b%s$b."}, /* {ARGS: "#TestChan"} */
250 {"NS_GOD_ON", "Security override has been enabled."},
251 {"NS_GOD_OFF", "Security override has been disabled."},
252 {"NS_PEEK_HEADER", "$b%s$b Status:"}, /* {ARGS: "#TestChan"} */
253 {"NS_PEEK_TOPIC", "Topic: %s"}, /* {ARGS: "TOPIC"} */
254 {"NS_PEEK_MODES", "Modes: %s"}, /* {ARGS: "+xyz"} */
255 {"NS_PEEK_USERS", "Total Users: %d (%d ops, %d voices, %d regulars, %d invisible)"}, /* {ARGS: 20, 4, 6, 8, 2} */
256 {"NS_PEEK_USERS_HALFOP", "Total Users: %d (%d ops, %d halfops, %d voices, %d regulars, %d invisible)"}, /* {ARGS: 25, 5, 4, 6, 8, 2} */
257 {"NS_PEEK_OPS", "Ops:"},
258 {"NS_USET_GLOBAL", "$b--- Global ---$b"},
259 {"NS_USET_CHANNEL", "$b--- User options (channel) ---$b"},
260 {"NS_USET_NO_ACCESS", "no access"},
261 {"NS_USET_UNKNOWN_SETTING", "$b%s$b is an unknown uset setting."}, /* {ARGS: "TestSetting"} */
262 {"NS_RELOADLANG_UNKNOWN", "$b%s$b is an unknown language tag."}, /* {ARGS: "de"} */
263 {"NS_RELOADLANG_DONE", "$b%s$b (%s) reloaded."}, /* {ARGS: "Deutsch", "de"} */
264 {"NS_UNBAN_DONE", "$b%d$b masks removed from the %s ban list."}, /* {ARGS: 5, "#TestChan"} */
265 {"NS_UNBAN_FAIL", "$b%s$b could not unban some of the masks you provided."}, /* {ARGS: "NeonServ"} */
266 {"NS_UNBANALL_DONE", "all $b%d$b masks removed from the %s ban list."}, /* {ARGS: 5, "#TestChan"} */
267 {"NS_UNBANALL_FAIL", "$b%s$b could not find any bans in %s."}, /* {ARGS: "NeonServ", "#TestChan"} */
268 {"NS_UNBANME_DONE", "removed $b%d$b masks from the %s ban list."}, /* {ARGS: 5, "#TestChan"} */
269 {"NS_UNBANME_FAIL", "$b%s$b could not find any bans matching %s."}, /* {ARGS: "NeonServ", "TestUser!TestIdent@TestUser.user.WebGamesNet"} */
270 {"NS_INVITE_RESTRICTION", "%s doesn't want to be invited to %s."}, /* {ARGS: "TestUser", "#TestChan"} */
271 {"NS_INVITE_TIMEOUT", "%s has already been invited to $b%s$b."}, /* {ARGS: "TestUser", "#TestChan"} */
272 {"NS_INVITE_ON_CHAN", "%s is already in $b%s$b."}, /* {ARGS: "TestUser", "#TestChan"} */
273 {"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"} */
274 {"NS_INVITE_DONE", "Invited $b%s$b to join %s."}, /* {ARGS: "TestUser", "#TestChan"} */
275 {"NS_INVITEME_ON_CHAN", "You are already in $b%s$b."}, /* {ARGS: "#TestChan"} */
276 {"NS_INVITEME_DONE", "You have been invited to join %s."}, /* {ARGS: "#TestChan"} */
277 {"NS_HELP_TOPIC", "No help on that topic."},
278 {"NS_CSUSPEND_ALREADY", "$b%s$b is already suspended."}, /* {ARGS: "#TestChan"} */
279 {"NS_CSUSPEND_DONE", "Channel $b%s$b has been temporarily suspended."}, /* {ARGS: "#TestChan"} */
280 {"NS_CUNSUSPEND_NOT", "$b%s$b is not suspended."}, /* {ARGS: "#TestChan"} */
281 {"NS_CUNSUSPEND_DONE", "Channel $b%s$b has been restored."}, /* {ARGS: "#TestChan"} */
282 {"NS_MOVE_SUSPENDED", "Moving cannot be performed if the source channel is suspended."},
283 {"NS_MOVE_SELF", "Moving cannot be performed if the source and target channels are the same."},
284 {"NS_MOVE_DONE", "Channel $b%s$b has been moved to $b%s$b."}, /* {ARGS: "#TestChan", "#NewTestChan"} */
285 {"NS_BIND_ALREADY", "$b%s$b is already bound to %s."}, /* {ARGS: "TestCommand", "TestFunction"} */
286 {"NS_BIND_UNKNOWN", "$b%s$b is an undefined function."}, /* {ARGS: "TestFunction"} */
287 {"NS_BIND_DONE", "New command $b%s$b bound to %s."}, /* {ARGS: "TestCommand", "TestFunction"} */
288 {"NS_UNBIND_NOT_FOUND", "There is no command called $b%s$b bound."}, /* {ARGS: "TestCommand"} */
289 {"NS_UNBIND_DONE", "Unbound command $b%s$b."}, /* {ARGS: "TestCommand"} */
290 {"NS_EVENTS_HEADER", "The following channel events were found:"},
291 {"NS_OPLOG_HEADER", "The following oper events were found:"},
292 {"NS_SEARCH_HEADER", "The following channels were found:"},
293 {"NS_COMMAND_BINDING", "$b%s$b is a binding of %s %s"}, /* {ARGS: "TestCommand", "TestFunction", "TestParameters"} */
294 {"NS_COMMAND_ACCESS", "You need at least %d channel access and %d oper access to execute this command."}, /* {ARGS: 500, 100} */
295 {"NS_TOPIC_ACCESS", "You lack sufficient access in %s to change the topic."}, /* {ARGS: "#TestChan"} */
296 {"NS_BOTWAR_DETECTED", "$b$k4BOTWAR DETECTED!$k Please check the channel configuration!$b"},
297 {"NS_BOTWAR_REPORTED", "A supporter has been informed to help you preventing botwars in the future."},
298 {"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"} */
299 {"NS_INVITE_FAIL", "$b%s$b is not registered with %s or suspended."}, /* {ARGS: "#TestChan", "NeonServ"} */
300 {"NS_SETACCESS_DONE", "$b%s$b has now %d global access."}, /* {ARGS: "TestUser", 1000} */
301 {"NS_ADDRANK_EXISTS", "Another support ranking called '$b%s$b' already exists."}, /* {ARGS: "Supporter"} */
302 {"NS_ADDRANK_DONE", "Support ranking '$b%s$b' created."}, /* {ARGS: "Supporter"} */
303 {"NS_DELRANK_NOT_FOUND", "There is no support ranking called '$b%s$b'."}, /* {ARGS: "Supporter"} */
304 {"NS_DELRANK_DELETED", "Support ranking called '$b%s$b' removed."}, /* {ARGS: "Supporter"} */
305 {"NS_LISTRANK_ID", "Id"},
306 {"NS_LISTRANK_NAME", "Name"},
307 {"NS_LISTRANK_ASSIGNED", "Assigned to"},
308 {"NS_LISTRANK_UNRANKED", "There are also %d unranked users with global access."}, /* {ARGS: 10} */
309 {"NS_SETRANK_NOT_FOUND", "There is no support ranking with ID '$b%s$b'."}, /* {ARGS: 42} */
310 {"NS_SETRANK_HEAD", "Support ranking settings for Id %s:"}, /* {ARGS: 42} */
311 {"NS_SETRANK_UNKNOWN_SETTING", "$b%s$b is an unknown support rank setting."}, /* {ARGS: "moep"} */
312 {"NS_SETRANK_ORDER_INVALID", "%d is an invalid numeric value. (valid: 1-99)"}, /* {ARGS: 100} */
313 {"NS_ASSIGNRANK_DONE", "$b%s$b is now ranked as '$b%s$b'."}, /* {ARGS: "TestUser", "Supporter"} */
314 {"NS_INFO_HEADER", "$b%s$b Information:"}, /* {ARGS: "#TestChan"} */
315 {"NS_INFO_DEFAULTTOPIC", "Default Topic:"},
316 {"NS_INFO_MODELOCK", "Mode Lock:"},
317 {"NS_INFO_RECORD", "Record Visitors:"},
318 {"NS_INFO_OWNER", "Owner:"},
319 {"NS_INFO_USERS", "Total User Count:"},
320 {"NS_INFO_BANS", "Ban Count:"},
321 {"NS_INFO_VISITED", "Visited:"},
322 {"NS_INFO_REGISTERED", "Registered:"},
323 {"NS_INFO_REGISTRAR", "Registered by:"},
324 {"NS_INFO_OWNERLOG", "Ownership transfer history for $b%s$b:"}, /* {ARGS: "#TestChan"} */
325 {"NS_INFO_OWNERCHANGE", " from %s to %s on %s"},
326 {"NS_RENAME_DONE", "Renamed $b%s$b to $b%s$b."}, /* {ARGS: "TestUser", "TestUser2"} */
327 {"NS_RENAME_FAIL", "Failed renaming $b%s$b."}, /* {ARGS: "TestUser"} */
328 {"NS_FUN_DISABLED", "Fun commands are disabled in %s."}, /* {ARGS: "#TestChan"} */
329 {"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"} */
330 {"NS_COMMANDS_NAME", "Name"},
331 {"NS_COMMANDS_ACCESS", "Access"},
332 {"NS_COMMANDS_GACCESS", "GodAccess"},
333 {"NS_COMMANDS_TRIGGERED", "Triggered"},
334 {"NS_COMMANDS_FUNCTION", "Function"},
335 {"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"} */
336 {"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"} */
337 {"NS_DNR_SET_ANONYM", "$b%s$b is do-not-register. Please contact the support to get more information."}, /* {ARGS: "TestUser"} */
338 {"NS_NOREGISTER_INVALID_DURATION", "$b%s$b is not a valid duration."}, /* {ARGS: "möp"} */
339 {"NS_NOREGISTER_REGISTERED", "$b%s$b is currently registered and can't be added to the do-not-register list."}, /* {ARGS: "#TestChan"} */
340 {"NS_NOREGISTER_DONE", "added $b%s$b to the do-not-register list."}, /* {ARGS: "#TestChan"} */
341 {"NS_NOREGISTER_HEAD", "The following do-not-registers were found:"},
342 {"NS_DNR_TARGET", "Target"},
343 {"NS_DNR_USER", "Issuer"},
344 {"NS_DNR_EXPIRES", "Expires"},
345 {"NS_DNR_REASON", "Reason"},
346 {"NS_STAFF_LOGGEDIN", "Logged in as"},
347 {"NS_BOTS_ID", "Id"},
348 {"NS_BOTS_NICK", "Nick"},
349 {"NS_BOTS_SERVER", "Server:Port(:Pass)"},
350 {"NS_BOTS_CLASS", "Bot Class"},
351 {"NS_BOTS_FLAGS", "Flags"},
352 {"NS_BOTS_CHANNELS", "Channels"},
353 {"NS_BOTS_TRIGGER", "Trigger"},
354 {"NS_NICKLIST_NICK", "Nick"},
355 {"NS_NICKLIST_STATE", "State"},
356 {"NS_NICKLIST_ACCESS", "Access"},
357 {"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)"},
358 {"NS_SETBOT_UNKNOWN", "`%d` is an unknown botid."}, /* {ARGS: 50} */
359 {"NS_SETBOT_HEADER", "$bSettings for botid `%d`:$b"}, /* {ARGS: 50} */
360 {"NS_SETBOT_SETTING", "$b%s$b is an unknown bot setting."}, /* {ARGS: "strangeSetting"} */
361 {"NS_SETBOT_NICK_INVALID", "`%s` is an invalid botnick."}, /* {ARGS: "-SuperMagicBananaBotWithManyFunctions"} */
362 {"NS_SETBOT_NEED_RESTART", "You need to reconnect the bot to apply this setting."},
363 {"NS_SETBOT_PORT_INVALID", "`%s` is an invalid port number."}, /* {ARGS: "-1"} */
364 {"NS_SETBOT_INVALID_CLASS", "`%s` is an invalid botclass."}, /* {ARGS: "MistColaLeer"} */
365 {"NS_SETBOT_MAXCHAN_INVALID", "`%s` is an invalid maxchan value."}, /* {ARGS: "-1"} */
366 {"NS_SETBOT_PRIORITY_INVALID", "`%s` is an invalid priority value."}, /* {ARGS: "-1"} */
367 {"NS_SETBOT_TRIGGER_INVALID", "`%s` is an invalid bot trigger."}, /* {ARGS: "tooLongTrigger"} */
368 {"NS_SETBOT_TRIGGER_NOTE", "Please note: This Setting will only affect new channels."},
369 {"NS_ADDBOT_EXISTING", "A bot with nick %s does already exist."}, /* {ARGS: "NeonServ"} */
370 {"NS_ADDBOT_DONE", "Added %s with BotID $b%d$b."}, /* {ARGS: "NeonServ", 2} */
371 {"NS_DELBOT_NOT_FOUND", "Bot with BotID / nick $b%s$b not found."}, /* {ARGS: "NeonServ"} */
372 {"NS_DELBOT_DONE", "Bot deleted."},
373 {"NS_RECONNECT_DONE", "Reconnected bot."},
374 {"NS_MODCMD_SETTING", "$b%s$b is an unknown modcmd setting."}, /* {ARGS: "strangeSetting"} */
375 {"NS_MODCMD_HEADER", "$bSettings for command %s:$b"}, /* {ARGS: "access"} */
376 {"NS_MODCMD_OUTRANKED", "$b%s$b outranks you. (required access: %d)"}, /* {ARGS: "die", 1000} */
377 {"NS_MODCMD_STATIC_FLAG", "This Flag is added statically. It can't be modified manually."},
378 {"NS_MEMINFO_DISABLED", "Memory Debugger is disabled!"},
379 {"NS_MEMINFO_NAME", "Name"},
380 {"NS_MEMINFO_COUNT", "Count"},
381 {"NS_MEMINFO_SIZE", "Size"},
382 {"NS_MEMINFO_LINE", "Line"},
383 {"NS_MEMINFO_TOTAL", "Total"},
390 cmd_neonserv_modcmd.c
391 cmd_neonserv_allowregister.c
392 cmd_neonserv_noregister.c
393 cmd_neonserv_expire.c
394 cmd_neonserv_unvisited.c
396 cmd_neonserv_dnrsearch.c
397 cmd_neonserv_iplocate.c
401 #include "event_neonserv_join.c"
402 #include "event_neonserv_part.c"
403 #include "event_neonserv_quit.c"
404 #include "event_neonserv_kick.c"
405 #include "event_neonserv_mode.c"
406 #include "event_neonserv_ctcp.c"
407 #include "event_neonserv_notice.c"
408 #include "event_neonserv_invite.c"
409 #include "event_neonserv_topic.c"
412 struct ClientSocket *getBotForChannel(struct ChanNode *chan) {
413 return getChannelBot(chan, BOTID);
416 static void neonserv_bot_ready(struct ClientSocket *client) {
420 printf_mysql_query("SELECT `automodes` FROM `bots` WHERE `id` = '%d'", client->clientid);
422 if ((row = mysql_fetch_row(res)) != NULL) {
423 putsock(client, "MODE %s +%s", client->user->nick, row[0]);
426 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);
429 while ((row = mysql_fetch_row(res)) != NULL) {
430 putsock(client, "JOIN %s %s", row[0], row[1]);
434 static void neonserv_trigger_callback(int clientid, struct ChanNode *chan, char *trigger) {
437 loadChannelSettings(chan);
438 if(!(chan->flags & CHANFLAG_CHAN_REGISTERED)) {
439 strcpy(trigger, "+");
442 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);
444 if(!(row = mysql_fetch_row(res))) {
445 strcpy(trigger, "+");
448 if(row[0] && *row[0])
449 strcpy(trigger, row[0]);
451 strcpy(trigger, ((row[1] && *row[1]) ? row[1] : "~"));
454 static void start_bots(int type) {
455 struct ClientSocket *client;
456 MYSQL_RES *res, *res2;
459 if(type == MODSTATE_STARTSTOP) {
460 printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID);
462 while ((row = mysql_fetch_row(res)) != NULL) {
463 client = create_socket(row[3], atoi(row[4]), row[10], row[5], row[0], row[1], row[2]);
464 client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0);
465 client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0);
466 client->flags |= (strcmp(row[9], "0") ? SOCKET_FLAG_SSL : 0);
467 client->botid = BOTID;
468 client->clientid = atoi(row[7]);
469 connect_socket(client);
473 printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access`, `chan_access`, `flags` FROM `bot_binds` WHERE `botclass` = '%d'", BOTID);
475 while ((row = mysql_fetch_row(res2)) != NULL) {
476 if(bind_cmd_to_command(BOTID, row[0], row[1])) {
477 if(row[2] && strcmp(row[2], "")) {
478 bind_set_parameters(BOTID, row[0], row[2]);
481 bind_set_global_access(BOTID, row[0], atoi(row[3]));
484 bind_set_channel_access(BOTID, row[0], row[4]);
486 if(strcmp(row[5], "0"))
487 bind_set_bind_flags(BOTID, row[0], atoi(row[5]));
490 bind_unbound_required_functions(BOTID);
493 void init_NeonServ(int type) {
494 set_bot_alias(BOTID, BOTALIAS);
497 if(type == MODSTATE_REBIND) return;
500 bind_bot_ready(neonserv_bot_ready, module_id);
501 bind_join(neonserv_event_join, module_id);
502 bind_part(neonserv_event_part, module_id);
503 bind_quit(neonserv_event_quit, module_id);
504 bind_chanctcp(neonserv_event_chanctcp, module_id);
505 bind_privctcp(general_event_privctcp, module_id);
506 bind_channotice(neonserv_event_channotice, module_id);
507 bind_topic(neonserv_event_topic, module_id);
508 bind_invite(neonserv_event_invite, module_id);
509 bind_mode(neonserv_event_mode, module_id);
510 bind_kick(neonserv_event_kick, module_id);
512 set_trigger_callback(BOTID, module_id, neonserv_trigger_callback);
514 register_default_language_table(msgtab);
517 void loop_NeonServ() {
521 void free_NeonServ(int type) {
522 unbind_allcmd(BOTID);
523 if(type == MODSTATE_STARTSTOP) {
524 //disconnect all our bots
525 struct ClientSocket *client;
526 for(client = getBots(0, NULL); client; client = getBots(0, client)) {
527 if(client->botid == BOTID) {
528 unbind_botwise_allcmd(0, client->clientid);
529 close_socket(client);