diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2013-07-25 19:22:41 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2015-12-03 03:31:29 +0100 |
commit | 0d6455e0d1c4655d125b3291caa5612496bae43c (patch) | |
tree | b2419c07b98200315e2f838fdba22a71306adfb9 | |
parent | bf687718c9bc4bcf80e3ef436f51ff5e992ab618 (diff) | |
download | bot-0d6455e0d1c4655d125b3291caa5612496bae43c.tar.gz bot-0d6455e0d1c4655d125b3291caa5612496bae43c.tar.bz2 bot-0d6455e0d1c4655d125b3291caa5612496bae43c.zip |
add ssl support
-rwxr-xr-x | __init__.py | 2 | ||||
-rwxr-xr-x | irc.py | 9 | ||||
-rwxr-xr-x | phenny | 4 |
3 files changed, 11 insertions, 4 deletions
diff --git a/__init__.py b/__init__.py index 6c94555..f537199 100755 --- a/__init__.py +++ b/__init__.py @@ -39,7 +39,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() except Exception, e: @@ -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() @@ -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 |