Alexandros Kosiaris has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/360325 )

Change subject: tcpircbot: Update it to work with 8.5.3 irc library
......................................................................


tcpircbot: Update it to work with 8.5.3 irc library

* Remove the connect function that would enable SSL and IPv6 via hack
* Update the calls to event source, type, arguments, target to use the non
private version of the attribute
* Use the Factory class to enable SSL and IPv6 after mangling the config a
it to enable creating that Factory class
* Stop supporting old versions like 0.4.8

Bug: T168348
Change-Id: I60691c3fcc72649613f4736ca2f1a230796f79a6
---
M modules/tcpircbot/files/tcpircbot.py
1 file changed, 15 insertions(+), 18 deletions(-)

Approvals:
  Alexandros Kosiaris: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/tcpircbot/files/tcpircbot.py 
b/modules/tcpircbot/files/tcpircbot.py
index 891ba8e..72fa5d3 100755
--- a/modules/tcpircbot/files/tcpircbot.py
+++ b/modules/tcpircbot/files/tcpircbot.py
@@ -25,7 +25,7 @@
   }
 
 Requirements:
- * irc >=0.4.8
+ * irc >=8.5.3
    <http://bitbucket.org/jaraco/irc>
    Debian package: 'python-irc'
  * netaddr >=0.7.5
@@ -47,13 +47,10 @@
 import logging
 import select
 import socket
+import ssl
+import irc
 
-try:
-    # irc 0.7+
-    import irc.bot as ircbot
-except ImportError:
-    import ircbot
-
+import irc.bot as ircbot
 
 BUFSIZE = 460  # Read from socket in IRC-message-sized chunks.
 
@@ -67,24 +64,17 @@
     """Minimal IRC bot; joins channels."""
 
     def __init__(self, network, nickname, channels, **options):
-        ircbot.SingleServerIRCBot.__init__(self, [network], nickname, nickname)
+        ircbot.SingleServerIRCBot.__init__(self, [network], nickname, 
nickname, **options)
         self.target_channels = channels
-        self.options = options
         for event in ['disconnect', 'join', 'part', 'welcome']:
             self.connection.add_global_handler(event, self.log_event)
 
-    def connect(self, *args, **kwargs):
-        """Intercepts call to ircbot.SingleServerIRCBot.connect to add support
-        for ssl and ipv6 params."""
-        kwargs.update(self.options)
-        ircbot.SingleServerIRCBot.connect(self, *args, **kwargs)
-
     def on_privnotice(self, connection, event):
-        logging.info('%s %s', event.source(), event.arguments())
+        logging.info('%s %s', event.source, event.arguments)
 
     def log_event(self, connection, event):
-        if connection.real_nickname in [event._source, event._target]:
-            logging.info('%(_eventtype)s [%(_source)s -> %(_target)s]'
+        if connection.real_nickname in [event.source, event.target]:
+            logging.info('%(type)s [%(source)s -> %(target)s]'
                          % vars(event))
 
     def on_welcome(self, connection, event):
@@ -106,6 +96,13 @@
     config = json.load(f)
 
 # Create a bot and connect to IRC
+# Mangle the config a bit for newer python-irc libraries
+ipv6 = config['irc'].pop(u'ipv6', False)
+if config['irc'].pop(u'ssl', False):
+    factory = irc.connection.Factory(ipv6=ipv6, wrapper=ssl.wrap_socket)
+else:
+    factory = irc.connection.Factory(ipv6=ipv6)
+config['irc']['connect_factory'] = factory
 bot = ForwarderBot(**config['irc'])
 bot._connect()
 

-- 
To view, visit https://gerrit.wikimedia.org/r/360325
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I60691c3fcc72649613f4736ca2f1a230796f79a6
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Alexandros Kosiaris <[email protected]>
Gerrit-Reviewer: Alexandros Kosiaris <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to