~ubuntu-branches/ubuntu/oneiric/irssi/oneiric

« back to all changes in this revision

Viewing changes to src/irc/flood/flood.c

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2009-05-05 15:50:50 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090505155050-aoqlnpes7che9rtd
Tags: 0.8.13-1ubuntu1
* Merge from debian unstable (LP: #372411), remaining changes:
  - debian/patches: 03firsttimer_text
    + Adapt it so it tells you about connecting to irc.ubuntu.com and
      joining #ubuntu instead of irc.debian.org and #debian.
  - debian/patches: 90irc-ubuntu-com
* Fixed debian/patches/90irc-ubuntu-com for new irssi.conf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
186
186
        MODULE_SERVER_REC *mserver;
187
187
        FLOOD_REC *flood;
188
188
        FLOOD_ITEM_REC *rec;
189
 
        time_t *ttime;
 
189
        time_t now, *ttime;
 
190
        GSList *times, *tnext;
190
191
 
191
192
        g_return_if_fail(server != NULL);
192
193
        g_return_if_fail(nick != NULL);
196
197
 
197
198
        rec = flood == NULL ? NULL : flood_find(flood, level, target);
198
199
        if (rec != NULL) {
 
200
                now = time(NULL);
 
201
                for (times = rec->msgtimes; times != NULL; times = tnext) {
 
202
                        time_t *data = times->data;
 
203
                        tnext = times->next;
 
204
 
 
205
                        if (now - *data >= flood_timecheck) {
 
206
                                rec->msgtimes = g_slist_remove(rec->msgtimes, data);
 
207
                                g_free(data);
 
208
                        } else
 
209
                                break;
 
210
                }
199
211
                ttime = g_new(time_t, 1);
200
 
                *ttime = time(NULL);
 
212
                *ttime = now;
201
213
                rec->msgtimes = g_slist_append(rec->msgtimes, ttime);
202
214
                if (g_slist_length(rec->msgtimes) > flood_max_msgs) {
203
215
                        /* flooding! */
274
286
        if (addr == NULL || g_strcasecmp(nick, server->nick) == 0)
275
287
                return;
276
288
 
277
 
        level = g_strncasecmp(data, "ACTION ", 7) != 0 ? MSGLEVEL_CTCPS :
 
289
        level = g_ascii_strncasecmp(data, "ACTION ", 7) != 0 ? MSGLEVEL_CTCPS :
278
290
                (ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);
279
291
        if (!ignore_check(SERVER(server), nick, addr, target, data, level))
280
292
                flood_newmsg(server, level, nick, addr, target);
287
299
 
288
300
        if (flood_timecheck > 0 && flood_max_msgs > 0) {
289
301
                if (flood_tag == -1) {
290
 
                        flood_tag = g_timeout_add(500, (GSourceFunc) flood_timeout, NULL);
 
302
                        flood_tag = g_timeout_add(5000, (GSourceFunc) flood_timeout, NULL);
291
303
 
292
304
                        signal_add("event privmsg", (SIGNAL_FUNC) flood_privmsg);
293
305
                        signal_add("event notice", (SIGNAL_FUNC) flood_notice);