Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #7 from wraithan/feature/fix_channel_striping

retain leading # on channels due to some channels having multiple #
  • Loading branch information...
commit 67d1414fc1a895d7662aaea250a2bd746e8b4107 2 parents acd8961 + 4d4228a
Charles Leifer authored July 01, 2012

Showing 1 changed file with 15 additions and 11 deletions. Show diff stats Hide diff stats

  1. 26  irc.py
26  irc.py
@@ -22,10 +22,10 @@ class IRCConnection(object):
22 22
     nick_re = re.compile('.*?Nickname is already in use')
23 23
     nick_change_re = re.compile(':(?P<old_nick>.*?)!\S+\s+?NICK\s+:\s*(?P<new_nick>[-\w]+)')
24 24
     ping_re = re.compile('^PING (?P<payload>.*)')
25  
-    chanmsg_re = re.compile(':(?P<nick>.*?)!\S+\s+?PRIVMSG\s+#(?P<channel>[-\w]+)\s+:(?P<message>[^\n\r]+)')
  25
+    chanmsg_re = re.compile(':(?P<nick>.*?)!\S+\s+?PRIVMSG\s+(?P<channel>#+[-\w]+)\s+:(?P<message>[^\n\r]+)')
26 26
     privmsg_re = re.compile(':(?P<nick>.*?)!~\S+\s+?PRIVMSG\s+[^#][^:]+:(?P<message>[^\n\r]+)')
27  
-    part_re = re.compile(':(?P<nick>.*?)!\S+\s+?PART\s+#(?P<channel>[-\w]+)')
28  
-    join_re = re.compile(':(?P<nick>.*?)!\S+\s+?JOIN\s+:\s*#(?P<channel>[-\w]+)')
  27
+    part_re = re.compile(':(?P<nick>.*?)!\S+\s+?PART\s+(?P<channel>#+[-\w]+)')
  28
+    join_re = re.compile(':(?P<nick>.*?)!\S+\s+?JOIN\s+:\s*(?P<channel>#+[-\w]+)')
29 29
     quit_re = re.compile(':(?P<nick>.*?)!\S+\s+?QUIT\s+.*')
30 30
     registered_re = re.compile(':(?P<server>.*?)\s+(?:376|422)')
31 31
     
@@ -105,22 +105,26 @@ def register(self):
105 105
         self.send('USER %s %s bla :%s' % (self.nick, self.server, self.nick), True)
106 106
 
107 107
     def join(self, channel):
108  
-        channel = channel.lstrip('#')
109  
-        self.send('JOIN #%s' % channel)
110  
-        self.logger.debug('joining #%s' % channel)
  108
+        if not channel.startswith('#'):
  109
+            channel = '#%s' % channel
  110
+        self.send('JOIN %s' % channel)
  111
+        self.logger.debug('joining %s' % channel)
111 112
 
112 113
     def part(self, channel):
113  
-        channel = channel.lstrip('#')
114  
-        self.send('PART #%s' % channel)
115  
-        self.logger.debug('leaving #%s' % channel)
116  
-    
  114
+        if not channel.startswith('#'):
  115
+            channel = '#%s' % channel
  116
+        self.send('PART %s' % channel)
  117
+        self.logger.debug('leaving %s' % channel)
  118
+
117 119
     def respond(self, message, channel=None, nick=None):
118 120
         """\
119 121
         Multipurpose method for sending responses to channel or via message to
120 122
         a single user
121 123
         """
122 124
         if channel:
123  
-            self.send('PRIVMSG #%s :%s' % (channel.lstrip('#'), message))
  125
+            if not channel.startswith('#'):
  126
+                channel = '#%s' % channel
  127
+            self.send('PRIVMSG %s :%s' % (channel, message))
124 128
         elif nick:
125 129
             self.send('PRIVMSG %s :%s' % (nick, message))
126 130
     

0 notes on commit 67d1414

Please sign in to comment.
Something went wrong with that request. Please try again.