~m4v/scratbot/main

« back to all changes in this revision

Viewing changes to src/ircutils.py

  • Committer: Elián Hanisch
  • Date: 2009-06-14 04:37:00 UTC
  • Revision ID: lambdae2@gmail.com-20090614043700-61a5mxgkal9y77r0
this allows to use banmask styles for ignores, since adding an ignore 
by nick can be quick but easy to circumvent.

new config option, Admin.ignoremask

Show diffs side-by-side

added added

removed removed

Lines of Context:
204
204
        else:
205
205
            return '*!*@'  + host
206
206
 
 
207
def makeBanmask(hostmask, options):
 
208
    """Returns a banning hostmask for hostmask with the given style.
 
209
 
 
210
    >>> makeBanmask('nick!user@host', ['user', 'host'])
 
211
    '*!user@host'
 
212
 
 
213
    >>> makeBanmask('nick!user@host', ['nick'])
 
214
    'nick!*@*'
 
215
    """
 
216
    assert isUserHostmask(hostmask)
 
217
    (nick, user, host) = splitHostmask(hostmask)
 
218
    bnick = buser = bhost = '*'
 
219
    for option in options:
 
220
        if option == 'nick':
 
221
            bnick = nick
 
222
        elif option == 'user':
 
223
            buser = user
 
224
        elif option == 'host':
 
225
            bhost = host
 
226
        elif option == 'exact':
 
227
            return hostmask
 
228
    return joinHostmask(bnick, buser, bhost)
 
229
 
207
230
_plusRequireArguments = 'ovhblkqe'
208
231
_minusRequireArguments = 'ovhbkqe'
209
232
def separateModes(args):