1- # -*- coding: utf-8 -*-
21#
32# This file is part of IRC Bot Behavior Bundle (IB3)
43# Copyright (C) 2017 Bryan Davis and contributors
2625import ib3 .connection
2726import ib3 .nick
2827
29-
3028logging .basicConfig (
3129 level = logging .DEBUG ,
32- format = ' %(asctime)s %(name)s %(levelname)s: %(message)s' ,
33- datefmt = ' %Y-%m-%dT%H:%M:%SZ'
30+ format = " %(asctime)s %(name)s %(levelname)s: %(message)s" ,
31+ datefmt = " %Y-%m-%dT%H:%M:%SZ" ,
3432)
3533logging .captureWarnings (True )
3634
37- logger = logging .getLogger (' saslbot' )
35+ logger = logging .getLogger (" saslbot" )
3836
3937
4038class SaslBot (ib3 .auth .SASL , ib3 .nick .Regain , ib3 .connection .SSL , ib3 .Bot ):
4139 """Example bot showing use of SASL auth, REGAIN, and SSL encryption."""
40+
4241 def on_privmsg (self , conn , event ):
4342 self .do_command (conn , event , event .arguments [0 ])
4443
4544 def on_pubmsg (self , conn , event ):
46- args = event .arguments [0 ].split (':' , 1 )
45+ args = event .arguments [0 ].split (":" , 1 )
4746 if len (args ) > 1 :
4847 to = irc .strings .lower (args [0 ])
4948 if to == irc .strings .lower (conn .get_nickname ()):
@@ -54,27 +53,28 @@ def do_command(self, conn, event, cmd):
5453 if to == conn .get_nickname ():
5554 to = event .source .nick
5655
57- if cmd == ' disconnect' :
56+ if cmd == " disconnect" :
5857 self .disconnect ()
59- elif cmd == ' die' :
58+ elif cmd == " die" :
6059 self .die ()
6160 else :
62- conn .privmsg (to , 'What does "{}" mean?' . format ( cmd ) )
61+ conn .privmsg (to , f 'What does "{ cmd } " mean?' )
6362
6463
65- if __name__ == ' __main__' :
66- parser = argparse .ArgumentParser (description = ' Example bot with SASL auth' )
67- parser .add_argument (' nick' )
68- parser .add_argument (' password' )
69- parser .add_argument (' channel' )
64+ if __name__ == " __main__" :
65+ parser = argparse .ArgumentParser (description = " Example bot with SASL auth" )
66+ parser .add_argument (" nick" )
67+ parser .add_argument (" password" )
68+ parser .add_argument (" channel" )
7069 parser .add_argument (
71- '-u' , '--username' ,
72- help = 'Account name if different than nick' ,
70+ "-u" ,
71+ "--username" ,
72+ help = "Account name if different than nick" ,
7373 )
7474 args = parser .parse_args ()
7575
7676 bot = SaslBot (
77- server_list = [(' irc.libera.chat' , 6697 )],
77+ server_list = [(" irc.libera.chat" , 6697 )],
7878 nickname = args .nick ,
7979 realname = args .nick ,
8080 username = args .username ,
@@ -84,8 +84,8 @@ def do_command(self, conn, event, cmd):
8484 try :
8585 bot .start ()
8686 except KeyboardInterrupt :
87- bot .disconnect (' KeyboardInterrupt!' )
87+ bot .disconnect (" KeyboardInterrupt!" )
8888 except Exception :
89- logger .exception (' Killed by unhandled exception' )
90- bot .disconnect (' Exception!' )
89+ logger .exception (" Killed by unhandled exception" )
90+ bot .disconnect (" Exception!" )
9191 raise SystemExit ()
0 commit comments