search another bot if unable to send funcmd replies over textbot
[NeonServV5.git] / src / modules / funcmd.mod / cmd_funcmds.c
index 56a7eab60b8b5dc69b1a85c6322a9729e8c3324a..eda55cca075e18fcaa8fd2d369301abbb7078382 100644 (file)
@@ -86,6 +86,7 @@ void register_commands() {
     USER_COMMAND("8ball",        funcmd_8ball,           1,  CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN | CMDFLAG_FUNCMD);
     USER_COMMAND("cookie",       funcmd_cookie,          0,  CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN | CMDFLAG_FUNCMD);
     USER_COMMAND("bomb",         funcmd_bomb,            0,  CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN | CMDFLAG_FUNCMD);
+    USER_COMMAND("ship",         funcmd_ship,            0,  CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN | CMDFLAG_FUNCMD);
     #undef USER_COMMAND
 }
 
@@ -126,6 +127,7 @@ free(header);
 #define REPLYTYPE_NOTICE 0x04
 static void funcmd_reply(struct funcmd_header_info *header, const char *text, int type, ...) {
     if (!(header->client->flags & SOCKET_FLAG_CONNECTED)) return;
+    struct ClientSocket *client = header->client;
     const char *reply_format = get_language_string((header->null_language ? NULL : header->user), text);
     if(reply_format)
         text = reply_format;
@@ -140,6 +142,8 @@ static void funcmd_reply(struct funcmd_header_info *header, const char *text, in
             sprintf(formatBuf, "PRIVMSG %s :\001ACTION %s\001", header->chan->name, text);
         else
             sprintf(formatBuf, "PRIVMSG %s :%s", header->chan->name, text);
+        if(!isUserOnChan(client->user, header->chan) && isModeSet(header->chan->modes, 'n'))
+            client = getChannelBot(header->chan, 0);
     }
     va_list arg_list;
     char sendBuf[MAXLEN];
@@ -151,7 +155,7 @@ static void funcmd_reply(struct funcmd_header_info *header, const char *text, in
     if (pos < 0 || pos > (MAXLEN - 2)) pos = MAXLEN - 2;
     sendBuf[pos] = '\n';
     sendBuf[pos+1] = '\0';
-    write_socket(header->client, sendBuf, pos+1);
+    write_socket(client, sendBuf, pos+1);
 }
 
 static char* getSetting(struct UserNode *user, struct ChanNode *chan, const char *setting) {
@@ -217,6 +221,12 @@ CMD_BIND(funcmd_dice) {
     int max = atoi(argv[0]);
     if(max > 1) {
         int val = (rand() % max) + 1;
+        funcmd_reply(header, "%s", REPLYTYPE_NORMAL, "     ____");
+        funcmd_reply(header, "%s", REPLYTYPE_NORMAL, "    /\\' .\\    _____");
+        funcmd_reply(header, "%s", REPLYTYPE_NORMAL, "   /: \\___\\  / .  /\\");
+        funcmd_reply(header, "%s", REPLYTYPE_NORMAL, "   \\' / . / /____/..\\");
+        funcmd_reply(header, "%s", REPLYTYPE_NORMAL, "    \\/___/  \\'  '\\  /");
+        funcmd_reply(header, "%s", REPLYTYPE_NORMAL, "             \\'__'\\/ ");
         funcmd_reply(header, "FUN_DICE", REPLYTYPE_NORMAL, user->nick, val, max);
     } else
         funcmd_reply(header, "FUN_DICE_NUM", REPLYTYPE_NORMAL, argv[0]);
@@ -279,3 +289,18 @@ CMD_BIND(funcmd_cookie) {
     funcmd_reply(header, "FUN_COOKIE", REPLYTYPE_ACTION, user->nick, total_count, user_count);
     FUNCMD_FOOTER;
 }
+
+CMD_BIND(funcmd_ship) {
+    FUNCMD_HEADER;
+    funcmd_reply(header, "%s", REPLYTYPE_NORMAL, "\0030,0------------------------\0031|");
+    funcmd_reply(header, "%s", REPLYTYPE_NORMAL, "\0030,0----------------------\00314)_)_)");
+    funcmd_reply(header, "%s%c%s", REPLYTYPE_NORMAL, "\0030,0--------------------\0031,4\002=", header->client->user->nick[0], "=\002\00314,0|)___)");
+    funcmd_reply(header, "%s", REPLYTYPE_NORMAL, "\0030,0-------------------\00314)__) )___) )");
+    funcmd_reply(header, "%s", REPLYTYPE_NORMAL, "\0030,0------------------\00314)___) )____))_)");
+    funcmd_reply(header, "%s", REPLYTYPE_NORMAL, "\0030,0----------------\00314)____)_____))__)\\");
+    funcmd_reply(header, "%s", REPLYTYPE_NORMAL, "\0030,0---------------\00314)\0035__\00314|\0035____\00314/|\0035___\00314|\0035___\00314-\\\\---");
+    funcmd_reply(header, "%s", REPLYTYPE_NORMAL, "\0030,0-------\00312^^^^^^\0035~~~\\ \002oo oo oo oo\002 /~~\00312^^^^^^");
+    funcmd_reply(header, "%s", REPLYTYPE_NORMAL, "\0030,0------------\00312~^^^^ ~~~~^^~~~~^^~~^^~~~~~");
+    funcmd_reply(header, "%s", REPLYTYPE_NORMAL, "\0030,0-----------------\00312~~^^ ~^^~ ~^~ ~^");
+    FUNCMD_FOOTER;
+}