Commit Graph

51 Commits

Author SHA1 Message Date
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 8607b40278 Fix bug #180 - Crash after signal SIGHUP. 2012-01-19 02:58:20 +01:00
Jan Vidar Krey 5edf2b60d4 Fixed bug #179 - !broadcast command does not work properly. 2012-01-10 02:21:22 +01:00
Jan Vidar Krey ca3782c570 Merge branch 'mod_chat_history_work'
Conflicts:
	doc/plugins.conf
2012-01-03 23:22:41 +01:00
Jan Vidar Krey 875f55a401 Added a chat history plugin.
The mod_chat_history plugin provides chat history for all public chat messages.

Can be configured in the following ways:

- history_max: max number of messages stored in history
- history_default: the default number of messages to be returned when invoking !history
- history_connect: if > 0, then this number of messages is automatically sent when connecting to the hub

Removed the built-in !history command in favour of the mod_chat_history plug-in.

Make sure we unescape all chat messages before forwarding any of them to plugins.

Update example plugins.conf in documentation directory.
2012-01-03 23:22:41 +01:00
Jan Vidar Krey 7b392acbf5 Format the help list appropriately (as in older versions). 2011-12-28 10:45:02 +01:00
Jan Vidar Krey 1700a27619 Fix bug #173 - Fix the command parsing errors. 2011-12-22 01:49:21 +01:00
Jan Vidar Krey 2a190859bd Remove the configuration options 'file_motd' and 'file_rules'. Use mod_welcome instead. 2011-12-21 14:44:37 +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 f31fc65e1d VS2010 fixes. 2011-12-21 01:42:21 +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 aec89fc125 Fix memory leaks when parsing user commands. 2011-12-09 16:54:48 +01:00
Jan Vidar Krey 2352e5a0dd Fix memory leak for built-in commands. 2011-12-09 16:35:42 +01:00
Jan Vidar Krey 1dc79c641c Cleanup: do not use strcat(). 2011-12-09 15:58:58 +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 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 998f5a57e2 Fix bug #152 - disable self-registering 2011-08-16 15:09:02 +02:00
Jan Vidar Krey 9b57279628 Many Visual C++ compile warnings and errors fixed. 2011-01-03 00:03:07 +01:00
Jan Vidar Krey 4f8e3ba10b Cleaned up command parsing, added register, password, useradd, userdel, userinfo, usermod and userpass.
Mostly not implemented.
2010-11-12 18:03:39 +01: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 0810982b57 Fix bug #136 - !broadcast does not report status back to to sender. 2010-06-07 15:41:07 +02:00
Jan Vidar Krey 50fde1c5c8 Updated the broadcast command to not send the message back to the user that sent it, but
instead summarize the number of users that received it.
2010-05-26 09:38:14 +02:00
Jan Vidar Krey 62333c5f39 Update the command to send a PM originating from the operator/admin that sent it. 2010-05-25 22:21:56 +02:00
Jan Vidar Krey 58630fde08 Fixed getip to return the ip address of the target user, not self. 2010-04-05 16:35:55 +02:00
Jan Vidar Krey 5454ae279a Fix bug #120: !getip does not work 2010-04-05 14:21:40 +02:00
Jan Vidar Krey 19b9f72337 Make sure !version agrees with the connect time banner (same format). 2010-02-11 01:19:58 +01:00
Jan Vidar Krey 8e7e8c68f5 gcc v2.95 compile fixes. 2010-01-28 01:06:41 +01:00
Jan Vidar Krey b04a20c66e fixed off by one bug in due to message escape. 2010-01-21 22:20:26 +01:00
Jan Vidar Krey 7e60919596 sorted the commands shown in help. 2010-01-20 00:24:57 +01:00
Jan Vidar Krey e7cb4cd277 remove extra space before !broadcast messages 2010-01-20 00:12:39 +01:00
Jan Vidar Krey e45511827f Added the +rules command.
Also added the +motd command to see the message of the day, which is sent while connecting.
2010-01-19 23:30:26 +01:00
Jan Vidar Krey 80c6ad9d76 Added mute/unmute functionality. 2010-01-19 23:07:55 +01:00
Jan Vidar Krey 00995a1946 Fix potential memory leaks and crashes. 2009-11-18 17:41:28 +01:00
Jan Vidar Krey f50b40fb92 Fix bug #85 - Do not broadcast unknown commands, but allow for commands to be broadcasted if they are double escaped with ++ or !!. 2009-10-06 18:02:37 +02:00
Jan Vidar Krey 69f6d811bf Added lots of asserts, and split out the ip address from the connection object.
Still a lot of work remains and a massive network connection cleanup is needed.
2009-09-29 00:30:52 +02:00
Jan Vidar Krey 1af613d9ce Fixed printf issues with size_t. Since Windows do not support %zu we have to use %Iu there instead.
Solved that with an ugly but needed macro.
2009-08-20 10:44:44 +02:00
Jan Vidar Krey 86ba3ca86f Complete moving all connection related data out of the hub_user object. 2009-08-07 00:22:30 +02:00
Jan Vidar Krey 4e43746c1b Moved the ipaddr object into the connection object. 2009-08-03 18:14:34 +02:00
Jan Vidar Krey 4666311516 Add a quit reason to the log messages printed by !log. 2009-08-02 22:53:25 +02:00
Jan Vidar Krey 077bffd74f Fix capped whoip/history messages due to limit of 1024 bytes imposed wrongly on outgoing server generated messages. 2009-08-02 21:58:12 +02:00
Jan Vidar Krey b78d48795b !history had a wrong help description. 2009-08-02 19:26:21 +02:00
Jan Vidar Krey 9b58ba6516 Use correct prefix for log command. 2009-07-28 02:17:57 +02:00
Jan Vidar Krey f322fbb197 Fix !log command, split it up into multiple messages, and allow for searches. 2009-07-28 02:02:19 +02:00
Jan Vidar Krey 10615a9a1a Whitespace 2009-07-26 06:32:15 +02:00
Jan Vidar Krey 7b44036480 print ip address when using whoip. 2009-07-26 06:30:48 +02:00
Jan Vidar Krey 444f991f44 Fix bug #44 - [Request] IP log in the memory 2009-07-26 06:03:43 +02:00
Jan Vidar Krey b125ffe3c1 Fix bug #52 - [Request] Chat history command 2009-07-26 05:23:56 +02:00
Jan Vidar Krey 76b84499bc Fix bug #46: [Request] A broadcast command.
Use !broadcast <message>
2009-07-26 04:47:43 +02:00
Jan Vidar Krey 6358c7f9cd Fix bug #45: [Request] Whoip command.
Rewrote patches from Zoltan to support ip ranges and multiple results per IP.
Needed to make sure IPv6 mapped IPv4 addresses were converted to proper IPv4 addresses after accept().
2009-07-26 04:31:36 +02:00
Jan Vidar Krey 367871e476 Renamed all "struct user" to hub_user in order to resolve a naming conflict on OpenWRT.
Basically: sed -i 's/struct user/struct hub_user/g' `find -type f`
2009-07-26 01:47:17 +02:00