2.13
Fixed the account expiration problem
Fixed the empty censor pattern bug
+
+2.14
+Text output changed a bit
+Text list is now sorted
+Added ?? term support for out reason
+Added channel option to kick users for highlighting chanops
+
+
#include <stdlib.h>
#include <assert.h>
+#include <string.h>
+#include <ctype.h>
#include "../lib/sstring.h"
#include "../lib/irc_string.h"
#include "../channel/channel.h"
#include "../localuser/localuserchannel.h"
#include "../core/schedule.h"
+#include "../nick/nick.h"
+
#include "hchannel.h"
#include "haccount.h"
return "No";
}
+int hchannel_highlight_detection(hchannel *hchan, const char *message)
+{
+ char buffer[512], *buffer_ptr = buffer, *ptr = buffer;
+ int i = 0, matches = 0;
+
+ strcpy(buffer, message);
+
+ do
+ {
+ nick *tmp;
+ huser *tmp_huser;
+ huser_channel *tmp_huserchan;
+
+ if (i++ > 6)
+ break;
+
+ while (*buffer_ptr && isspace(*buffer))
+ buffer_ptr++;
+
+ if (*buffer_ptr)
+ {
+ ptr = strchr(buffer_ptr, ' ');
+ if (ptr)
+ {
+ *ptr = '\0';
+ ptr++;
+ }
+ if ((tmp = getnickbynick(buffer_ptr)))
+ if ((tmp_huser = huser_get(tmp)))
+ if ((tmp_huserchan = huser_on_channel(tmp_huser, hchan)))
+ if ((tmp_huserchan->flags & HCUMODE_OP) && strlen(huser_get_nick(tmp_huser)) > 1)
+ matches++;
+ }
+ if (ptr == NULL)
+ break;
+ else
+ buffer_ptr = ptr;
+ } while (*ptr);
+
+ if (matches > 2)
+ return 1;
+ else
+ return 0;
+}
const char *hchannel_get_sname(int flag)
{
case 19:
return "Require a ticket to join";
case 20:
- return "Send a message on ticket issue";
+ return "Send a message on ticket issue";
+ case 21:
+ return "Excessive highlight prevention";
default:
return "Error, please contact strutsi";
}
H_DISALLOW_LAME_TEXT = 1 << 17,
H_QUEUE_TIMEOUT = 1 << 18,
H_REQUIRE_TICKET = 1 << 19,
+
H_TICKET_MESSAGE = 1 << 20,
+ H_HIGHLIGHT_PREVENTION = 1 << 21,
/* the following are not real channel flags, they're used only internally */
H_UNUSED_1 = 1 << 28,
#define H_CHANFLAGS_DEFAULT (H_CHANNEL_COMMANDS)
-#define HCHANNEL_CONF_COUNT 20
+#define HCHANNEL_CONF_COUNT 21
typedef struct hchannel_struct
{
int hchannel_count(void);
+int hchannel_highlight_detection(hchannel *, const char *);
+
void hchannel_activate_join_flood(hchannel*);
/* goes to schedule */
void hchannel_deactivate_join_flood();
SKIP_WORD;
}
reason = ostr + 1;
+
+ if (!strncmp(reason, "?? ", 3))
+ { /* obtain reason from hterms */
+ hchannel *hchan = NULL;
+ if (returntype != NULL)
+ hchan = hchannel_get_by_channel(returntype);
+ hterm *new_reason = hterm_get_and_find(hchan->channel_hterms, reason + 3);
+ if (new_reason != NULL)
+ reason = new_reason->description->content;
+ }
break;
}
{
DIR *dir;
struct dirent *dent;
- char buffer[384];
- int nwritten, bufpos = 0;
+ char buffer[384], **lines, *start;
+ int nwritten, bufpos = 0, nlines = 0,i;
dir = opendir(HELPMOD_TEXT_DIR);
assert(dir != NULL);
- helpmod_reply(sender, returntype, "Following texts are available:");
-
+ /* First pass, count */
for (dent = readdir(dir);dent != NULL;dent = readdir(dir))
{
/* Skip stuff like . and .. */
if (!strncmp(dent->d_name, ".", 1))
continue;
+ nlines++;
+ }
+
+ if (nlines == 0)
+ {
+ helpmod_reply(sender, returntype, "No texts are available.");
+ return;
+ }
+ helpmod_reply(sender, returntype, "Following texts are available:");
+
+ {
+ lines = (char **)malloc(sizeof(char*) * nlines);
+ *lines = (char *)malloc(sizeof(char) * (HED_FILENAME_LENGTH+1) * nlines);
+ /* We need the start to free this array */
+ start = *lines;
+ for(i=0;i < nlines;i++)
+ lines[i] = &lines[0][(HED_FILENAME_LENGTH+1) * i];
+ }
+
+ /* Second pass, create array */
+ rewinddir(dir);
+ for (dent = readdir(dir), i = 0;dent != NULL && i < nlines;dent = readdir(dir))
+ {
+ /* Skip stuff like . and .. */
+ if (!strncmp(dent->d_name, ".", 1))
+ continue;
+ strncpy(lines[i], dent->d_name, 64);
+ i++;
+ }
+ /* Sort */
+ qsort(*lines, nlines, sizeof(char)*(HED_FILENAME_LENGTH+1), (int (*)(const void*, const void*))&strcmp);
+
+ for (i = 0;i < nlines;i++)
+ {
if (bufpos)
{
buffer[bufpos] = ' ';
bufpos++;
}
- sprintf(buffer + bufpos, "%s%n", dent->d_name, &nwritten);
+ sprintf(buffer + bufpos, "%s%n", lines[i], &nwritten);
bufpos+=nwritten;
- if (bufpos > 256)
+ if (bufpos > (384 - (HED_FILENAME_LENGTH+1)))
{
helpmod_reply(sender, returntype, buffer);
bufpos = 0;
}
}
- if (bufpos)
+
+ if (bufpos)
helpmod_reply(sender, returntype, buffer);
+
+ free(start);
+ free(lines);
+
return;
}
else if (!ci_strcmp(argv[0], "show"))
if (!fgets(buffer, 512, in))
break;
if (returntype != NULL && huser_get_level(sender) > H_PEON)
- helpmod_message_channel(hchannel_get_by_channel(returntype), "%s", buffer);
+ helpmod_message_channel(hchannel_get_by_channel(returntype), "%s: %s", argv[1], buffer);
else
- helpmod_reply(sender, returntype, "%s", buffer);
+ helpmod_reply(sender, returntype, "%s: %s", argv[1], buffer);
}
fclose (in);
return;
#define HED_BUFFER_LINES 16
#define HELPMOD_TEXT_DIR "./helpmod2/text"
+#define HED_FILENAME_LENGTH 64
/* Forward declarations */
struct hchannel_struct;
typedef struct helpmod_editor_struct
{
- char filename[64];
+ char filename[HED_FILENAME_LENGTH];
hed_line buffers[HED_BUFFER_LINES];
hed_line *start;
{
helpmod_kick(hchan, sender_huser, "Please only use normal text on %s", hchannel_get_name(hchan));
return;
- }
+ }
+ if ((hchan->flags & H_HIGHLIGHT_PREVENTION) && hchannel_highlight_detection(hchan, (char*)message))
+ {
+ helpmod_kick(hchan, sender_huser, "Please do not abuse the highlight feature of IRC clients");
+ return;
+ }
}
if (hcommand_is_command((char*)message) && (hchan->flags & H_CHANNEL_COMMANDS))
/* configuration */
/* These should always be equal */
-#define HELPMOD_VERSION_INTERNAL HELPMOD_VERSION_2_13
-#define HELPMOD_VERSION "2.13"
+#define HELPMOD_VERSION_INTERNAL HELPMOD_VERSION_2_14
+#define HELPMOD_VERSION "2.14"
#define HELPMOD_USER_TIMEOUT 1200
#define HELPMOD_VERSION_2_12 12 /* */
-#define HELPMOD_VERSION_2_13 13 /* */
+#define HELPMOD_VERSION_2_13 13 /* October 2005*/
+
+#define HELPMOD_VERSION_2_14 14 /* November 2005*/
#endif