def irc_NICK(self, prefix, params): # TODO: assert that this user has logged in to the main login server so that impersonation # isn't possible like it is for the real gamespy # TODO: are personas available only for newer games? # solution is to just create 1 persona by default for each login # Here is the fix for impersonation: use name found during USER command # TODO: remove this when new auth methods are plugged in #self.nick = Persona.objects.get(user=self.avatar, selected=True).name IRCUser.irc_NICK(self, prefix, params) ## sends _welcomeMessage
def connectionMade(self): IRCUser.connectionMade(self) peer = self.transport.getPeer() self.log = util.getLogger('gamespy.peerchat', self) ## some HACKS for IRCUser compat self.name = '*' ## need this since user hasn't logged in yet self.password = '' ## FIXME, TODO: remove once auth process fixed (used by irc_NICK currently to login) self.hostname = 's' ## TODO actually require a PONG response rather than ## just any traffic def disconnect(): self.log.info('PING timeout expired; closing connection.') self.transport.loseConnection() def sendPing(): self.sendLine('PING :{0}'.format(self.hostname)) self.pingService = KeepaliveService(sendPing, 90, disconnect)
def receive(self, sender, recipient, message): IRCUser.receive(self, sender, recipient, message) print("{} said {} on {}".format(sender.name, message['text'], recipient.name)) sys.stdout.flush()
def userLeft(self, group, user, reason=None): IRCUser.userLeft(self, group, user) print("{} left {}".format(user.name, group.name)) sys.stdout.flush()
def userJoined(self, group, user): IRCUser.userJoined(self, group, user) print("{} joined {}".format(user.name, group.name)) sys.stdout.flush()
def privmsg(self, sender, recip, message): # Hard to track how unicode leaks here sender, recip, message = it.imap(force_bytes, [sender, recip, message]) return IRCUser.privmsg(self, sender, recip, message)
def irc_JOIN(self, prefix, params): if not self.avatar: # deny any access to no-auth users self.sendMessage( irc.ERR_NOSUCHCHANNEL, params[0], ':No such channel (or only available for authorized users)' ) for channel in (params[0].split(',') if ',' in params[0] else [params[0]]): IRCUser.irc_JOIN(self, prefix, [channel] + params[1:])
def irc_PART(self, prefix, params): ## TODO: delete gamelobby once empty IRCUser.irc_PART(self, prefix, params)
def irc_JOIN(self, prefix, params): ## TODO: make sure everything is send just like in original peerchat impl IRCUser.irc_JOIN(self, prefix, params)