(self)
| 138 | |
| 139 | @lock |
| 140 | def get_irc_command(self): |
| 141 | origin, command, args = None, None, None |
| 142 | while True: |
| 143 | line = self._get_response_line() |
| 144 | origin, command, args = self._parse_irc_msg(line) |
| 145 | |
| 146 | if command == "PING": |
| 147 | self.plugin.log_debug(_("[%s] Ping? Pong!") % args[0]) |
| 148 | self.irc_sock.send("PONG :%s\r\n" % args[0]) |
| 149 | |
| 150 | elif origin and command == "PRIVMSG": |
| 151 | sender_nick = origin.split('@')[0].split('!')[0] |
| 152 | recipient = args[0] |
| 153 | text = args[1] |
| 154 | |
| 155 | if text[0] == '\x01' and text[-1] == '\x01': #: CTCP |
| 156 | ctcp_data = text[1:-1].split(' ', 1) |
| 157 | ctcp_command = ctcp_data[0] |
| 158 | ctcp_args = ctcp_data[1] if len(ctcp_data) > 1 else "" |
| 159 | |
| 160 | if recipient[0:len(self.nick)] == self.nick: |
| 161 | if ctcp_command == "VERSION": |
| 162 | self.plugin.log_debug(_("[%s] CTCP VERSION") % sender_nick) |
| 163 | self.irc_sock.send("NOTICE %s :\x01VERSION %s\x01\r\n" % (sender_nick, "pyLoad! IRC Interface")) |
| 164 | |
| 165 | elif ctcp_command == "TIME": |
| 166 | self.plugin.log_debug(_("[%s] CTCP TIME") % sender_nick) |
| 167 | self.irc_sock.send("NOTICE %s :\x01%s\x01\r\n" % (sender_nick, time.strftime("%a %b %d %H:%M:%S %Y"))) |
| 168 | |
| 169 | elif ctcp_command == "PING": |
| 170 | self.plugin.log_debug(_("[%s] Ping? Pong!") % sender_nick) |
| 171 | self.irc_sock.send("NOTICE %s :\x01PING %s\x01\r\n" % (sender_nick, ctcp_args)) #@NOTE: PING is not a typo |
| 172 | |
| 173 | else: |
| 174 | break |
| 175 | |
| 176 | else: |
| 177 | break |
| 178 | |
| 179 | else: |
| 180 | break |
| 181 | |
| 182 | return origin, command, args |
| 183 | |
| 184 | |
| 185 | @lock |
no test coverage detected