2 * Copyright (C) 2017 Andy Spencer <andy753421@gmail.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
41 chat_log = (log_t*)log_buf.data;
48 void chat_config(const char *group, const char *name, const char *key, const char *value)
50 irc_config(group, name, key, value);
51 xmpp_config(group, name, key, value);
54 void chat_notice(const char *channel, const char *from, const char *fmt, ...)
56 static char buf[1024];
60 vsnprintf(buf, sizeof(buf), fmt, ap);
63 chat_recv(channel, from, buf);
66 void chat_recv(const char *channel, const char *from, const char *msg)
68 append(&log_buf, NULL, sizeof(log_t));
69 chat_log = (log_t*)log_buf.data;
71 log_t *log = &chat_log[chat_len];
72 log->when = time(NULL);
73 log->from = strcopy(from);
74 log->channel = strcopy(channel);
75 log->msg = strcopy(msg);
81 void chat_send(const char *channel, const char *msg)
83 append(&log_buf, NULL, sizeof(log_t));
84 chat_log = (log_t*)log_buf.data;
86 log_t *log = &chat_log[chat_len];
87 log->when = time(NULL);
89 log->channel = strcopy(channel);
90 log->msg = strcopy(msg);
93 irc_send(channel, msg);
94 xmpp_send(channel, msg);
103 for (int i = 0; i < chat_len; i++)
104 free((void*)chat_log[i].msg);