File: writing.html

package info (click to toggle)
eggdrop 1.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,596 kB
  • sloc: ansic: 65,863; javascript: 8,908; sh: 5,337; tcl: 3,801; makefile: 1,771; python: 121
file content (461 lines) | stat: -rw-r--r-- 35,756 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
<!DOCTYPE html>

<html lang="en" data-content_root="../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

    <title>How to Write an Eggdrop Module &#8212; Eggdrop 1.10.1rc2 documentation</title>
    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=03e43079" />
    <link rel="stylesheet" type="text/css" href="../_static/eggdrop.css?v=ab48a1b6" />
    <script src="../_static/documentation_options.js?v=290de6c6"></script>
    <script src="../_static/doctools.js?v=9bcbadda"></script>
    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Eggdrop Bind Internals" href="internals.html" />
    <link rel="prev" title="Uptime Module" href="mod/uptime.html" /> 
  </head><body>
    <div class="header-wrapper" role="banner">
      <div class="header">
        <div class="headertitle"><a
          href="../index.html">Eggdrop 1.10.1rc2 documentation</a></div>
        <div class="rel" role="navigation" aria-label="related navigation">
          <a href="mod/uptime.html" title="Uptime Module"
             accesskey="P">previous</a> |
          <a href="internals.html" title="Eggdrop Bind Internals"
             accesskey="N">next</a>
        </div>
       </div>
    </div>

    <div class="content-wrapper">
      <div class="content">
        <div class="sidebar">
          
          <h3>Table of Contents</h3>
          <p class="caption" role="heading"><span class="caption-text">Installing Eggdrop</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../install/readme.html">README</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install/install.html">Installing Eggdrop</a></li>
<li class="toctree-l1"><a class="reference internal" href="../install/upgrading.html">Upgrading Eggdrop</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Using Eggdrop</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../using/features.html">Eggdrop Features</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/core.html">Eggdrop Core Settings</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/partyline.html">The Party Line</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/autoscripts.html">Eggdrop Autoscripts</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/users.html">Users and Flags</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/bans.html">Bans, Invites, and Exempts</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/botnet.html">Botnet Sharing and Linking</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/ipv6.html">IPv6 support</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/tls.html">TLS support</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/ircv3.html">IRCv3 support</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/accounts.html">Account tracking in Eggdrop</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/pbkdf2info.html">Encryption/Hashing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/python.html">Using the Python Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/twitchinfo.html">Twitch</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/tricks.html">Advanced Tips</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/text-sub.html">Textfile Substitutions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/tcl-commands.html">Eggdrop Tcl Commands</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/twitch-tcl-commands.html">Eggdrop Twitch Tcl Commands</a></li>
<li class="toctree-l1"><a class="reference internal" href="../using/patch.html">Patching Eggdrop</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Tutorials</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/setup.html">Setting Up Eggdrop</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/firststeps.html">Common First Steps</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/tlssetup.html">Enabling TLS Security on Eggdrop</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/userfilesharing.html">Sharing Userfiles</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/firstscript.html">Writing an Eggdrop Tcl Script</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/module.html">Writing a Basic Eggdrop Module</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Eggdrop Modules</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="index.html">Eggdrop Module Information</a></li>
<li class="toctree-l1"><a class="reference internal" href="included.html">Modules included with Eggdrop</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">How to Write an Eggdrop Module</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#module-requirements">Module requirements</a></li>
<li class="toctree-l2"><a class="reference internal" href="#what-to-do-with-a-module">What to do with a module?</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="internals.html">Eggdrop Bind Internals</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">About Eggdrop</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../about/about.html">About Eggdrop</a></li>
<li class="toctree-l1"><a class="reference internal" href="../about/legal.html">Boring legal stuff</a></li>
</ul>

          <div role="search">
            <h3 style="margin-top: 1.5em;">Search</h3>
            <form class="search" action="../search.html" method="get">
                <input type="text" name="q" />
                <input type="submit" value="Go" />
            </form>
          </div>

        </div>
        <div class="document">
            
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="how-to-write-an-eggdrop-module">
<span id="writing-module"></span><h1>How to Write an Eggdrop Module<a class="headerlink" href="#how-to-write-an-eggdrop-module" title="Link to this heading">¶</a></h1>
<p>Note: This is for a simple module of 1 source file.</p>
<blockquote>
<div><ol class="arabic">
<li><p>Create a src/mod/MODULE.mod directory in your Eggdrop directory (where
MODULE is the module name) and cd to it.</p></li>
<li><p>Copy the file ‘Makefile’ from src/mod/woobie.mod and replace all
occurrences of ‘woobie’ with your module name. This should ensure
that your module gets compiled.</p></li>
<li><p>Next, you want to create a file called MODULE.c (MODULE is the module
name again).</p></li>
<li><p>You MUST include the following in your source code:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1">#define MODULE_NAME &quot;module-name&quot;</span>
</pre></div>
</div>
</li>
</ol>
<blockquote>
<div><p>This should be defined to the same name you will be using when you load
your module.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1">#define MAKING_MODULENAME</span>
</pre></div>
</div>
<p>MODULENAME is the name of your module (MODULE_NAME), but in all caps.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1">#include &quot;../module.h&quot;</span>
</pre></div>
</div>
<p>This provides access to Eggdrop’s global function table. Examine
src/mod/module.h closely to find a list of functions available.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1">#include any other standard c header files you might need.</span>
</pre></div>
</div>
<p>Note that stdio.h, string.h, stdlib.h, and sys/types.h are already included.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Function</span> <span class="o">*</span><span class="k">global</span><span class="p">;</span>
</pre></div>
</div>
<p>This variable provides access to all the Eggdrop functions; without it,
you can’t call any Eggdrop functions (the module won’t even load).</p>
</div></blockquote>
</div></blockquote>
<section id="module-requirements">
<h2>Module requirements<a class="headerlink" href="#module-requirements" title="Link to this heading">¶</a></h2>
<p>In most modules, all functions/variables (except global and MODULE_start)
should be static. This will drastically reduce the size of modules on
decent systems.</p>
<p>Throughout this step, MODULE refers to the module name. Note that
“MODULE_NAME” should literally be “MODULE_NAME”.</p>
<section id="module-start">
<h3>MODULE_start<a class="headerlink" href="#module-start" title="Link to this heading">¶</a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">char</span> <span class="o">*</span><span class="n">MODULE_start</span><span class="p">(</span><span class="n">Function</span> <span class="o">*</span><span class="n">func_table</span><span class="p">)</span>
</pre></div>
</div>
<p>This function is called when the module is first loaded. There are
several things that need to be done in this function</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">global</span> <span class="o">=</span> <span class="n">func_table</span><span class="p">;</span>
</pre></div>
</div>
<p>This allows you to make calls to the global function table.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">module_register</span><span class="p">(</span><span class="n">MODULE_NAME</span><span class="p">,</span> <span class="n">MODULE_table</span><span class="p">,</span> <span class="n">MAJOR</span><span class="p">,</span> <span class="n">MINOR</span><span class="p">);</span>
</pre></div>
</div>
<p>This records details about the module for other modules and Eggdrop
itself to access. MAJOR and MINOR are ints, where MAJOR is the
module’s major version number and MINOR is a minor version number.
MODULE_table is a function table (see below).</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">module_depend</span><span class="p">(</span><span class="n">MODULE_NAME</span><span class="p">,</span> <span class="s2">&quot;another-module&quot;</span><span class="p">,</span> <span class="n">MAJOR</span><span class="p">,</span> <span class="n">MINOR</span><span class="p">);</span>
</pre></div>
</div>
<p>This lets Eggdrop know that your module NEEDS “another-module” of
major version ‘MAJOR’ and at least minor version ‘MINOR’ to run,
and hence should try to load it if it’s not already loaded. This
will return 1 on success, or 0 if it can’t be done (at which stage
you should return an error).</p>
<p>Any other initialization stuff you desire should also be included in
this function. See below for various things you can do.</p>
<p>You also will need to return a value. Returning NULL implies the
module loaded successfully. Returning a non-NULL STRING is an error
message. The module (and any other dependent modules) will stop
loading and an error will be returned.</p>
</section>
<section id="module-table">
<h3>MODULE_table<a class="headerlink" href="#module-table" title="Link to this heading">¶</a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">static</span> <span class="n">Function</span> <span class="o">*</span><span class="n">MODULE_table</span> <span class="o">=</span> <span class="p">{</span>
       <span class="n">MODULE_start</span><span class="p">,</span>
       <span class="n">MODULE_close</span><span class="p">,</span>
       <span class="n">MODULE_expmem</span><span class="p">,</span>
       <span class="n">MODULE_report</span><span class="p">,</span>
       <span class="n">any_other_functions</span><span class="p">,</span>
       <span class="n">you_want_to_export</span>
<span class="p">};</span>
</pre></div>
</div>
<p>This is a table of functions which any other module can access. The
first 4 functions are FIXED. You MUST have them; they provide important
module information.</p>
</section>
<section id="module-close">
<h3>MODULE_close ()<a class="headerlink" href="#module-close" title="Link to this heading">¶</a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">static</span> <span class="n">char</span> <span class="o">*</span><span class="n">MODULE_close</span> <span class="p">()</span>
</pre></div>
</div>
<p>This is called when the module is unloaded. Apart from tidying any
relevant data (I suggest you be thorough, we don’t want any trailing
garbage from modules), you MUST do the following:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">module_undepend</span><span class="p">(</span><span class="n">MODULE_NAME</span><span class="p">);</span>
</pre></div>
</div>
<p>This lets Eggdrop know your module no longer depends on any other
modules.</p>
<p>Return a value. NULL implies success; any non-NULL STRING implies
that the module cannot be unloaded for some reason, and hence the
bot should not unload it (see the blowfish module for an example).</p>
</section>
<section id="module-expmem">
<h3>MODULE_expmem<a class="headerlink" href="#module-expmem" title="Link to this heading">¶</a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">static</span> <span class="nb">int</span> <span class="n">MODULE_expmem</span> <span class="p">()</span>

<span class="n">This</span> <span class="n">should</span> <span class="n">tally</span> <span class="nb">all</span> <span class="n">memory</span> <span class="n">you</span> <span class="n">allocate</span><span class="o">/</span><span class="n">deallocate</span> <span class="n">within</span> <span class="n">the</span> <span class="n">module</span>
<span class="p">(</span><span class="n">using</span> <span class="n">nmalloc</span><span class="p">,</span> <span class="n">nfree</span><span class="p">,</span> <span class="n">etc</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">bytes</span><span class="o">.</span> <span class="n">It</span><span class="s1">&#39;s used by memory debugging to</span>
<span class="n">track</span> <span class="n">memory</span> <span class="n">faults</span><span class="p">,</span> <span class="ow">and</span> <span class="n">it</span> <span class="ow">is</span> <span class="n">used</span> <span class="n">by</span> <span class="o">.</span><span class="n">status</span> <span class="n">to</span> <span class="n">total</span> <span class="n">up</span> <span class="n">memory</span> <span class="n">usage</span><span class="o">.</span>
</pre></div>
</div>
</section>
<section id="module-report">
<h3>MODULE_report<a class="headerlink" href="#module-report" title="Link to this heading">¶</a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">static</span> <span class="n">void</span> <span class="n">MODULE_report</span> <span class="p">(</span><span class="nb">int</span> <span class="n">idx</span><span class="p">)</span>
</pre></div>
</div>
<p>This should provide a relatively short report of the module’s status
(for the module and status commands).</p>
<p>These functions are available to modules. MANY more available functions
can be found in src/mod/module.h.</p>
</section>
<section id="additional-functions">
<h3>Additional functions<a class="headerlink" href="#additional-functions" title="Link to this heading">¶</a></h3>
<section id="nmalloc">
<h4>nmalloc<a class="headerlink" href="#nmalloc" title="Link to this heading">¶</a></h4>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">void</span> <span class="o">*</span><span class="n">nmalloc</span><span class="p">(</span><span class="nb">int</span> <span class="n">j</span><span class="p">);</span>
</pre></div>
</div>
<p>This allocates j bytes of memory.</p>
</section>
<section id="nfree">
<h4>nfree<a class="headerlink" href="#nfree" title="Link to this heading">¶</a></h4>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">void</span> <span class="n">nfree</span><span class="p">(</span><span class="n">void</span> <span class="o">*</span><span class="n">a</span><span class="p">);</span>
</pre></div>
</div>
<p>This frees an nmalloc’d block of memory.</p>
</section>
<section id="context">
<h4>Context<a class="headerlink" href="#context" title="Link to this heading">¶</a></h4>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Context</span><span class="p">;</span>
</pre></div>
</div>
<p>Actually a macro – records the current position in execution (for
debugging). Using Context is no longer recommended, because it uses
too many resources and a core file provides much more information.</p>
</section>
<section id="dprintf">
<h4>dprintf<a class="headerlink" href="#dprintf" title="Link to this heading">¶</a></h4>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">void</span> <span class="n">dprintf</span><span class="p">(</span><span class="nb">int</span> <span class="n">idx</span><span class="p">,</span> <span class="n">char</span> <span class="o">*</span><span class="nb">format</span><span class="p">,</span> <span class="o">...</span><span class="p">)</span>
</pre></div>
</div>
<p>This acts like a normal printf() function, but it outputs to
log/socket/idx. idx is a normal dcc idx, or if &lt; 0 is a sock number.</p>
<blockquote>
<div><p>Other destinations:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">DP_LOG</span>    <span class="o">-</span> <span class="n">send</span> <span class="n">to</span> <span class="n">log</span> <span class="n">file</span>
<span class="n">DP_STDOUT</span> <span class="o">-</span> <span class="n">send</span> <span class="n">to</span> <span class="n">stdout</span>
<span class="n">DP_MODE</span>   <span class="o">-</span> <span class="n">send</span> <span class="n">via</span> <span class="n">mode</span> <span class="n">queue</span> <span class="n">to</span> <span class="n">the</span> <span class="n">server</span>
<span class="n">DP_SERVER</span> <span class="o">-</span> <span class="n">send</span> <span class="n">via</span> <span class="n">normal</span> <span class="n">queue</span> <span class="n">to</span> <span class="n">the</span> <span class="n">server</span>
<span class="n">DP_HELP</span>   <span class="o">-</span> <span class="n">send</span> <span class="n">via</span> <span class="n">help</span> <span class="n">queue</span> <span class="n">to</span> <span class="n">server</span>
</pre></div>
</div>
</div></blockquote>
</section>
<section id="module-entry">
<h4>module_entry<a class="headerlink" href="#module-entry" title="Link to this heading">¶</a></h4>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">const</span> <span class="n">module_entry</span> <span class="o">*</span><span class="n">module_find</span><span class="p">(</span><span class="n">char</span> <span class="o">*</span><span class="n">module_name</span><span class="p">,</span> <span class="nb">int</span> <span class="n">major</span><span class="p">,</span> <span class="nb">int</span> <span class="n">minor</span><span class="p">);</span>
</pre></div>
</div>
<p>Searches for a loaded module (matching major, &gt;= minor), and returns
info about it.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Members</span> <span class="n">of</span> <span class="n">module_entry</span><span class="p">:</span>

<span class="n">char</span> <span class="o">*</span><span class="n">name</span><span class="p">;</span>      <span class="o">-</span> <span class="n">module</span> <span class="n">name</span>
<span class="nb">int</span> <span class="n">major</span><span class="p">;</span>       <span class="o">-</span> <span class="n">real</span> <span class="n">major</span> <span class="n">version</span>
<span class="nb">int</span> <span class="n">minor</span><span class="p">;</span>       <span class="o">-</span> <span class="n">real</span> <span class="n">minor</span> <span class="n">version</span>
<span class="n">Function</span> <span class="o">*</span><span class="n">funcs</span><span class="p">;</span> <span class="o">-</span> <span class="n">function</span> <span class="n">table</span> <span class="p">(</span><span class="n">see</span> <span class="n">above</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="module-rename">
<h4>module_rename<a class="headerlink" href="#module-rename" title="Link to this heading">¶</a></h4>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">void</span> <span class="n">module_rename</span><span class="p">(</span><span class="n">char</span> <span class="o">*</span><span class="n">old_module_name</span><span class="p">,</span> <span class="n">char</span> <span class="o">*</span><span class="n">new_module_name</span><span class="p">)</span>
</pre></div>
</div>
<p>This renames a module from old_module_name to new_module_name.</p>
</section>
<section id="add-hook-del-hook">
<h4>add_hook/del_hook<a class="headerlink" href="#add-hook-del-hook" title="Link to this heading">¶</a></h4>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">void</span> <span class="n">add_hook</span><span class="p">(</span><span class="nb">int</span> <span class="n">hook_num</span><span class="p">,</span> <span class="n">Function</span> <span class="o">*</span><span class="n">funcs</span><span class="p">)</span>
<span class="n">void</span> <span class="n">del_hook</span><span class="p">(</span><span class="nb">int</span> <span class="n">hook_num</span><span class="p">,</span> <span class="n">Function</span> <span class="o">*</span><span class="n">funcs</span><span class="p">)</span>
</pre></div>
</div>
<p>These are used for adding or removing hooks to/from Eggdrop code that
are triggered on various events. Valid hooks are:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">HOOK_SECONDLY</span>   <span class="o">-</span> <span class="n">called</span> <span class="n">every</span> <span class="n">second</span>
<span class="n">HOOK_MINUTELY</span>   <span class="o">-</span> <span class="n">called</span> <span class="n">every</span> <span class="n">minute</span>
<span class="n">HOOK_5MINUTELY</span>  <span class="o">-</span> <span class="n">called</span> <span class="n">every</span> <span class="mi">5</span> <span class="n">minutes</span>
<span class="n">HOOK_HOURLY</span>     <span class="o">-</span> <span class="n">called</span> <span class="n">every</span> <span class="n">hour</span> <span class="p">(</span><span class="n">hourly</span><span class="o">-</span><span class="n">updates</span> <span class="n">minutes</span> <span class="n">past</span><span class="p">)</span>
<span class="n">HOOK_DAILY</span>      <span class="o">-</span> <span class="n">called</span> <span class="n">when</span> <span class="n">the</span> <span class="n">logfiles</span> <span class="n">are</span> <span class="n">switched</span>

<span class="n">HOOK_READ_USERFILE</span> <span class="o">-</span> <span class="n">called</span> <span class="n">when</span> <span class="n">the</span> <span class="n">userfile</span> <span class="ow">is</span> <span class="n">read</span>
<span class="n">HOOK_USERFILE</span>      <span class="o">-</span> <span class="n">called</span> <span class="n">when</span> <span class="n">the</span> <span class="n">userfile</span> <span class="ow">is</span> <span class="n">written</span>
<span class="n">HOOK_PRE_REHASH</span>    <span class="o">-</span> <span class="n">called</span> <span class="n">just</span> <span class="n">before</span> <span class="n">a</span> <span class="n">rehash</span>
<span class="n">HOOK_REHASH</span>        <span class="o">-</span> <span class="n">called</span> <span class="n">just</span> <span class="n">after</span> <span class="n">a</span> <span class="n">rehash</span>
<span class="n">HOOK_IDLE</span>          <span class="o">-</span> <span class="n">called</span> <span class="n">whenever</span> <span class="n">the</span> <span class="n">dcc</span> <span class="n">connections</span> <span class="n">have</span> <span class="n">been</span>
                     <span class="n">idle</span> <span class="k">for</span> <span class="n">a</span> <span class="n">whole</span> <span class="n">second</span>
<span class="n">HOOK_BACKUP</span>        <span class="o">-</span> <span class="n">called</span> <span class="n">when</span> <span class="n">a</span> <span class="n">user</span><span class="o">/</span><span class="n">channel</span> <span class="n">file</span> <span class="n">backup</span> <span class="ow">is</span> <span class="n">done</span>
<span class="n">HOOK_LOADED</span>        <span class="o">-</span> <span class="n">called</span> <span class="n">when</span> <span class="n">Eggdrop</span> <span class="ow">is</span> <span class="n">first</span> <span class="n">loaded</span>
<span class="n">HOOK_DIE</span>           <span class="o">-</span> <span class="n">called</span> <span class="n">when</span> <span class="n">Eggdrop</span> <span class="ow">is</span> <span class="n">about</span> <span class="n">to</span> <span class="n">die</span>
</pre></div>
</div>
</section>
<section id="module-load-unload">
<h4>module_load/unload<a class="headerlink" href="#module-load-unload" title="Link to this heading">¶</a></h4>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">char</span> <span class="o">*</span><span class="n">module_unload</span> <span class="p">(</span><span class="n">char</span> <span class="o">*</span><span class="n">module_name</span><span class="p">);</span>
<span class="n">char</span> <span class="o">*</span><span class="n">module_load</span> <span class="p">(</span><span class="n">char</span> <span class="o">*</span><span class="n">module_name</span><span class="p">);</span>
</pre></div>
</div>
<p>Tries to load or unload the specified module; returns 0 on success, or
an error message.</p>
</section>
<section id="add-rem-tcl-commands">
<h4>add/rem_tcl_commands<a class="headerlink" href="#add-rem-tcl-commands" title="Link to this heading">¶</a></h4>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">void</span> <span class="n">add_tcl_commands</span><span class="p">(</span><span class="n">tcl_cmds</span> <span class="o">*</span><span class="n">tab</span><span class="p">);</span>
<span class="n">void</span> <span class="n">rem_tcl_commands</span><span class="p">(</span><span class="n">tcl_cmds</span> <span class="o">*</span><span class="n">tab</span><span class="p">);</span>
</pre></div>
</div>
<p>Provides a quick way to create and remove a table of Tcl commands. The
table is in the form of:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="n">char</span> <span class="o">*</span><span class="n">func_name</span><span class="p">,</span> <span class="n">Function</span> <span class="o">*</span><span class="n">function_to_call</span><span class="p">}</span>
</pre></div>
</div>
<p>Use { NULL, NULL } to indicate the end of the list.</p>
</section>
<section id="add-rem-tcl-ints">
<h4>add/rem_tcl_ints<a class="headerlink" href="#add-rem-tcl-ints" title="Link to this heading">¶</a></h4>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">void</span> <span class="n">add_tcl_ints</span><span class="p">(</span><span class="n">tcl_ints</span> <span class="o">*</span><span class="p">);</span>
<span class="n">void</span> <span class="n">rem_tcl_ints</span><span class="p">(</span><span class="n">tcl_ints</span> <span class="o">*</span><span class="p">);</span>
</pre></div>
</div>
<p>Provides a quick way to create and remove a table of links from C
int variables to Tcl variables (add_tcl_ints checks to see if the Tcl
variable exists and copies it over the C one). The format of table is:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="n">char</span> <span class="o">*</span><span class="n">variable_name</span><span class="p">,</span> <span class="nb">int</span> <span class="o">*</span><span class="n">variable</span><span class="p">,</span> <span class="nb">int</span> <span class="n">readonly</span><span class="p">}</span>
</pre></div>
</div>
<p>Use {NULL, NULL, 0} to indicate the end of the list.</p>
</section>
<section id="add-rem-tcl-strings">
<h4>add/rem_tcl_strings<a class="headerlink" href="#add-rem-tcl-strings" title="Link to this heading">¶</a></h4>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">void</span> <span class="n">add_tcl_strings</span><span class="p">(</span><span class="n">tcl_strings</span> <span class="o">*</span><span class="p">);</span>
<span class="n">void</span> <span class="n">rem_tcl_strings</span><span class="p">(</span><span class="n">tcl_strings</span> <span class="o">*</span><span class="p">);</span>
</pre></div>
</div>
<p>Provides a quick way to create and remove a table of links from C
string variables to Tcl variables (add_tcl_ints checks to see if the
Tcl variable exists and copies it over the C one). The format of table
is:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="n">char</span> <span class="o">*</span><span class="n">variable_name</span><span class="p">,</span> <span class="n">char</span> <span class="o">*</span><span class="n">string</span><span class="p">,</span> <span class="nb">int</span> <span class="n">length</span><span class="p">,</span> <span class="nb">int</span> <span class="n">flags</span><span class="p">}</span>
</pre></div>
</div>
<p>Use {NULL, NULL, 0, 0} to indicate the end of the list. Use 0 for
length if you want a const string. Use STR_DIR for flags if you want a
‘/’ constantly appended; use STR_PROTECT if you want the variable set
in the config file, but not during normal usage.</p>
</section>
<section id="add-rem-builtins">
<h4>add/rem_builtins<a class="headerlink" href="#add-rem-builtins" title="Link to this heading">¶</a></h4>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">void</span> <span class="n">add_builtins</span><span class="p">(</span><span class="n">p_tcl_hash_list</span> <span class="n">table</span><span class="p">,</span> <span class="n">cmd_t</span> <span class="o">*</span><span class="n">cc</span><span class="p">);</span>
<span class="n">void</span> <span class="n">rem_builtins</span><span class="p">(</span><span class="n">p_tcl_hash_list</span> <span class="n">table</span><span class="p">,</span> <span class="n">cmd_t</span> <span class="o">*</span><span class="n">cc</span><span class="p">);</span>
</pre></div>
</div>
<p>This adds binds to one of Eggdrop’s bind tables. The format of the
table is:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span><span class="n">char</span> <span class="o">*</span><span class="n">command</span><span class="p">,</span> <span class="n">char</span> <span class="o">*</span><span class="n">flags</span><span class="p">,</span> <span class="n">Function</span> <span class="o">*</span><span class="n">function</span><span class="p">,</span> <span class="n">char</span> <span class="o">*</span><span class="n">displayname</span><span class="p">}</span>
</pre></div>
</div>
<p>Use {NULL, NULL, NULL, NULL} to indicate the end of the list.</p>
<p>This works EXACTLY like the Tcl ‘bind’ command. displayname is what Tcl
sees this function’s proc name as (in .binds all).</p>
<p>function is called with exactly the same args as a Tcl binding is with
type conversion taken into account (e.g. idx’s are ints). Return values
are much the same as Tcl bindings. Use int 0/1 for those which require
0/1, or char * for those which require a string (auch as filt). Return
nothing if no return value is required.</p>
</section>
<section id="putlog">
<h4>putlog<a class="headerlink" href="#putlog" title="Link to this heading">¶</a></h4>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">void</span> <span class="n">putlog</span> <span class="p">(</span><span class="nb">int</span> <span class="n">logmode</span><span class="p">,</span> <span class="n">char</span> <span class="o">*</span><span class="n">channel</span><span class="p">,</span> <span class="n">char</span> <span class="o">*</span><span class="nb">format</span><span class="p">,</span> <span class="o">...</span><span class="p">)</span>
</pre></div>
</div>
<p>Adds text to a logfile (determined by logmode and channel). This text
will also output to any users’ consoles if they have the specified
console mode enabled.</p>
</section>
</section>
</section>
<section id="what-to-do-with-a-module">
<h2>What to do with a module?<a class="headerlink" href="#what-to-do-with-a-module" title="Link to this heading">¶</a></h2>
<p>If you have written a module and feel that you wish to share it with the
rest of the Eggdrop community, find us in #eggdrop on Libera. Make sure you
have a nice descriptive text (modulename.desc) to describe it, and make sure
to mention in your text file which version Eggdrop the module is written for.</p>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
        </div>
        <div class="clearer"></div>
      </div>
    </div>

    <div class="footer-wrapper">
      <div class="footer">
        <div class="left">
          <div role="navigation" aria-label="related navigaton">
            <a href="mod/uptime.html" title="Uptime Module"
              >previous</a> |
            <a href="internals.html" title="Eggdrop Bind Internals"
              >next</a>
          </div>
          <div role="note" aria-label="source link">
          </div>
        </div>

        <div class="right">
          
    <div class="footer" role="contentinfo">
    &#169; Copyright 2025, Eggheads.
      Last updated on Aug 15, 2025.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.
    </div>
        </div>
        <div class="clearer"></div>
      </div>
    </div>

  </body>
</html>