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 *.pyc
conf conf
*.cfg *.cfg
......
...@@ -123,6 +123,7 @@ optional arguments: ...@@ -123,6 +123,7 @@ optional arguments:
self.set(currentNetwork,'owner_nick',"Your username (use the auth plugin to set a password)") 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_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,'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,'port',"Port", "6667")
self.set(currentNetwork,'use_ssl','Use ssl (yes/no)', 'no') self.set(currentNetwork,'use_ssl','Use ssl (yes/no)', 'no')
self.set(currentNetwork,"comchar","My command char", "-") self.set(currentNetwork,"comchar","My command char", "-")
......
...@@ -145,6 +145,9 @@ class PluginManager(object): ...@@ -145,6 +145,9 @@ class PluginManager(object):
self.unloadPlugin(plugin.lower()) self.unloadPlugin(plugin.lower())
class IRC(asynchat.async_chat): class IRC(asynchat.async_chat):
def handle_error(self):
'''Print a traceback when an error happens'''
traceback.print_exc()
def __init__(self, config): def __init__(self, config):
asynchat.async_chat.__init__(self) asynchat.async_chat.__init__(self)
self.pluginManager = PluginManager(self) self.pluginManager = PluginManager(self)
...@@ -157,8 +160,8 @@ class IRC(asynchat.async_chat): ...@@ -157,8 +160,8 @@ class IRC(asynchat.async_chat):
errs = self.pluginManager.loadAllPlugins() errs = self.pluginManager.loadAllPlugins()
self.userlist = { } self.userlist = { }
self.data = "" self.data = b""
self.set_terminator("\r\n") self.set_terminator(b"\r\n")
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if self.config["use_ssl"].lower().startswith("y"): if self.config["use_ssl"].lower().startswith("y"):
...@@ -182,13 +185,11 @@ class IRC(asynchat.async_chat): ...@@ -182,13 +185,11 @@ class IRC(asynchat.async_chat):
def _getData(self): def _getData(self):
ret = self.data ret = self.data
self.data = '' self.data = b""
return ret return ret
def found_terminator(self): def found_terminator(self):
data = self._getData() data = self._getData().decode("utf-8")
print("HI")
print(str(words))
words = data.split(" ") words = data.split(" ")
if words[0] == "PING": if words[0] == "PING":
# The server pinged us, we need to pong or we'll be disconnected # The server pinged us, we need to pong or we'll be disconnected
...@@ -223,7 +224,7 @@ class IRC(asynchat.async_chat): ...@@ -223,7 +224,7 @@ class IRC(asynchat.async_chat):
elif words[1] == "353": elif words[1] == "353":
#user list, if it's large, we only got part of it. #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: if self.userlist.get(words[3], None) is None:
self.userlist[words[3]] = [] self.userlist[words[3]] = []
...@@ -310,6 +311,7 @@ class IRC(asynchat.async_chat): ...@@ -310,6 +311,7 @@ class IRC(asynchat.async_chat):
def handle_connect(self): def handle_connect(self):
self.config["ident"] = ident = self.config["ident"] if self.config["ident"] != "" else self.config["nickname"] self.config["ident"] = ident = self.config["ident"] if self.config["ident"] != "" else self.config["nickname"]
self.sendLine("USER "+ident+" * * *") self.sendLine("USER "+ident+" * * *")
if self.config["srpass"] != "": self.sendLine("PASS "+self.config["srpass"])
self.sendLine("NICK "+self.config["nickname"]) self.sendLine("NICK "+self.config["nickname"])
def handle_disconnect(self): def handle_disconnect(self):
...@@ -321,9 +323,9 @@ class IRC(asynchat.async_chat): ...@@ -321,9 +323,9 @@ class IRC(asynchat.async_chat):
def sendLine(self, line): def sendLine(self, line):
print("'"+line+"'") print("'"+line+"'")
if line.endswith("\r\n"): if line.endswith("\r\n"):
self.push(line) self.push(bytes(line, "utf_8"))
else: else:
self.push(line+"\r\n") self.push(bytes(line + "\r\n", "utf_8"))
def doMessage(self, channel, message): def doMessage(self, channel, message):
self.sendLine("PRIVMSG "+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