def dcc_start_chat(self, nick): """ start a dcc chat with 'nick' - i.e. open local socket, send appropriate ctcp message, update model """ s = dccSession(dccSession.DCCSESSION_CHAT, nick) factory = dccFactory(self, s, dcc_chat) conn = Port(0, factory, backlog=1) conn.startListening() (prot, dcchost, dccport) = conn.getHost() # # don't trust the host reported by dcc_chat - it's unconnected, # so it's not clear on which interface the connection will be serverhost = self.irc.getHost()[1] self.ctcp(nick, "DCC", "CHAT chat %lu %u" % \ (net.inet_aton(serverhost), dccport)) self.dccsessions.append(s) # move to factory? if self.queries.has_key(nick): target = self.queries[nick] else: target = self.viewtext target.announce("Starting dcc chat with %s" % nick)
def dcc_send_file(self, nick, file): s = dccSend(nick, file) factory = dccFactory(self, s, dcc_fileoffer) conn = Port(0, factory, backlog=1) conn.startListening() (prot, dcchost, dccport) = conn.getHost() # # don't trust the host reported by dcc_chat - it's unconnected, # so it's not clear on which interface the connection will be serverhost = self.getHost()[1] self.ctcp(nick, "DCC", "SEND %s %lu %u" % \ (file, net.inet_aton(serverhost), dccport)) self.dccsessions.append(s) self.viewtext.announce("Waiting for %s to accept %s" % (nick, file))