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

Method process_irc_command

module/plugins/hoster/XDCC.py:595–639  ·  view source on GitHub ↗
(self, origin, command, args)

Source from the content-addressed store, hash-verified

593
594
595 def process_irc_command(self, origin, command, args):
596 bot = self.info['pattern']['BOT']
597 nick = self.config.get('nick')
598
599 if origin is None\
600 or command is None\
601 or args is None:
602 return
603
604 # Private message from bot to us?
605 bot_host = self.irc_client.get_bot_host(bot)
606 if '@' not in origin \
607 or (origin[0:len(bot)] != bot and bot_host and origin.split('@')[1] != bot_host) \
608 or args[0][0:len(nick)] != nick \
609 or command not in ("PRIVMSG", "NOTICE"):
610 return
611
612 try:
613 text = unicode(args[1], 'utf-8')
614 except UnicodeDecodeError:
615 text = unicode(args[1], 'latin1', 'replace')
616
617 sender_nick = origin.split('@')[0].split('!')[0]
618 self.log_debug(_("PrivMsg: <%s> %s") % (sender_nick, text))
619
620 if text in ("You already requested that pack", "All Slots Full", "You have a DCC pending"):
621 self.request_again = True
622
623 elif "you must be on a known channel to request a pack" in text:
624 self.log_error(_("Invalid channel"))
625 self.fail(_("Invalid channel"))
626
627 elif "Invalid Pack Number" in text:
628 self.log_error(_("Invalid Pack Number"))
629 self.fail(_("Invalid Pack Number"))
630
631 m = re.match('\x01DCC SEND "?(?P<NAME>.*?)"? (?P<IP>\d+) (?P<PORT>\d+)(?: (?P<SIZE>\d+))?\x01', text) #: XDCC?
632 if m:
633 ip = socket.inet_ntoa(struct.pack('!I', int(m.group('IP'))))
634 self.dcc_port = int(m.group('PORT'))
635 self.dcc_file_name = m.group('NAME')
636 self.dcc_sender_bot = origin.split('@')[0].split('!')[0]
637 file_size = long(m.group('SIZE')) if m.group('SIZE') else 0
638
639 self.do_download(ip, self.dcc_port, self.dcc_file_name, file_size)
640
641 def _on_notification(self, notification):
642 if 'progress' in notification:

Callers 1

processMethod · 0.95

Calls 9

do_downloadMethod · 0.95
get_bot_hostMethod · 0.80
splitMethod · 0.80
log_debugMethod · 0.80
log_errorMethod · 0.80
_Function · 0.50
getMethod · 0.45
failMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected