#NEWLINE# def doJoin( self , irc , msg ) : #NEWLINE# #INDENT# channel = msg . args [ 0 ] #NEWLINE# if ircutils . strEqual ( irc . nick , msg . nick ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( not self . registryValue ( 'enable' , channel ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# fallthrough = self . registryValue ( 'fallthrough' , channel ) #NEWLINE# def do( type ) : #NEWLINE# #INDENT# cap = ircdb . makeChannelCapability ( channel , type ) #NEWLINE# cap_auto = ircdb . makeChannelCapability ( channel , ( 'auto' + type ) ) #NEWLINE# try : #NEWLINE# #INDENT# apply_mode = ircdb . checkCapability ( msg . prefix , cap , ignoreOwner = ( not self . registryValue ( 'owner' ) ) , ignoreChannelOp = True , ignoreDefaultAllow = True ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# apply_mode = False #NEWLINE# #UNINDENT# if self . registryValue ( 'alternativeCapabilities' , channel ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# override = ircdb . checkCapability ( msg . prefix , cap_auto , ignoreOwner = ( not self . registryValue ( 'owner' ) ) , ignoreChannelOp = True , ignoreDefaultAllow = True ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# override = False #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# override = False #NEWLINE# #UNINDENT# if ( apply_mode or override ) : #NEWLINE# #INDENT# if ( override or self . registryValue ( type , channel ) ) : #NEWLINE# #INDENT# self . log . info ( 'Scheduling auto-%s of %s in %s.' , type , msg . prefix , channel ) #NEWLINE# def dismiss( ) : #NEWLINE# #INDENT# 'Determines whether or not a mode has already\n                        been applied.' #NEWLINE# l = getattr ( irc . state . channels [ channel ] , ( type + 's' ) ) #NEWLINE# return ( msg . nick in l ) #NEWLINE# #UNINDENT# msgmaker = getattr ( ircmsgs , type ) #NEWLINE# schedule_msg ( msgmaker ( channel , msg . nick ) , dismiss ) #NEWLINE# raise Continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not fallthrough ) : #NEWLINE# #INDENT# self . log . debug ( '%s has %s, but supybot.plugins.AutoMode.%s is not enabled in %s, refusing to fall through.' , msg . prefix , cap , type , channel ) #NEWLINE# raise Continue #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# def schedule_msg( msg , dismiss ) : #NEWLINE# #INDENT# def f( ) : #NEWLINE# #INDENT# if ( not dismiss ( ) ) : #NEWLINE# #INDENT# irc . queueMsg ( msg ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . log . info ( 'Dismissing auto-mode for %s.' , msg . args [ 2 ] ) #NEWLINE# #UNINDENT# #UNINDENT# delay = self . registryValue ( 'delay' , channel ) #NEWLINE# if delay : #NEWLINE# #INDENT# schedule . addEvent ( f , ( time . time ( ) + delay ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# f ( ) #NEWLINE# #UNINDENT# #UNINDENT# def extra_modes( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# user = ircdb . users . getUser ( ircdb . users . getUserId ( msg . prefix ) ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# pattern = re . compile ( '-|\\+' ) #NEWLINE# for item in self . registryValue ( 'extra' , channel ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ( username , modes ) = pattern . split ( item , maxsplit = 1 ) #NEWLINE# modes = ( item [ len ( username ) ] + modes ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# log . error ( ( '%r is not a valid item for supybot.plugins.AutoMode.extra' % item ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# if ( username != user . name ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . log . info ( 'Scheduling auto-modes %s of %s in %s.' , modes , msg . prefix , channel ) #NEWLINE# modes = ( [ modes ] + ( [ msg . nick ] * len ( pattern . sub ( '' , modes ) ) ) ) #NEWLINE# schedule_msg ( ircmsgs . mode ( channel , modes ) , ( lambda : False ) ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# do ( 'op' ) #NEWLINE# if ( 'h' in irc . state . supported [ 'prefix' ] ) : #NEWLINE# #INDENT# do ( 'halfop' ) #NEWLINE# #UNINDENT# #UNINDENT# except Continue : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# extra_modes ( ) #NEWLINE# #UNINDENT# c = ircdb . channels . getChannel ( channel ) #NEWLINE# if ( c . checkBan ( msg . prefix ) and self . registryValue ( 'ban' , channel ) ) : #NEWLINE# #INDENT# period = self . registryValue ( 'ban.period' , channel ) #NEWLINE# if period : #NEWLINE# #INDENT# def unban( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( msg . prefix in irc . state . channels [ channel ] . bans ) : #NEWLINE# #INDENT# irc . queueMsg ( ircmsgs . unban ( channel , msg . prefix ) ) #NEWLINE# #UNINDENT# #UNINDENT# except KeyError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# schedule . addEvent ( unban , ( time . time ( ) + period ) ) #NEWLINE# #UNINDENT# banmask = conf . supybot . protocols . irc . banmask . makeBanmask ( msg . prefix ) #NEWLINE# irc . queueMsg ( ircmsgs . ban ( channel , banmask ) ) #NEWLINE# irc . queueMsg ( ircmsgs . kick ( channel , msg . nick ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# do ( 'voice' ) #NEWLINE# #UNINDENT# except Continue : #NEWLINE# #INDENT# return