]> jfr.im git - irc/evilnet/x3.git/blame - src/mod-webtv.c
Basic module for webtv module work, plus updated google core dumper to version 1.1
[irc/evilnet/x3.git] / src / mod-webtv.c
CommitLineData
2784452e 1/* mod-webtv.c - WebTV Module for X3
2 * Copyright 2007 X3 Development Team
3 *
4 * This file is part of x3.
5 *
6 * x3 is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with srvx; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 */
20
21/*
22 *
23 * /msg opserv bind opserv service *modcmd.joiner
24 * /msg opserv bind opserv service\ add *modcmd.service\ add
25 * /msg opserv bind opserv service\ rename *modcmd.service\ rename
26 * /msg opserv bind opserv service\ trigger *modcmd.service\ trigger
27 * /msg opserv bind opserv service\ remove *modcmd.service\ remove
28 * Add the bot:
29 * /msg opserv service add IRC WebTV Service Bot
30 * /msg opserv bind IRC help *modcmd.help
31 * Restart X3 with the updated conf file (as above, butwith "bot"
32 * "IRC"), and bind the commands to it:
33 * /msg opserv bind IRC * *webtv.*
34 * /msg opserv bind IRC set *webtv.set
35 */
36
37#include "chanserv.h"
38#include "conf.h"
39#include "modcmd.h"
40#include "nickserv.h"
41#include "opserv.h"
42#include "saxdb.h"
43#include "timeq.h"
44
45static const struct message_entry msgtab[] = {
46 { "MSMSG_CANNOT_SEND", "You cannot send to account $b%s$b." },
47
48 { NULL, NULL }
49};
50
51struct userNode *webtv;
52
53#define WEBTV_FUNC(NAME) MODCMD_FUNC(NAME)
54#define WEBTV_SYNTAX() svccmd_send_help_brief(user, webtv, cmd)
55#define WEBTV_MIN_PARAMS(N) if(argc < (N)) { \
56 reply("MSG_MISSING_PARAMS", argv[0]); \
57 WEBTV_SYNTAX(); \
58 return 0; }
59
60static struct {
61 struct userNode *bot;
62} webtv_conf;
63
64#define OPTION_FUNC(NAME) int NAME(struct svccmd *cmd, struct userNode *user, struct handle_info *hi, UNUSED_ARG(unsigned int override), unsigned int argc, char *argv[])
65typedef OPTION_FUNC(option_func_t);
66
67extern struct string_list *autojoin_channels;
68const char *webtv_module_deps[] = { NULL };
69static struct module *webtv_module;
70static struct log_type *WB_LOG;
71
72
73
74
75
76
77
78static void
79webtv_conf_read(void)
80{
81 dict_t conf_node;
82 const char *str;
83
84 str = "modules/webtv";
85 if (!(conf_node = conf_get_data(str, RECDB_OBJECT))) {
86 log_module(WB_LOG, LOG_ERROR, "config node `%s' is missing or has wrong type.", str);
87 return;
88 }
89}
90
91static void
92webtv_cleanup(void)
93{
94}
95
96int
97webtv_init(void)
98{
99 WB_LOG = log_register_type("WebTV", "file:webtv.log");
100
101 conf_register_reload(webtv_conf_read);
102 reg_exit_func(webtv_cleanup);
103
104 webtv_module = module_register("WebTV", WB_LOG, "mod-webtv.help", NULL);
105/*
106 modcmd_register(webtv_module, "send", cmd_send, 3, MODCMD_REQUIRE_AUTHED, NULL);
107 modcmd_register(webtv_module, "expire", cmd_expire, 1, MODCMD_REQUIRE_AUTHED, "flags", "+oper", NULL);
108*/
109 message_register_table(msgtab);
110 return 1;
111}
112
113int
114webtv_finalize(void) {
115 struct chanNode *chan;
116 unsigned int i;
117 dict_t conf_node;
118 const char *str;
119
120 str = "modules/webtv";
121 if (!(conf_node = conf_get_data(str, RECDB_OBJECT))) {
122 log_module(WB_LOG, LOG_ERROR, "config node `%s' is missing or has wrong type.", str);
123 return 0;
124 }
125
126 str = database_get_data(conf_node, "bot", RECDB_QSTRING);
127 if (str) {
128 webtv = webtv_conf.bot;
129 const char *modes = conf_get_data("modules/webtv/modes", RECDB_QSTRING);
130 webtv = AddService(str, modes ? modes : NULL, "WebTV IRC Service", NULL);
131 } else {
132 log_module(WB_LOG, LOG_ERROR, "database_get_data for webtv_conf.bot failed!");
133 exit(1);
134 }
135
136 if (autojoin_channels && webtv) {
137 for (i = 0; i < autojoin_channels->used; i++) {
138 chan = AddChannel(autojoin_channels->list[i], now, "+nt", NULL, NULL);
139 AddChannelUser(webtv, chan)->modes |= MODE_CHANOP;
140 }
141 }
142
143 return 1;
144}