def MakeDict(self, *args): """ Creates a local dictionary cache of channels """ self.dict = {} for channel in sm.StartService('LSC').GetChannels(refresh=1): self.dict[chat.GetDisplayName(channel.channelID).lower()] = channel self.dict[channel.displayName.lower()] = channel
def GetName(self, dictName = None, dictID = None, *args): if dictID is None: return if not hasattr(self, 'dict'): self.MakeDict() if type(dictID) is types.IntType: if dictName in self.dict: info = self.dict[dictName] else: tmp = [ c for c in sm.StartService('LSC').GetChannels(refresh=1) if c.channelID == dictID ] if len(tmp): info = tmp[0] else: return name = info.displayName length = len(name.split('\\')) if length > 1: name = name.split('\\')[1] else: name = chat.GetDisplayName(dictID) return name
def MakeDict(self, *args): self.dict = {} for channel in sm.StartService('LSC').GetChannels(refresh=1): self.dict[chat.GetDisplayName(channel.channelID).lower()] = channel self.dict[channel.displayName.lower()] = channel
def OnLSC(self, channelID, estimatedMemberCount, method, who, args): channelName = chat.GetDisplayName(channelID) if method != 'SendMessage' or not self.isRunning: return self.stats['numMessages'] += 1 message = args[0] sanitizedMessage = self.SanitizeMessage(message) message = unicode(message).encode('UTF-8') charID = who[2][0] charName = who[2][1] whoAllianceID, whoCorpID, who, whoRole, whoCorpRole, whoWarFactionID = who suspect = self.IsMessageSuspect(sanitizedMessage) if suspect is None: return try: self.LogInfo( 'There is something suspect from character %s: %s...' % (who, suspect)) except: pass info = self.GetCharInfo(charID) userID = info.charStatic.userID userName = info.userStatic.userName fullName = info.userStatic.fullName email = info.userStatic.eMail userType = info.userDynamic.userType ipAddress = info.ipAddress isIpMatch = False if suspect[0] == 2: if ipAddress in self.config['ipAddresses'] and 0: self.LogInfo( 'Upgrading from notify to detention because of IP relationship', ipAddress) suspect[0] = 1 isIpMatch = True if suspect[0]: if whoRole & service.ROLE_NEWBIE == 0: self.LogInfo('... %s is not a newbie.' % who[1]) return if not util.IsNPC(whoCorpID): self.LogInfo('... %s is in a player corp.' % who[1]) return if charID in self.suspects: self.LogInfo('... %s is already a suspect.' % who[1]) return message = message.decode('UTF-8', 'replace') cleanmessage = message.replace('>', '>').replace('<', '<') try: self.LogInfo('... %s is really a suspect for saying %s!' % (charName, message)) except: self.LogInfo('... %s is really a suspect for saying %s!' % (charName, 'unknown')) self.lookedUpChars[charID] = info if suspect[0] == 1: act = '<b>DETENTION</b>' self.stats['numDetention'] += 1 try: self.LogError('I will place', who[1], 'in detention for saying', message) except: self.LogError('I will place', who[1], 'in detention for saying', 'unknown') else: act = '<color=red>NOTIFY</color>' self.stats['numNotify'] += 1 try: self.LogError('I will notify user of', who[1], 'for saying', message) except: self.LogError('I will notify user of', who[1], 'for saying', 'unknown') self.suspects.add(charID) act2 = '' try: if suspect[0] == 1: self.PlaceInDetention(charID) except Exception as e: raise ip = ipAddress if isIpMatch: ip = '<color=red>%s</color>' % ip matchstring = suspect[1] label = '%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s<t>%s' % ( act, util.FmtDate(blue.os.GetTime(), 'ss'), channelName, charName, userName, ip, matchstring, cleanmessage[:64]) kv = {} data = util.KeyVal(charID=charID, userID=userID, label=label, GetMenu=self.GetSpammerMenu, hint=cleanmessage, data=info) l = listentry.Get('Generic', data=data) self.scrolllist.append(l) self.scroll.AddEntries(0, [l]) self.WriteLog(label)