summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-06-23 07:12:41 -0400
committerAdam <Adam@anope.org>2014-06-23 07:12:41 -0400
commit148b26f687ce85dc01e852a2358b03d493757ada (patch)
treef81ea553d0384ec6063eff45cfaff5aa92aaa1c9
parent0dba0692f9f88275b7d89d511bf22124217bc4c6 (diff)
Mostly working language string rewrite with new format strings
-rw-r--r--include/anope.h66
-rw-r--r--include/bots.h2
-rw-r--r--include/commands.h11
-rw-r--r--include/config.h2
-rw-r--r--include/event.h2
-rw-r--r--include/language.h64
-rw-r--r--include/users.h13
-rw-r--r--modules/commands/bs_assign.cpp114
-rw-r--r--modules/commands/bs_badwords.cpp144
-rw-r--r--modules/commands/bs_bot.cpp156
-rw-r--r--modules/commands/bs_botlist.cpp25
-rw-r--r--modules/commands/bs_control.cpp52
-rw-r--r--modules/commands/bs_info.cpp42
-rw-r--r--modules/commands/bs_kick.cpp335
-rw-r--r--modules/commands/bs_set.cpp47
-rw-r--r--modules/commands/cs_access.cpp312
-rw-r--r--modules/commands/cs_akick.cpp157
-rw-r--r--modules/commands/cs_ban.cpp99
-rw-r--r--modules/commands/cs_clone.cpp32
-rw-r--r--modules/commands/cs_drop.cpp27
-rw-r--r--modules/commands/cs_enforce.cpp55
-rw-r--r--modules/commands/cs_entrymsg.cpp60
-rw-r--r--modules/commands/cs_flags.cpp83
-rw-r--r--modules/commands/cs_getkey.cpp17
-rw-r--r--modules/commands/cs_info.cpp16
-rw-r--r--modules/commands/cs_invite.cpp51
-rw-r--r--modules/commands/cs_kick.cpp39
-rw-r--r--modules/commands/cs_list.cpp79
-rw-r--r--modules/commands/cs_log.cpp78
-rw-r--r--modules/commands/cs_mode.cpp146
-rw-r--r--modules/commands/cs_register.cpp51
-rw-r--r--modules/commands/cs_seen.cpp70
-rw-r--r--modules/commands/cs_set.cpp439
-rw-r--r--modules/commands/cs_set_misc.cpp16
-rw-r--r--modules/commands/cs_status.cpp109
-rw-r--r--modules/commands/cs_suspend.cpp39
-rw-r--r--modules/commands/cs_sync.cpp42
-rw-r--r--modules/commands/cs_topic.cpp66
-rw-r--r--modules/commands/cs_unban.cpp30
-rw-r--r--modules/commands/cs_updown.cpp84
-rw-r--r--modules/commands/cs_xop.cpp158
-rw-r--r--modules/commands/gl_global.cpp6
-rw-r--r--modules/commands/greet.cpp56
-rw-r--r--modules/commands/help.cpp16
-rw-r--r--modules/commands/hs_del.cpp32
-rw-r--r--modules/commands/hs_group.cpp16
-rw-r--r--modules/commands/hs_list.cpp29
-rw-r--r--modules/commands/hs_off.cpp10
-rw-r--r--modules/commands/hs_on.cpp14
-rw-r--r--modules/commands/hs_request.cpp72
-rw-r--r--modules/commands/hs_set.cpp61
-rw-r--r--modules/commands/ms_cancel.cpp22
-rw-r--r--modules/commands/ms_check.cpp24
-rw-r--r--modules/commands/ms_del.cpp50
-rw-r--r--modules/commands/ms_ignore.cpp34
-rw-r--r--modules/commands/ms_info.cpp85
-rw-r--r--modules/commands/ms_list.cpp36
-rw-r--r--modules/commands/ms_read.cpp54
-rw-r--r--modules/commands/ms_rsend.cpp14
-rw-r--r--modules/commands/ms_send.cpp19
-rw-r--r--modules/commands/ms_sendall.cpp4
-rw-r--r--modules/commands/ms_set.cpp130
-rw-r--r--modules/commands/ms_staff.cpp2
-rw-r--r--modules/commands/ns_access.cpp83
-rw-r--r--modules/commands/ns_ajoin.cpp43
-rw-r--r--modules/commands/ns_alist.cpp16
-rw-r--r--modules/commands/ns_cert.cpp67
-rw-r--r--modules/commands/ns_drop.cpp15
-rw-r--r--modules/commands/ns_getemail.cpp14
-rw-r--r--modules/commands/ns_getpass.cpp16
-rw-r--r--modules/commands/ns_group.cpp106
-rw-r--r--modules/commands/ns_identify.cpp20
-rw-r--r--modules/commands/ns_info.cpp62
-rw-r--r--modules/commands/ns_list.cpp98
-rw-r--r--modules/commands/ns_logout.cpp15
-rw-r--r--modules/commands/ns_recover.cpp35
-rw-r--r--modules/commands/ns_register.cpp93
-rw-r--r--modules/commands/ns_resetpass.cpp18
-rw-r--r--modules/commands/ns_set.cpp321
-rw-r--r--modules/commands/ns_set_misc.cpp10
-rw-r--r--modules/commands/ns_status.cpp5
-rw-r--r--modules/commands/ns_suspend.cpp34
-rw-r--r--modules/commands/os_akill.cpp142
-rw-r--r--modules/commands/os_chankill.cpp11
-rw-r--r--modules/commands/os_config.cpp23
-rw-r--r--modules/commands/os_defcon.cpp25
-rw-r--r--modules/commands/os_dns.cpp149
-rw-r--r--modules/commands/os_forbid.cpp40
-rw-r--r--modules/commands/os_ignore.cpp44
-rw-r--r--modules/commands/os_info.cpp32
-rw-r--r--modules/commands/os_jupe.cpp18
-rw-r--r--modules/commands/os_kick.cpp24
-rw-r--r--modules/commands/os_kill.cpp10
-rw-r--r--modules/commands/os_list.cpp31
-rw-r--r--modules/commands/os_login.cpp18
-rw-r--r--modules/commands/os_logsearch.cpp33
-rw-r--r--modules/commands/os_mode.cpp22
-rw-r--r--modules/commands/os_modinfo.cpp20
-rw-r--r--modules/commands/os_module.cpp39
-rw-r--r--modules/commands/os_news.cpp47
-rw-r--r--modules/commands/os_noop.cpp16
-rw-r--r--modules/commands/os_oline.cpp12
-rw-r--r--modules/commands/os_oper.cpp43
-rw-r--r--modules/commands/os_reload.cpp9
-rw-r--r--modules/commands/os_session.cpp130
-rw-r--r--modules/commands/os_set.cpp76
-rw-r--r--modules/commands/os_shutdown.cpp19
-rw-r--r--modules/commands/os_stats.cpp84
-rw-r--r--modules/commands/os_svs.cpp47
-rw-r--r--modules/commands/os_sxline.cpp255
-rw-r--r--modules/commands/os_update.cpp5
-rw-r--r--modules/fantasy.cpp13
-rw-r--r--modules/ns_maxemail.cpp4
-rw-r--r--modules/pseudoclients/chanserv/chanserv.cpp2
-rw-r--r--modules/pseudoclients/memoserv/memoserv.cpp4
-rw-r--r--modules/pseudoclients/nickserv/nickserv.cpp6
-rw-r--r--modules/pseudoclients/operserv.cpp2
-rw-r--r--modules/webcpanel/pages/chanserv/modes.cpp2
-rw-r--r--src/bots.cpp14
-rw-r--r--src/channels.cpp2
-rw-r--r--src/command.cpp32
-rw-r--r--src/config.cpp5
-rw-r--r--src/misc.cpp2
-rw-r--r--src/users.cpp51
124 files changed, 3234 insertions, 3616 deletions
diff --git a/include/anope.h b/include/anope.h
index 845a2b1fb..839d201cf 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -631,7 +631,7 @@ class spacesepstream : public sepstream
public:
/** Initialize with space seperator
*/
- spacesepstream(const Anope::string &source) : sepstream(source, ' ') { }
+ spacesepstream(const Anope::string &source, bool allowempty = false) : sepstream(source, ' ', allowempty) { }
};
/** This class can be used on its own to represent an exception, or derived to represent a module-specific exception.
@@ -775,3 +775,67 @@ template<typename T, typename O> inline T anope_dynamic_static_cast(O ptr)
return static_cast<T>(ptr);
}
#endif
+
+struct kwarg
+{
+ Anope::string name, value;
+
+ template<typename T>
+ kwarg& operator=(const T& rhs)
+ {
+ value = stringify(rhs);
+ return *this;
+ }
+};
+
+inline kwarg operator"" _kw(const char *literal, size_t n)
+{
+ return kwarg{ literal };
+}
+
+struct FormatInfo
+{
+ Anope::string format;
+ std::vector<kwarg> parameters;
+ unsigned int pos = 0;
+
+ FormatInfo(const Anope::string &fmt, size_t size) : format(fmt), parameters(size) { }
+
+ template<typename T>
+ void Add(T& arg)
+ {
+ parameters[pos] = kwarg{ stringify(pos).c_str() } = stringify(arg);
+ ++pos;
+ }
+
+ template<typename Arg, typename... Args>
+ void Format(Arg &&arg, Args&&... args)
+ {
+ Add(arg);
+ Format(std::forward<Args>(args)...);
+ }
+
+ void Format()
+ {
+ for (kwarg& arg : parameters)
+ format = format.replace_all_cs("{" + arg.name + "}", arg.value);
+ }
+};
+
+template<>
+inline void FormatInfo::Add(kwarg &arg)
+{
+ parameters[pos++] = arg;
+}
+
+namespace Anope
+{
+ template<typename... Args>
+ inline Anope::string Format(const Anope::string &format, Args&&... args)
+ {
+ FormatInfo fi(format, sizeof...(Args));
+ fi.Format(std::forward<Args>(args)...);
+ return fi.format;
+ }
+}
+
diff --git a/include/bots.h b/include/bots.h
index 9a2c5d237..ef57d31f3 100644
--- a/include/bots.h
+++ b/include/bots.h
@@ -124,6 +124,8 @@ class CoreExport BotInfo : public User, public Serializable
*/
CommandInfo *GetCommand(const Anope::string &cname);
+ CommandInfo *FindCommand(const Anope::string &service);
+
/** Find a bot by nick
* @param nick The nick
* @param nick_only True to only look by nick, and not by UID
diff --git a/include/commands.h b/include/commands.h
index 359995f8f..6f29aa135 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -14,6 +14,7 @@
#include "service.h"
#include "anope.h"
#include "channels.h"
+#include "language.h"
struct CommandGroup
{
@@ -29,6 +30,8 @@ struct CommandInfo
/* Service name of the command */
Anope::string name;
+ /* User visible name */
+ Anope::string cname;
/* Permission required to execute the command */
Anope::string permission;
/* Group this command is in */
@@ -77,7 +80,13 @@ class CoreExport CommandSource
ChanServ::AccessGroup AccessFor(ChanServ::Channel *ci);
bool IsFounder(ChanServ::Channel *ci);
- void Reply(const char *message, ...);
+ template<typename... Args>
+ void Reply(const char *message, Args&&... args)
+ {
+ const char *translated_message = Language::Translate(this->nc, message);
+ Reply(Anope::Format(translate