Skip to content
Snippets Groups Projects
Commit fea5c7e2 authored by Svetlana Tkachenko's avatar Svetlana Tkachenko
Browse files

Workaround http://bugs.python.org/issue12523 ; add srpass for better auth

parent 58f5ad7a
No related branches found
No related tags found
No related merge requests found
__pycache__
*/__pycache__
*.pyc
conf
*.cfg
......
......@@ -123,6 +123,7 @@ optional arguments:
self.set(currentNetwork,'owner_nick',"Your username (use the auth plugin to set a password)")
self.set(currentNetwork,'ns_name',"NickServ username (if there is none, press ENTER)")
self.set(currentNetwork,'ns_pwd',"NickServ password (if there is none, press ENTER)")
self.set(currentNetwork,'srpass',"Server password (used on private servers or for Services auth)")
self.set(currentNetwork,'port',"Port", "6667")
self.set(currentNetwork,'use_ssl','Use ssl (yes/no)', 'no')
self.set(currentNetwork,"comchar","My command char", "-")
......
......@@ -145,6 +145,9 @@ class PluginManager(object):
self.unloadPlugin(plugin.lower())
class IRC(asynchat.async_chat):
def handle_error(self):
'''Print a traceback when an error happens'''
traceback.print_exc()
def __init__(self, config):
asynchat.async_chat.__init__(self)
self.pluginManager = PluginManager(self)
......@@ -157,8 +160,8 @@ class IRC(asynchat.async_chat):
errs = self.pluginManager.loadAllPlugins()
self.userlist = { }
self.data = ""
self.set_terminator("\r\n")
self.data = b""
self.set_terminator(b"\r\n")
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if self.config["use_ssl"].lower().startswith("y"):
......@@ -182,13 +185,11 @@ class IRC(asynchat.async_chat):
def _getData(self):
ret = self.data
self.data = ''
self.data = b""
return ret
def found_terminator(self):
data = self._getData()
print("HI")
print(str(words))
data = self._getData().decode("utf-8")
words = data.split(" ")
if words[0] == "PING":
# The server pinged us, we need to pong or we'll be disconnected
......@@ -223,7 +224,7 @@ class IRC(asynchat.async_chat):
elif words[1] == "353":
#user list, if it's large, we only got part of it.
words = [k for k in data.replace(" =", "").split(" ") if k != '']
words = [k for k in str(data).replace(" =", "").split(" ") if k != '']
if self.userlist.get(words[3], None) is None:
self.userlist[words[3]] = []
......@@ -310,6 +311,7 @@ class IRC(asynchat.async_chat):
def handle_connect(self):
self.config["ident"] = ident = self.config["ident"] if self.config["ident"] != "" else self.config["nickname"]
self.sendLine("USER "+ident+" * * *")
if self.config["srpass"] != "": self.sendLine("PASS "+self.config["srpass"])
self.sendLine("NICK "+self.config["nickname"])
def handle_disconnect(self):
......@@ -321,9 +323,9 @@ class IRC(asynchat.async_chat):
def sendLine(self, line):
print("'"+line+"'")
if line.endswith("\r\n"):
self.push(line)
self.push(bytes(line, "utf_8"))
else:
self.push(line+"\r\n")
self.push(bytes(line + "\r\n", "utf_8"))
def doMessage(self, channel, message):
self.sendLine("PRIVMSG "+channel+" :"+message)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment