/[cvs]/eggdrop1.9/src/core_binds.c
ViewVC logotype

Contents of /eggdrop1.9/src/core_binds.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.20 - (show annotations) (download) (as text)
Fri Dec 15 09:30:47 2006 UTC (12 years, 3 months ago) by sven
Branch: MAIN
CVS Tags: HEAD
Changes since 1.19: +1 -1 lines
File MIME type: text/x-chdr

 * Added a function to delete all bots by owner.
 * Documented the user binds.

I did not fix the various oddities of the user binds because a lot of other
binds have similar problems and they should be fixed all at the same time
to get consistent behaviour.

1 /* core_binds.c: core bind tables
2 *
3 * Copyright (C) 2001, 2002, 2003, 2004 Eggheads Development Team
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 #include <eggdrop/eggdrop.h>
21 #include "core_binds.h" /* prototypes */
22
23 /*!
24 * \bind
25 * This bind is triggered once a minute. It is similar to ::BT_event minutely
26 * but allows you to match a specified date and time.
27 * \name time
28 * \flags Ignored.
29 * \match The currect date and time in the format: "minute hour day month year".
30 * All fields except for "year" are two digit numbers including a leading
31 * 0 if necessary. "hour" is a number in 24 hour format between 0 and 23.
32 * "year" is a full 4 digit number.
33 * \param int The "minute" field of the match string.
34 * \param int The "hour" field of the match string.
35 * \param int The "day" field of the match string.
36 * \param int The "month" field of the match string.
37 * \param int The "year" field of the match string.
38 * \stackable
39 * \noreturn
40 */
41
42 static bind_table_t *BT_time = NULL;
43
44 /*!
45 * \bind
46 * This bind is triggered once every second. The bind is not triggered one second
47 * after the time it was triggered last but one second after the time it should
48 * have been triggered last. So it should be triggered 60 times per minute on avarage.
49 * You should \b never do anything that \a might take longer than one second to
50 * execute here.
51 * \name secondly
52 * \flags Ignored.
53 * \match None.
54 * \noparam
55 * \stackable
56 * \noreturn
57 */
58
59 static bind_table_t *BT_secondly = NULL;
60
61 /*!
62 * \bind
63 * This bind is triggered every time a local partymember executes the ".status"
64 * command on the partyline.
65 * \name status
66 * \flags Ignored.
67 * \match None.
68 * \param partymember The partymember who typed ".status" on the partyline.
69 * \param string Whatever the user typed after ".status".
70 * \stackable
71 * \noreturn
72 * \bug The flags and match shouldn't be ignored, right?
73 */
74
75 static bind_table_t *BT_status = NULL;
76
77 /*!
78 * \bind
79 * This bind is triggered when the bot is originally started and then every
80 * time after a restart. It's impossible to tell which of the two just happened.
81 * \name init
82 * \flags Ignored.
83 * \match None.
84 * \noparam
85 * \stackable
86 * \noreturn
87 * \bug Should there be a way to tell a start from a restart?
88 */
89
90 static bind_table_t *BT_init = NULL;
91
92 /*!
93 * \bind
94 * This bind is triggered when the bot shuts down and before every restart.
95 * It's impossible to tell which of the two just happened.
96 * \name shutdown
97 * \flags Ignored.
98 * \match None.
99 * \noparam
100 * \stackable
101 * \noreturn
102 * \bug Should there be a way to tell a shutdown from a restart?
103 */
104
105 static bind_table_t *BT_shutdown = NULL;
106
107 int core_binds_init(void)
108 {
109 BT_init = bind_table_add (BTN_CORE_INIT, 0, "", MATCH_NONE, BIND_STACKABLE); /* DDD */
110 BT_shutdown = bind_table_add (BTN_CORE_SHUTDOWN, 0, "", MATCH_NONE, BIND_STACKABLE); /* DDD */
111 BT_time = bind_table_add(BTN_CORE_TIME, 5, "iiiii", MATCH_MASK, BIND_STACKABLE); /* DDD */
112 BT_secondly = bind_table_add(BTN_CORE_SECONDLY, 0, "", MATCH_NONE, BIND_STACKABLE); /* DDD */
113 BT_status = bind_table_add(BTN_CORE_STATUS, 2, "Ps", MATCH_NONE, BIND_STACKABLE); /* DDD */
114
115 return (0);
116 }
117
118 int core_binds_shutdown(void)
119 {
120 bind_table_del(BT_status);
121 bind_table_del(BT_secondly);
122 bind_table_del(BT_time);
123 bind_table_del(BT_shutdown);
124 bind_table_del(BT_init);
125
126 return (0);
127 }
128
129 void check_bind_init(void)
130 {
131 egg_assert(BT_init != NULL);
132
133 bind_check (BT_init, NULL, NULL);
134 }
135
136 void check_bind_shutdown (void)
137 {
138 egg_assert(BT_shutdown != NULL);
139
140 bind_check (BT_shutdown, NULL, NULL);
141 }
142
143 void check_bind_time(struct tm *tm)
144 {
145 char full[32];
146
147 sprintf(full, "%02d %02d %02d %02d %04d", tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon + 1, tm->tm_year + 1900);
148 bind_check(BT_time, NULL, full, tm->tm_min, tm->tm_hour, tm->tm_mday, tm->tm_mon + 1, tm->tm_year + 1900);
149 }
150
151 void check_bind_secondly()
152 {
153 bind_check(BT_secondly, NULL, NULL);
154 }
155
156 void check_bind_status(partymember_t *p, const char *text)
157 {
158 bind_check(BT_status, NULL, NULL, p, text);
159 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23