Commit 984fb3ef authored by Mindiell's avatar Mindiell

Moved to SSL connection

parent 03e19cbb
...@@ -5,7 +5,7 @@ Configuration for IRC bot Wantzel. ...@@ -5,7 +5,7 @@ Configuration for IRC bot Wantzel.
# IRC access # IRC access
server = 'irc.freenode.net' server = 'irc.freenode.net'
port = 6667 port = 6697
nickname = 'testBot' nickname = 'testBot'
password = '', password = '',
channels = [ channels = [
......
...@@ -43,10 +43,3 @@ class IrcClientFactory(protocol.ClientFactory): ...@@ -43,10 +43,3 @@ class IrcClientFactory(protocol.ClientFactory):
def clientConnectionFailed(self, connector, reason): def clientConnectionFailed(self, connector, reason):
print("Connection failed: %s" % reason) print("Connection failed: %s" % reason)
reactor.stop() reactor.stop()
if __name__ == '__main__':
factory = IrcClientFactory({'nickname':'','password':''})
reactor.connectTCP("irc.freenode.net", 6667, factory)
reactor.run()
...@@ -9,7 +9,7 @@ Doc : https://wiki.laquadrature.net/Wantzel ...@@ -9,7 +9,7 @@ Doc : https://wiki.laquadrature.net/Wantzel
import re import re
from irc import IrcClientFactory from irc import IrcClientFactory
from twisted.internet import reactor, task from twisted.internet import reactor, task, ssl
import config import config
from logs import Log from logs import Log
...@@ -36,7 +36,7 @@ class Wantzel(object): ...@@ -36,7 +36,7 @@ class Wantzel(object):
# Connection to IRC # Connection to IRC
self.irc = IrcClientFactory(config) self.irc = IrcClientFactory(config)
self.irc.set_privmsg = self.set_privmsg self.irc.set_privmsg = self.set_privmsg
reactor.connectTCP(config.server, config.port, self.irc) reactor.connectSSL(config.server, config.port, self.irc, ssl.ClientContextFactory())
self.test_timer = "" self.test_timer = ""
# Loop call # Loop call
self.loop_started = False self.loop_started = False
...@@ -75,6 +75,16 @@ class Wantzel(object): ...@@ -75,6 +75,16 @@ class Wantzel(object):
self.irc.client.irc_unknown = self.irc_unknown self.irc.client.irc_unknown = self.irc_unknown
# When bot mode is changed # When bot mode is changed
self.irc.client.modeChanged = self.mode_changed self.irc.client.modeChanged = self.mode_changed
# When bot nickname is changed
self.irc.client.nickChanged = self.nick_changed
def nick_changed(self, nick):
"""
Callback called whenever bot nickname is changed.
"""
Log.debug("Nick changed : %s" % (nick))
if nick!=config.nickname:
self.irc.client.setNick(config.nickname)
def mode_changed(self, user, channel, flag_set, modes, args): def mode_changed(self, user, channel, flag_set, modes, args):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment