X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=plomlombot.py;h=0e02f1c6dd426b60a380e8cb14dd02b43e992424;hb=920a2af71ebc064d5c0ae8b1700814a63ab4f6c1;hp=dc9a46d46b9b3be508ca70862982469fc16cee5a;hpb=8bbb7d5aff28115d74360e72898ae3fba72c9ece;p=plomlombot-irc.git
diff --git a/plomlombot.py b/plomlombot.py
index dc9a46d..0e02f1c 100755
--- a/plomlombot.py
+++ b/plomlombot.py
@@ -471,8 +471,9 @@ def handle_url(url, notice, show_url=False):
class Session:
- def __init__(self, io, username, nickname, channel, twtfile, dbdir, rmlogs,
+ def __init__(self, io, username, nickname, sasl, channel, twtfile, dbdir, rmlogs,
markov_input, no_show_page_titles):
+ import base64
self.io = io
self.nickname = nickname
self.users_in_chan = []
@@ -483,8 +484,16 @@ class Session:
self.markovfile = chandir + "markovfeed"
self.quotesfile = chandir + "quotes"
self.log = Log(chandir, self.nickname, username, channel, rmlogs)
+ if sasl:
+ self.io.send_line("CAP REQ :sasl")
self.io.send_line("NICK " + self.nickname)
self.io.send_line("USER " + username + " 0 * : ")
+ if sasl:
+ self.io.send_line("AUTHENTICATE PLAIN")
+ auth = username + '\0' + username + '\0' + sasl
+ auth_encoded = base64.b64encode(auth.encode()).decode().rstrip()
+ self.io.send_line("AUTHENTICATE " + auth_encoded)
+ self.io.send_line("CAP END")
self.io.send_line("JOIN " + channel)
self.io.log = self.log
self.log.separator_line()
@@ -567,6 +576,8 @@ def parse_command_line_arguments():
parser.add_argument("-n, --nickname", action="store", dest="nickname",
default=NICKNAME, help="nickname to use (default: "
+ NICKNAME + ")")
+ parser.add_argument("-a, --authenticate", action="store", dest="sasl",
+ default=None, help="SASL password (default: none)")
parser.add_argument("-t, --twtxtfile", action="store", dest="twtfile",
default=TWTFILE, help="twtxt file to use (default: "
+ TWTFILE + ")")
@@ -592,7 +603,7 @@ while True:
io = IO(opts.server, opts.port, opts.timeout)
hash_server = hashlib.md5(opts.server.encode("utf-8")).hexdigest()
dbdir = opts.dbdir + "/" + hash_server
- session = Session(io, opts.username, opts.nickname, opts.channel,
+ session = Session(io, opts.username, opts.nickname, opts.sasl, opts.channel,
opts.twtfile, dbdir, opts.rmlogs, opts.markov_store,
opts.no_show_page_titles)
session.loop()