added language system
[NeonServV5.git] / IRCParser.c
index 4280866facdfd06475c12fa5bf92d358063b3c65..c52659ed21f3c795511d429d3e221a19449193a9 100644 (file)
@@ -6,6 +6,7 @@
 #include "IRCEvents.h"
 #include "ClientSocket.h"
 #include "WHOHandler.h"
+#include "lang.h"
 
 struct irc_cmd *irc_commands = NULL;
 
@@ -367,6 +368,24 @@ void free_parser() {
 }
 
 void reply(struct ClientSocket *client, struct UserNode *user, const char *text, ...) {
-    //following
+    char *reply_format = get_language_string(user, text);
+    if(reply_format == NULL)
+        reply_format = text;
+    if((user->flags & USERFLAG_ISAUTHED) && !(user->flags & USERFLAG_LOADED_SETTINGS))
+        load_user_settings(user);
+    char formatBuf[MAXLEN];
+    sprintf(formatBuf, "%s %s :%s", ((user->flags & USERFLAG_REPLY_PRIVMSG) ? "PRIVMSG" : "NOTICE"), user->nick, reply_format);
+    va_list arg_list;
+    char sendBuf[MAXLEN];
+    int pos;
+    if (!(client->flags & SOCKET_FLAG_CONNECTED)) return;
+    sendBuf[0] = '\0';
+    va_start(arg_list, formatBuf);
+    pos = vsnprintf(sendBuf, MAXLEN - 2, formatBuf, arg_list);
+    va_end(arg_list);
+    if (pos < 0 || pos > (MAXLEN - 2)) pos = MAXLEN - 2;
+    sendBuf[pos] = '\n';
+    sendBuf[pos+1] = '\0';
+    write_socket(client, sendBuf, pos+1);
 }