// be sent from the IRCd to the target without being truncated.\r
\r
var blocks = truncateString(args.msg, 350);\r
- blocks.forEach(function (block) {\r
- irc_connection.write('PRIVMSG ' + args.target + ' :' + block);\r
+ blocks.forEach(function (block, idx) {\r
+ // Apply the callback on the last message only\r
+ var cb = (idx === blocks.length - 1) ?\r
+ callback :\r
+ undefined;\r
+\r
+ irc_connection.write('PRIVMSG ' + args.target + ' :' + block, cb);\r
});\r
},\r
\r
// be sent from the IRCd to the target without being truncated.\r
\r
var blocks = truncateString(args.msg, 350);\r
- blocks.forEach(function (block) {\r
- irc_connection.write('NOTICE ' + args.target + ' :' + block);\r
+ blocks.forEach(function (block, idx) {\r
+ // Apply the callback on the last message only\r
+ var cb = (idx === blocks.length - 1) ?\r
+ callback :\r
+ undefined;\r
+\r
+ irc_connection.write('NOTICE ' + args.target + ' :' + block, cb);\r
});\r
},\r
\r