MCPcopy Index your code
hub / github.com/pyload/pyload / get_irc_command

Method get_irc_command

module/plugins/hoster/XDCC.py:140–182  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers 8

connect_serverMethod · 0.95
join_channelMethod · 0.95
nickserv_identifyMethod · 0.95
send_invite_requestMethod · 0.95
is_bot_onlineMethod · 0.95
xdcc_request_resumeMethod · 0.95
xdcc_get_pack_infoMethod · 0.95
processMethod · 0.80

Calls 6

_get_response_lineMethod · 0.95
_parse_irc_msgMethod · 0.95
log_debugMethod · 0.80
splitMethod · 0.80
_Function · 0.50
sendMethod · 0.45

Tested by

no test coverage detected