mirror of
https://github.com/znc/znc.git
synced 2026-06-29 22:41:39 +02:00
Documentation
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@171 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||||
<meta name="robots" content="index,follow" />
|
||||
<meta name="language" content="en" />
|
||||
<title>ZNC - Writing Modules</title>
|
||||
</head>
|
||||
|
||||
<body bgcolor="#FFFFFF" text="#000000" alink="#993333" link="#333399" vlink="#666666">
|
||||
[<a href="index.php">Home</a>]
|
||||
-
|
||||
[<a href="http://sourceforge.net/projects/znc">Project Page</a>]
|
||||
|
||||
<hr noshade>
|
||||
<p />
|
||||
<h2>
|
||||
Overview
|
||||
</h2>
|
||||
<ul>
|
||||
<li> Create your own module.cpp file
|
||||
<li> #include <main.h> and <Modules.h>
|
||||
<li> Create a new class derived from CModule overriding any <a href="ModuleHooks.html">ModuleHooks</a> that you need
|
||||
<li> Be sure to add the macro call <em>MODULEDEFS(CYourClass)</em> at the END of the file
|
||||
<li> Compile your module into a shared object (.so file)
|
||||
<ul>
|
||||
<li> The easy way to compile is to use the znc-buildmod script as long as your module is a single .cpp file
|
||||
<ul>
|
||||
<li> <em>znc-buildmod example.cpp</em>
|
||||
</ul>
|
||||
<li> alternative is to manually compile using znc-config to ensure that you are using the same flags and libs that the znc engine was compiled with
|
||||
<ul>
|
||||
<li> <em>g++ `znc-config --cflags` `znc-config --include` `znc-config --libs` -shared -o example.so example.cpp</em>
|
||||
</ul>
|
||||
</ul>
|
||||
<li> Place the .so file into your ~/.znc/modules directory !!!WARNING!!! if you overwrite a .so file while znc has it loaded it can and probably will crash znc, <em>/msg *status unloadmod foo</em> first!
|
||||
</ul>
|
||||
<h2>
|
||||
Code
|
||||
</h2>
|
||||
<pre>
|
||||
#include <main.h>
|
||||
#include <Modules.h>
|
||||
</pre>
|
||||
<pre>
|
||||
class CExampleMod : public CModule {
|
||||
public:
|
||||
MODCONSTRUCTOR(CExampleMod) {}
|
||||
virtual ~CExampleMod() {}
|
||||
</pre>
|
||||
<pre>
|
||||
virtual void OnModCommand(const string& sCommand) {
|
||||
if (strcasecmp(sCommand.c_str(), "HELP") == 0) {
|
||||
PutModule("I'd like to help, but I am just an example");
|
||||
} else {
|
||||
PutModule("Unknown command, try HELP");
|
||||
}
|
||||
}
|
||||
};
|
||||
</pre>
|
||||
<pre>
|
||||
MODULEDEFS(CExampleMod)
|
||||
</pre>
|
||||
<h2>
|
||||
Output
|
||||
</h2>
|
||||
<pre>
|
||||
<zncuser> test
|
||||
<*example> Unknown command, try HELP
|
||||
<zncuser> help
|
||||
<*example> I'd like to help, but I am just an example
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user