<s> """<STR_LIT>""" <EOL> import idiokit <EOL> import time as _time <EOL> from abusehelper . core import utils , cymruwhois , bot , events <EOL> OPENBL_FEED_URL = "<STR_LIT>" <EOL> def normalize_time ( time ) : <EOL> seconds = int ( time ) - <NUM_LIT:1> * <NUM_LIT> <EOL> return _time . strftime ( "<STR_LIT>" , _time . gmtime ( seconds ) ) <EOL> class OpenBLBot ( bot . PollingBot ) : <EOL> feed_url = bot . Param ( default = OPENBL_FEED_URL ) <EOL> use_cymru_whois = bot . BoolParam ( ) <EOL> def poll ( self ) : <EOL> pipe = self . _poll ( url = self . feed_url ) <EOL> if self . use_cymru_whois : <EOL> pipe = pipe | cymruwhois . augment ( "<STR_LIT>" ) <EOL> return pipe <EOL> @ idiokit . stream <EOL> def _poll ( self , url ) : <EOL> self . log . info ( "<STR_LIT>" % url ) <EOL> try : <EOL> info , fileobj = yield utils . fetch_url ( url ) <EOL> except utils . FetchUrlFailed , fuf : <EOL> raise bot . PollSkipped ( "<STR_LIT>" . format ( url , fuf ) ) <EOL> self . log . info ( "<STR_LIT>" ) <EOL> for line in fileobj : <EOL> if line . startswith ( "<STR_LIT:#>" ) : <EOL> continue <EOL> ip , time = line . split ( ) <EOL> time = normalize_time ( time ) <EOL> event = events . Event ( ) <EOL> event . add ( "<STR_LIT>" , ip ) <EOL> event . add ( "<STR_LIT>" , time ) <EOL> event . add ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> event . add ( "<STR_LIT>" , self . feed_url ) <EOL> event . add ( "<STR_LIT:type>" , "<STR_LIT>" ) <EOL> event . add ( <EOL> "<STR_LIT:description>" , <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" ) <EOL> yield idiokit . send ( event ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> OpenBLBot . from_command_line ( ) . execute ( ) </s>
