botmsg.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. /*
  2. * botmsg.c -- handles:
  3. * formatting of messages to be sent on the botnet
  4. * sending differnet messages to different versioned bots
  5. *
  6. * by Darrin Smith (beldin@light.iinet.net.au)
  7. *
  8. */
  9. #include "common.h"
  10. #include "misc.h"
  11. #include "dcc.h"
  12. #include "userrec.h"
  13. #include "main.h"
  14. #include "net.h"
  15. #include "users.h"
  16. #include "cfg.h"
  17. #include "botmsg.h"
  18. #include "dccutil.h"
  19. #include "cmds.h"
  20. #include "chanprog.h"
  21. #include "botnet.h"
  22. #include "tandem.h"
  23. #include "core_binds.h"
  24. #include "src/mod/notes.mod/notes.h"
  25. #include <stdarg.h>
  26. static char OBUF[SGRAB - 110] = "";
  27. /* Thank you ircu :) */
  28. static char tobase64array[64] =
  29. {
  30. 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
  31. 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
  32. 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
  33. 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
  34. '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
  35. '[', ']'
  36. };
  37. char *int_to_base64(unsigned int val)
  38. {
  39. static char buf_base64[12] = "";
  40. int i = 11;
  41. buf_base64[11] = 0;
  42. if (!val) {
  43. buf_base64[10] = 'A';
  44. return buf_base64 + 10;
  45. }
  46. while (val) {
  47. i--;
  48. buf_base64[i] = tobase64array[val & 0x3f];
  49. val = val >> 6;
  50. }
  51. return buf_base64 + i;
  52. }
  53. char *int_to_base10(int val)
  54. {
  55. static char buf_base10[17] = "";
  56. int p = 0;
  57. int i = 16;
  58. buf_base10[16] = 0;
  59. if (!val) {
  60. buf_base10[15] = '0';
  61. return buf_base10 + 15;
  62. }
  63. if (val < 0) {
  64. p = 1;
  65. val *= -1;
  66. }
  67. while (val) {
  68. i--;
  69. buf_base10[i] = '0' + (val % 10);
  70. val /= 10;
  71. }
  72. if (p) {
  73. i--;
  74. buf_base10[i] = '-';
  75. }
  76. return buf_base10 + i;
  77. }
  78. char *unsigned_int_to_base10(unsigned int val)
  79. {
  80. static char buf_base10[16] = "";
  81. int i = 15;
  82. buf_base10[15] = 0;
  83. if (!val) {
  84. buf_base10[14] = '0';
  85. return buf_base10 + 14;
  86. }
  87. while (val) {
  88. i--;
  89. buf_base10[i] = '0' + (val % 10);
  90. val /= 10;
  91. }
  92. return buf_base10 + i;
  93. }
  94. int simple_sprintf (char *buf, ...)
  95. {
  96. char *format = NULL, *s = NULL;
  97. int c = 0, i;
  98. va_list va;
  99. va_start(va, buf);
  100. format = va_arg(va, char *);
  101. while (*format && c < 1023) {
  102. if (*format == '%') {
  103. format++;
  104. switch (*format) {
  105. case 's':
  106. s = va_arg(va, char *);
  107. break;
  108. case 'd':
  109. case 'i':
  110. i = va_arg(va, int);
  111. s = int_to_base10(i);
  112. break;
  113. case 'D':
  114. i = va_arg(va, int);
  115. s = int_to_base64((unsigned int) i);
  116. break;
  117. case 'u':
  118. i = va_arg(va, unsigned int);
  119. s = unsigned_int_to_base10(i);
  120. break;
  121. case '%':
  122. buf[c++] = *format++;
  123. continue;
  124. case 'c':
  125. buf[c++] = (char) va_arg(va, int);
  126. format++;
  127. continue;
  128. default:
  129. continue;
  130. }
  131. if (s)
  132. while (*s && c < 1023)
  133. buf[c++] = *s++;
  134. format++;
  135. } else
  136. buf[c++] = *format++;
  137. }
  138. va_end(va);
  139. buf[c] = 0;
  140. return c;
  141. }
  142. /* Ditto for tandem bots
  143. */
  144. static void send_tand_but(int x, char *buf, int len)
  145. {
  146. int i, iso = 0;
  147. if (len < 0) {
  148. len = -len;
  149. iso = 1;
  150. }
  151. for (i = 0; i < dcc_total; i++)
  152. if ((dcc[i].type == &DCC_BOT) && (i != x) && (!iso || !(bot_flags(dcc[i].user) & BOT_ISOLATE)))
  153. tputs(dcc[i].sock, buf, len);
  154. }
  155. #ifdef S_DCCPASS
  156. void botnet_send_cmdpass(int idx, char *cmd, char *pass)
  157. {
  158. if (tands > 0) {
  159. char *buf = NULL;
  160. buf = malloc(strlen(cmd) + strlen(pass) + 5 + 1);
  161. sprintf(buf, "cp %s %s\n", cmd, pass);
  162. send_tand_but(idx, buf, strlen(buf));
  163. free(buf);
  164. }
  165. }
  166. #endif /* S_DCCPASS */
  167. int botnet_send_cmd(char * fbot, char * bot, char * from, int fromidx, char * cmd) {
  168. int i = nextbot(bot);
  169. if (i >= 0) {
  170. char buf[2048] = "";
  171. sprintf(buf, STR("rc %s %s %s %i %s\n"), bot, fbot, from, fromidx, cmd);
  172. tputs(dcc[i].sock, buf, strlen(buf));
  173. return 1;
  174. } else if (!strcmp(bot, conf.bot->nick)) {
  175. char tmp[24] = "";
  176. sprintf(tmp, "%i", fromidx);
  177. gotremotecmd(conf.bot->nick, conf.bot->nick, from, tmp, cmd);
  178. }
  179. return 0;
  180. }
  181. void botnet_send_cmd_broad(int idx, char * fbot, char * from, int fromidx, char * cmd) {
  182. if (tands > 0) {
  183. char buf[2048] = "";
  184. egg_snprintf(buf, sizeof buf, STR("rc * %s %s %i %s\n"), fbot, from, fromidx, cmd);
  185. send_tand_but(idx, buf, strlen(buf));
  186. }
  187. if (idx<0) {
  188. char tmp[24] = "";
  189. sprintf(tmp, "%i", fromidx);
  190. gotremotecmd("*", conf.bot->nick, from, tmp, cmd);
  191. }
  192. }
  193. void botnet_send_cmdreply(char * fbot, char * bot, char * to, char * toidx, char * ln) {
  194. int i = nextbot(bot);
  195. if (i>=0) {
  196. char buf[2048] = "";
  197. egg_snprintf(buf, sizeof buf, STR("rr %s %s %s %s %s\n"), bot, fbot, to, toidx, ln);
  198. tputs(dcc[i].sock, buf, strlen(buf));
  199. } else if (!strcmp(bot, conf.bot->nick)) {
  200. gotremotereply(conf.bot->nick, to, toidx, ln);
  201. }
  202. }
  203. void botnet_send_bye()
  204. {
  205. if (tands > 0)
  206. send_tand_but(-1, "bye\n", 4);
  207. }
  208. void botnet_send_chan(int idx, char *botnick, char *user, int chan, char *data)
  209. {
  210. int i;
  211. if ((tands > 0) && (chan < GLOBAL_CHANS)) {
  212. if (user) {
  213. i = simple_sprintf(OBUF, "c %s@%s %D %s\n", user, botnick, chan, data);
  214. } else {
  215. i = simple_sprintf(OBUF, "c %s %D %s\n", botnick, chan, data);
  216. }
  217. send_tand_but(idx, OBUF, -i);
  218. }
  219. }
  220. void botnet_send_act(int idx, char *botnick, char *user, int chan, char *data)
  221. {
  222. int i;
  223. if ((tands > 0) && (chan < GLOBAL_CHANS)) {
  224. if (user) {
  225. i = simple_sprintf(OBUF, "a %s@%s %D %s\n", user, botnick, chan, data);
  226. } else {
  227. i = simple_sprintf(OBUF, "a %s %D %s\n", botnick, chan, data);
  228. }
  229. send_tand_but(idx, OBUF, -i);
  230. }
  231. }
  232. void botnet_send_chat(int idx, char *botnick, char *data)
  233. {
  234. int i;
  235. if (tands > 0) {
  236. i = simple_sprintf(OBUF, "ct %s %s\n", botnick, data);
  237. send_tand_but(idx, OBUF, -i);
  238. }
  239. }
  240. void botnet_send_ping(int idx)
  241. {
  242. tputs(dcc[idx].sock, "pi\n", 3);
  243. dcc[idx].pingtime = now;
  244. }
  245. void botnet_send_pong(int idx)
  246. {
  247. tputs(dcc[idx].sock, "po\n", 3);
  248. }
  249. void botnet_send_priv (int idx, ...)
  250. {
  251. int l;
  252. char *from = NULL, *to = NULL, *tobot = NULL, *format = NULL;
  253. char tbuf[1024] = "";
  254. va_list va;
  255. va_start(va, idx);
  256. from = va_arg(va, char *);
  257. to = va_arg(va, char *);
  258. tobot = va_arg(va, char *);
  259. format = va_arg(va, char *);
  260. egg_vsnprintf(tbuf, 450, format, va);
  261. va_end(va);
  262. tbuf[sizeof(tbuf)-1] = 0;
  263. if (tobot) {
  264. l = simple_sprintf(OBUF, "p %s %s@%s %s\n", from, to, tobot, tbuf);
  265. } else {
  266. l = simple_sprintf(OBUF, "p %s %s %s\n", from, to, tbuf);
  267. }
  268. tputs(dcc[idx].sock, OBUF, l);
  269. }
  270. void botnet_send_who(int idx, char *from, char *to, int chan)
  271. {
  272. int l;
  273. l = simple_sprintf(OBUF, "w %s %s %D\n", from, to, chan);
  274. tputs(dcc[idx].sock, OBUF, l);
  275. }
  276. void botnet_send_infoq(int idx, char *par)
  277. {
  278. int i = simple_sprintf(OBUF, "i? %s\n", par);
  279. send_tand_but(idx, OBUF, i);
  280. }
  281. void botnet_send_unlink(int idx, char *who, char *via,
  282. char *bot, char *reason)
  283. {
  284. int l;
  285. l = simple_sprintf(OBUF, "ul %s %s %s %s\n", who, via, bot, reason);
  286. tputs(dcc[idx].sock, OBUF, l);
  287. }
  288. void botnet_send_link(int idx, char *who, char *via, char *bot)
  289. {
  290. int l;
  291. l = simple_sprintf(OBUF, "l %s %s %s\n", who, via, bot);
  292. tputs(dcc[idx].sock, OBUF, l);
  293. }
  294. void botnet_send_unlinked(int idx, char *bot, char *args)
  295. {
  296. int l;
  297. if (tands > 0) {
  298. l = simple_sprintf(OBUF, "un %s %s\n", bot, args ? args : "");
  299. send_tand_but(idx, OBUF, l);
  300. }
  301. }
  302. void botnet_send_nlinked(int idx, char *bot, char *next, char flag,
  303. int vernum)
  304. {
  305. int l;
  306. if (tands > 0) {
  307. l = simple_sprintf(OBUF, "n %s %s %c%D\n", bot, next, flag, vernum);
  308. send_tand_but(idx, OBUF, l);
  309. }
  310. }
  311. void botnet_send_traced(int idx, char *bot, char *buf)
  312. {
  313. int l;
  314. l = simple_sprintf(OBUF, "td %s %s\n", bot, buf);
  315. tputs(dcc[idx].sock, OBUF, l);
  316. }
  317. void botnet_send_trace(int idx, char *to, char *from, char *buf)
  318. {
  319. int l;
  320. l = simple_sprintf(OBUF, "t %s %s %s:%s\n", to, from, buf, conf.bot->nick);
  321. tputs(dcc[idx].sock, OBUF, l);
  322. }
  323. void botnet_send_update(int idx, tand_t * ptr)
  324. {
  325. int l;
  326. if (tands > 0) {
  327. l = simple_sprintf(OBUF, "u %s %c%D\n", ptr->bot, ptr->share, ptr->ver);
  328. send_tand_but(idx, OBUF, l);
  329. }
  330. }
  331. void botnet_send_reject(int idx, char *fromp, char *frombot, char *top, char *tobot, char *reason)
  332. {
  333. int l;
  334. char to[NOTENAMELEN + 1] = "", from[NOTENAMELEN + 1] = "";
  335. if (!(bot_flags(dcc[idx].user) & BOT_ISOLATE)) {
  336. if (tobot) {
  337. simple_sprintf(to, "%s@%s", top, tobot);
  338. top = to;
  339. }
  340. if (frombot) {
  341. simple_sprintf(from, "%s@%s", fromp, frombot);
  342. fromp = from;
  343. }
  344. if (!reason)
  345. reason = "";
  346. l = simple_sprintf(OBUF, "r %s %s %s\n", fromp, top, reason);
  347. tputs(dcc[idx].sock, OBUF, l);
  348. }
  349. }
  350. inline void putallbots(char *par)
  351. {
  352. botnet_send_zapf_broad(-1, conf.bot->nick, NULL, par);
  353. }
  354. void putbot(char *bot, char *par)
  355. {
  356. int i;
  357. char msg[SGRAB - 110] = "";
  358. if (!bot || !par || !bot[0] || !par[0])
  359. return;
  360. i = nextbot(bot);
  361. if (i < 0)
  362. return;
  363. strncpyz(msg, par, sizeof msg);
  364. botnet_send_zapf(i, conf.bot->nick, bot, msg);
  365. }
  366. void botnet_send_zapf(int idx, char *a, char *b, char *c)
  367. {
  368. int l;
  369. l = simple_sprintf(OBUF, "z %s %s %s\n", a, b, c);
  370. tputs(dcc[idx].sock, OBUF, l);
  371. }
  372. void botnet_send_zapf_broad(int idx, char *a, char *b, char *c)
  373. {
  374. int l;
  375. if (tands > 0) {
  376. l = simple_sprintf(OBUF, "zb %s %s%s%s\n", a, b ? b : "", b ? " " : "", c);
  377. send_tand_but(idx, OBUF, l);
  378. }
  379. }
  380. void botnet_send_cfg(int idx, struct cfg_entry * entry) {
  381. int l;
  382. l = simple_sprintf(OBUF, STR("cg %s %s\n"), entry->name, entry->gdata ? entry->gdata : "");
  383. tputs(dcc[idx].sock, OBUF, l);
  384. }
  385. void botnet_send_cfg_broad(int idx, struct cfg_entry * entry) {
  386. int l;
  387. if (tands > 0) {
  388. l = simple_sprintf(OBUF, STR("cgb %s %s\n"), entry->name, entry->gdata ? entry->gdata : "");
  389. send_tand_but(idx, OBUF, l);
  390. }
  391. }
  392. void botnet_send_idle(int idx, char *bot, int sock, int idle, char *away)
  393. {
  394. int l;
  395. if (tands > 0) {
  396. l = simple_sprintf(OBUF, "i %s %D %D %s\n", bot, sock, idle, away ? away : "");
  397. send_tand_but(idx, OBUF, -l);
  398. }
  399. }
  400. void botnet_send_away(int idx, char *bot, int sock,
  401. char *msg, int linking)
  402. {
  403. int l;
  404. if (tands > 0) {
  405. l = simple_sprintf(OBUF, "aw %s%s %D %s\n",
  406. ((idx >= 0) && linking) ? "!" : "",
  407. bot, sock, msg ? msg : "");
  408. send_tand_but(idx, OBUF, -l);
  409. }
  410. }
  411. void botnet_send_join_idx(int useridx, int oldchan)
  412. {
  413. int l;
  414. if (tands > 0) {
  415. l = simple_sprintf(OBUF, "j %s %s %D %c%D %s\n",
  416. conf.bot->nick, dcc[useridx].nick,
  417. dcc[useridx].u.chat->channel, geticon(useridx),
  418. dcc[useridx].sock, dcc[useridx].host);
  419. send_tand_but(-1, OBUF, -l);
  420. }
  421. }
  422. void botnet_send_join_party(int idx, int linking, int useridx, int oldchan)
  423. {
  424. int l;
  425. if (tands > 0) {
  426. l = simple_sprintf(OBUF, "j %s%s %s %D %c%D %s\n", linking ? "!" : "",
  427. party[useridx].bot, party[useridx].nick,
  428. party[useridx].chan, party[useridx].flag,
  429. party[useridx].sock,
  430. party[useridx].from ? party[useridx].from : "");
  431. send_tand_but(idx, OBUF, -l);
  432. }
  433. }
  434. void botnet_send_part_idx(int useridx, char *reason)
  435. {
  436. int l = simple_sprintf(OBUF, "pt %s %s %D %s\n", conf.bot->nick,
  437. dcc[useridx].nick, dcc[useridx].sock,
  438. reason ? reason : "");
  439. if (tands > 0) {
  440. send_tand_but(-1, OBUF, -l);
  441. }
  442. }
  443. void botnet_send_part_party(int idx, int partyidx, char *reason,
  444. int silent)
  445. {
  446. int l;
  447. if (tands > 0) {
  448. l = simple_sprintf(OBUF, "pt %s%s %s %D %s\n",
  449. silent ? "!" : "", party[partyidx].bot,
  450. party[partyidx].nick, party[partyidx].sock,
  451. reason ? reason : "");
  452. send_tand_but(idx, OBUF, -l);
  453. }
  454. }
  455. void botnet_send_nkch(int useridx, char *oldnick)
  456. {
  457. int l;
  458. if (tands > 0) {
  459. l = simple_sprintf(OBUF, "nc %s %D %s\n", conf.bot->nick,
  460. dcc[useridx].sock, dcc[useridx].nick);
  461. send_tand_but(-1, OBUF, -l);
  462. }
  463. }
  464. void botnet_send_nkch_part(int butidx, int useridx, char *oldnick)
  465. {
  466. int l;
  467. if (tands > 0) {
  468. l = simple_sprintf(OBUF, "nc %s %D %s\n", party[useridx].bot,
  469. party[useridx].sock, party[useridx].nick);
  470. send_tand_but(butidx, OBUF, -l);
  471. }
  472. }
  473. /* This part of add_note is more relevant to the botnet than
  474. * to the notes file
  475. */
  476. int add_note(char *to, char *from, char *msg, int idx, int echo)
  477. {
  478. int status, i, iaway, sock;
  479. char *p = NULL, botf[81] = "", ss[81] = "", ssf[81] = "";
  480. struct userrec *u;
  481. if (strlen(msg) > 450)
  482. msg[450] = 0; /* Notes have a limit */
  483. /* note length + PRIVMSG header + nickname + date must be <512 */
  484. p = strchr(to, '@');
  485. if (p != NULL) { /* Cross-bot note */
  486. char x[21] = "";
  487. *p = 0;
  488. strncpy(x, to, 20);
  489. x[20] = 0;
  490. *p = '@';
  491. p++;
  492. if (!egg_strcasecmp(p, conf.bot->nick)) /* To me?? */
  493. return add_note(x, from, msg, idx, echo); /* Start over, dimwit. */
  494. if (egg_strcasecmp(from, conf.bot->nick)) {
  495. if (strlen(from) > 40)
  496. from[40] = 0;
  497. if (strchr(from, '@')) {
  498. strcpy(botf, from);
  499. } else
  500. sprintf(botf, "%s@%s", from, conf.bot->nick);
  501. } else
  502. strcpy(botf, conf.bot->nick);
  503. i = nextbot(p);
  504. if (i < 0) {
  505. if (idx >= 0)
  506. dprintf(idx, BOT_NOTHERE);
  507. return NOTE_ERROR;
  508. }
  509. if ((idx >= 0) && (echo))
  510. dprintf(idx, "-> %s@%s: %s\n", x, p, msg);
  511. if (idx >= 0) {
  512. sprintf(ssf, "%lu:%s", dcc[idx].sock, botf);
  513. botnet_send_priv(i, ssf, x, p, "%s", msg);
  514. } else
  515. botnet_send_priv(i, botf, x, p, "%s", msg);
  516. return NOTE_OK; /* Forwarded to the right bot */
  517. }
  518. /* Might be form "sock:nick" */
  519. splitc(ssf, from, ':');
  520. rmspace(ssf);
  521. splitc(ss, to, ':');
  522. rmspace(ss);
  523. if (!ss[0])
  524. sock = (-1);
  525. else
  526. sock = atoi(ss);
  527. /* Don't process if there's a note binding for it */
  528. if (idx != (-2)) { /* Notes from bots don't trigger it */
  529. if (check_bind_note(from, to, msg)) {
  530. if ((idx >= 0) && (echo))
  531. dprintf(idx, "-> %s: %s\n", to, msg);
  532. return NOTE_TCL;
  533. }
  534. }
  535. if (!(u = get_user_by_handle(userlist, to))) {
  536. if (idx >= 0)
  537. dprintf(idx, USERF_UNKNOWN);
  538. return NOTE_ERROR;
  539. }
  540. if (is_bot(u)) {
  541. if (idx >= 0)
  542. dprintf(idx, BOT_NONOTES);
  543. return NOTE_ERROR;
  544. }
  545. status = NOTE_STORED;
  546. iaway = 0;
  547. /* Online right now? */
  548. for (i = 0; i < dcc_total; i++) {
  549. if ((dcc[i].type->flags & DCT_GETNOTES) &&
  550. ((sock == (-1)) || (sock == dcc[i].sock)) &&
  551. (!egg_strcasecmp(dcc[i].nick, to))) {
  552. int aok = 1;
  553. if (dcc[i].type == &DCC_CHAT)
  554. if ((dcc[i].u.chat->away != NULL) &&
  555. (idx != (-2))) {
  556. /* Only check away if it's not from a bot */
  557. aok = 0;
  558. if (idx >= 0)
  559. dprintf(idx, "%s %s: %s\n", dcc[i].nick, BOT_USERAWAY,
  560. dcc[i].u.chat->away);
  561. if (!iaway)
  562. iaway = i;
  563. status = NOTE_AWAY;
  564. }
  565. if (aok) {
  566. char *p = NULL, *fr = from;
  567. int l = 0;
  568. char work[1024] = "";
  569. while ((*msg == '<') || (*msg == '>')) {
  570. p = newsplit(&msg);
  571. if (*p == '<')
  572. l += simple_sprintf(work + l, "via %s, ", p + 1);
  573. else if (*from == '@')
  574. fr = p + 1;
  575. }
  576. if (idx == -2 || (!egg_strcasecmp(from, conf.bot->nick)))
  577. dprintf(i, "*** [%s] %s%s\n", fr, l ? work : "", msg);
  578. else
  579. dprintf(i, "%cNote [%s]: %s%s\n", 7, fr, l ? work : "", msg);
  580. if ((idx >= 0) && (echo))
  581. dprintf(idx, "-> %s: %s\n", to, msg);
  582. return NOTE_OK;
  583. }
  584. }
  585. }
  586. if (idx == (-2))
  587. return NOTE_OK; /* Error msg from a tandembot: don't store */
  588. status = storenote(from, to, msg, idx, NULL, 0);
  589. if (status < 0) status = NOTE_ERROR;
  590. else if (status == NOTE_AWAY) {
  591. /* User is away in all sessions -- just notify the user that a
  592. * message arrived and was stored. (only oldest session is notified.)
  593. */
  594. dprintf(iaway, "*** %s.\n", BOT_NOTEARRIVED);
  595. }
  596. return(status);
  597. }