Commit Graph

87 Commits

Author SHA1 Message Date
Blair Bonnett
2e7f0f9c12 Add plugin to send user commands.
Adds a mod_ucmd plugin which uses the previously added user command
plugin functions to send user commands when users log in. These are read
from a text file in a simple format. They can be restricted to users
with certain credentials, and can have multiple actions (e.g., send a PM
and a message in the main chat).

A sample user command file for the standard uhub commands is at
doc/ucmd.conf, and will be automatically installed if appropriate.

This currently won't send commands to existing users (e.g., if the
plugin is (re)loaded after the hub is already up and running). To
support this, a plugin function to list all current users would need to
be added.

I'm not sure how efficient this would be due to the volume of
messages needed to delete the existing commands on shutdown and send
them again on startup. As the commands are reloaded properly within the
plugin, it may be easier to require users to reconnect after the
configuration changes (and, of course, an admin could force this by
restarting the hub).
2012-08-08 19:34:19 +12:00
Blair Bonnett
66854bc204 Add UCMD extension methods to plugin API.
The user command (UCMD) extension to the ADC protocol allows for sending
hub-specific commands to clients. These commands have a name (which
generally appears in a menu in the client) and a command string which
the client sends back to the hub when the command is selected. These
command strings can contain keyword substitutions for useful
information, such as the SID of another user that was selected in the
client.

This commit adds some support for sending user commands to the uhub
plugin API. It currently restricts the command string to containing main
chat messages (BMSG commands in ADC parlance).

A plugin_ucmd structure is added to store the details of a user command,
and four methods are added to the plugin_handle.hub structure:

* plugin->hub.ucmd_create(plugin, name, length) creates a new user
  command.
* plugin->hub.ucmd_add_chat(plugin, ucmd, message, me) adds a main chat
  message to the list of commands to be run when the user command is
  selected. The me flag allows IRC /me style messages.
* plugin->hub.ucmd_send(plugin, user, ucmd) sends the command to a user.
* plugin->hub.ucmd_free(plugin, ucmd) frees the memory taken by a user
  command.

The structure has a number of flags (categories, remove, separator,
constrained) which correspond to the flags in the UCMD specification.
The categories flag must be set prior to sending to one (or more, via
a logical OR) of the ucmd_category_* enumeration values defined in
plugin_api/types.h.

The PLUGIN_API_VERSION has been increased to 2 to mark the change.
2012-08-02 02:26:54 +12:00
Tilka
05fd6bb723 minimal changes 2012-05-09 23:27:06 +02:00
Tilka
dce8b97bba fix dependency of 'install' target 2012-05-03 10:13:21 +02:00
Jan Vidar Krey
74ca5a0a33 Cleaned up command handling code, by splitting into multiple files. 2012-05-01 20:15:49 +02:00
Jan Vidar Krey
55030935a7 Merge https://github.com/Tilka/uhub 2012-04-19 23:17:39 +02:00
Tilka
0cbb382b14 also clean uhub-passwd 2012-04-19 02:54:56 +02:00
Jan Vidar Krey
1dba731cc3 Fix bug #158 - Added plugin for setting topic (hub description).
Load plugin mod_topic, and it will provide 3 new user commands:

!topic - set new topic
!cleartopic - reset the topic (use default hub description)
!showtopic - show the current topic
2012-04-19 00:33:38 +02:00
Jan Vidar Krey
df7bbc094f Command arguments handling + cleanups
Fix bug #185 - Args of !commands lost/damaged.
All string arguments were incorrectly freed after being added to the argument list for a command.
Instead this fix makes sure it is properly copied into a new string, and by doing so this requires
a new API for dealing with hub command arguments in a type safe manner, and also allows for each
argument to be cleaned up properly when the command is no longer needed.

This also fixes issues with parse errors for certain types, and optional arguments (previously it was impossible
to tell the difference for an integer with value 0 or if no integer was given).

All arguments can now be accessed through the new functions
hub_command_arg_reset() and hub_command_arg_next().

These functions are also exposed to plug-ins.

The argument type notations for 'n' has changed to mean nick (string),
and 'u' is used for a user (struct hub_user - must be online).
2012-04-18 23:03:05 +02:00
Jan Vidar Krey
eee2636582 Added a chat only hub plugin that disables searching and connection setup.
This also deprecates the built-in chat_only configuration option.
If you need this functionality, then load the mod_chat_only plugin (if it is loaded then only operators
are able to search, connect, etc).
2012-01-09 20:58:19 +01:00
Jan Vidar Krey
fcf6827a68 Also build the chat history plugin. 2012-01-03 22:41:56 +00:00
Jan Vidar Krey
ecedd44fee Added %c substitution to mod_welcome to print the current user credentials. 2011-12-22 00:14:34 +00:00
Jan Vidar Krey
24e2c2090e Fix welcome plugin handle, and build issues. 2011-12-21 23:50:23 +00:00
Jan Vidar Krey
88dd1341d2 Started working on mod_welcome which will replace the built-in file_motd and file_rules configuration options. 2011-12-21 14:31:29 +01:00
Jan Vidar Krey
b24d4b85cd Split out the command buffer code to a generic buffer. 2011-12-21 13:53:53 +01:00
Jan Vidar Krey
ec3afc3a44 Added a simple tool to create and manipulate the uhub sqlite authentication database. 2011-12-20 16:20:54 +01:00
Jan Vidar Krey
f2cb84180a Refactored command parsing.
Allows for automatically tested command parsing by splitting parsing
and invokation of the commands.
2011-12-19 00:34:45 +01:00
Jan Vidar Krey
8d607dff13 fixup! Fix bug #167 - Build errors on OpenBSD. 2011-12-09 13:44:36 +01:00
Jan Vidar Krey
318163c066 Added support for dynamic commands.
Dynamic commands are user commands that can be added dynamically to
the hub by a plugin.

The example plugin (mod_example.c) adds a !example command that when
invoked send a message to the user who invoked it.
2011-12-09 10:29:50 +01:00
Jan Vidar Krey
78ed83840b fixup! Fix bug #167 - Build errors on OpenBSD. 2011-12-02 13:56:41 +01:00
Jan Vidar Krey
2396d8555c Fix bug #167 - Build errors on OpenBSD.
- Don't link with -ldl, as it is not needed in most cases
- Don't compile plugins if USE_PLUGINS=NO
- Fix warning about missing newline at end of getopt.h
- Removed the O_NOATIME open() flag from the logging plugin.
- Removed the O_LARGEFILE open() flag. _FILE_OFFSET_BITS is 64.
- Use fsync() if fdatasync() is not available for log file writing.
- Replaced some sprintf() with snprintf() due to compiler warnings (though, they were length limited otherwise).
- Replaced two occurences of strcpy() with memcpy().
2011-11-30 13:43:39 +01:00
Jan Vidar Krey
0d8283930f Compile fix for Fedora/RedHat. Add -lcrypto to LDFLAGS. 2011-09-07 10:20:58 +02:00
Jan Vidar Krey
e4aa565fab Build plugins by default. 2011-08-16 15:10:33 +02:00
Jan Vidar Krey
169b8a4a75 Added option to redirect from adc:// to adcs:// if tls is required. 2011-08-16 12:11:04 +02:00
Jan Vidar Krey
4a03accc34 Fix compile warning about PLUGIN_SUPPORT being redefined. 2011-02-05 17:16:14 +01:00
E_zombie
d4accea32c - update GNUmakefile 2010-11-23 16:07:39 +03:00
E_zombie
50e44f5272 - update GNUmakefile for install plugin modules 2010-11-23 15:54:57 +03:00
Jan Vidar Krey
1af7e26c52 Moved flood control stuff to the util package. 2010-08-11 22:46:06 +02:00
Jan Vidar Krey
c2b7ecd49c Made sure the logging plugin logs on a format that looks almost the same as we used to have in the past. 2010-08-04 17:03:37 +02:00
Jan Vidar Krey
dbf790bb93 Added autotests for credentials handling. 2010-07-29 11:22:04 +02:00
Jan Vidar Krey
55ffe46a38 Added an SQLite authentication backend. 2010-07-29 08:49:24 +02:00
Jan Vidar Krey
56e5557146 Cleaned up the credentials handling, and made it ready for plugins. 2010-07-12 19:05:50 +02:00
Jan Vidar Krey
4b22ccb73c Added a proper config file tokenizer that supports escaping sequences
and comments.

This allows for:

'"foo bar"' can be represented as 'foo\ bar'.

And allows for comments using the hash symbol (#), but not inside
escapes or quotes. "#this is not a comment", \#this\ is\ not\ a comment.

All configuration file parsers should be rewritten using this functionality.
2010-07-09 14:01:03 +02:00
Jan Vidar Krey
849a791f79 Fixed plugin handling when using the utils code from within a plugin. 2010-07-08 14:26:07 +02:00
Jan Vidar Krey
aa26052479 Misc plugin work
* Fix crash when unloading plugins.
* Fixed plugin loader and plugin unload handler.
* Added a new example plugin: mod_logging which logs users logging in and out of the hub to stdout.
2010-06-29 15:40:19 +02:00
Jan Vidar Krey
07d4e4470c More work on the plugin API. 2010-06-06 16:19:59 +02:00
Jan Vidar Krey
ed53034ad5 Added plugin loader code, merely a wrapper around dlopen() and friends. 2010-05-30 23:33:06 +02:00
Jan Vidar Krey
8815118fde Added flood control support.
This closes bug #79: Flood control, and rate limits
2010-04-05 16:01:07 +02:00
Jan Vidar Krey
198d86a1ee Added some automatic tests for the timeout handling. 2010-02-25 17:57:50 +01:00
Jan Vidar Krey
2ded9f3e09 Make the revision file if it does not exist. 2010-02-25 16:38:05 +01:00
Jan Vidar Krey
59ed268f4d Added test cases for sid allocation.
This revealed a few bugs:
* when sid allocator is full, then uhub will loop indefinitely when allocating one more (unlikely to occur).
* looking up a user object based on a sid that is out of range (off by one) returns invalid memory.
2010-02-18 16:02:13 +01:00
Jan Vidar Krey
1a98bb6810 Added optional include of local makefile. 2010-02-15 18:56:23 +01:00
Jan Vidar Krey
685597c795 Make sure we delete the revision.h files when updating.
Also, only use annotated tags for git revision numbers.
2010-02-11 09:16:30 +01:00
Jan Vidar Krey
782f091637 Bump to 0.3.1-rc1 2010-02-11 09:03:07 +01:00
Jan Vidar Krey
bf1b64db53 Write git revision to a header file, then make version.h depend on that file. 2010-02-11 01:03:09 +01:00
Jan Vidar Krey
7637d9ba68 Added experimental Haiku OS support.
It compiles and it runs with some minor glitches.
2010-01-28 01:35:08 +01:00
Jan Vidar Krey
d7a1a52c1a Started working kqueue() backend for OSX and BSD. 2010-01-26 23:30:32 +01:00
Jan Vidar Krey
f54e8dbbba Moved the timeout code to where it belongs, along with the network backend code. 2010-01-26 22:55:08 +01:00
Jan Vidar Krey
92c448b855 Dont use SSL by default. 2010-01-23 01:09:00 +01:00
Jan Vidar Krey
c670d13369 Make sure we shutdown SSL connections when an error occurs. 2010-01-23 00:20:48 +01:00