summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2013-07-25 19:22:41 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-07-25 19:22:41 +0200
commitba7af08009db0abf60e19b667a99a9dd374abc51 (patch)
tree2301c0b7c421eb4d1660dbfb911cf48c040dcc2c
parent5d8b72cc7fa5d45796b2e34bcb94dfa1a86c29d6 (diff)
downloadbot-ba7af08009db0abf60e19b667a99a9dd374abc51.tar.gz
bot-ba7af08009db0abf60e19b667a99a9dd374abc51.tar.bz2
bot-ba7af08009db0abf60e19b667a99a9dd374abc51.zip
add ssl support
-rwxr-xr-x__init__.py2
-rwxr-xr-xirc.py9
-rwxr-xr-xphenny4
3 files changed, 11 insertions, 4 deletions
diff --git a/__init__.py b/__init__.py
index b33d0cf..7cc64a9 100755
--- a/__init__.py
+++ b/__init__.py
@@ -40,7 +40,7 @@ def run_phenny(config):
def connect(config):
p = bot.Phenny(config)
- p.run(config.host, config.port)
+ p.run(config.host, config.port, config.ssl)
try: Watcher(config)
except Exception, e:
diff --git a/irc.py b/irc.py
index 251ed64..d028ede 100755
--- a/irc.py
+++ b/irc.py
@@ -73,15 +73,18 @@ class Bot(asynchat.async_chat):
self.__write(args, text)
except Exception, e: pass
- def run(self, host, port=6667):
- self.initiate_connect(host, port)
+ def run(self, host, port=6667, ssl=False):
+ self.initiate_connect(host, port, ssl)
- def initiate_connect(self, host, port):
+ def initiate_connect(self, host, port, ssl):
if self.verbose:
message = 'Connecting to %s:%s...' % (host, port)
print >> sys.stderr, message,
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.connect((host, port))
+ if ssl:
+ import ssl
+ self.socket = ssl.wrap_socket(self.socket)
try: asyncore.loop()
except KeyboardInterrupt:
sys.exit()
diff --git a/phenny b/phenny
index 6a6a131..9bc0311 100755
--- a/phenny
+++ b/phenny
@@ -27,6 +27,7 @@ def create_default_config(fn):
print >> f, trim("""\
nick = 'phenny'
host = 'irc.example.net'
+ ssl = False
channels = ['#example', '#test']
owner = 'yournickname'
@@ -145,6 +146,9 @@ def main(argv=None):
if not hasattr(module, 'port'):
module.port = 6667
+ if not hasattr(module, 'ssl'):
+ module.ssl = False
+
if not hasattr(module, 'password'):
module.password = None