diff --git a/modules/usrinfo.py b/modules/usrinfo.py index ff9d25a..74cd450 100644 --- a/modules/usrinfo.py +++ b/modules/usrinfo.py @@ -16,9 +16,35 @@ async def on_all(self,wtime=100): self.userdb.insert_ignore(dict(user),['id']) print('done') +async def findalt(self,c,n,m): + m = m.strip() + user = self.userdb.find_one(nickname={'like':m},order_by='-id') + if user == None: + await self.message(c,'[\x036usrinfo\x0f] I could not find that user :(') + # check if identd + if user['username'][0] == '~': + # not identd + alts = [i['nickname'] for i in self.userdb.find(hostname=user['hostname'])] + else: + alts = [i['nickname'] for i in self.userdb.find(username=user['username'])] + if len(alts) < 2: + await self.message(c,'[\x036usrinfo\x0f] I could not find any alts :(') + return + falt=' '.join([i[:1]+'\u200c'+i[1:] for i in sorted(list(set(alts)))]) + if len(falt) > 200: + if c in self.more: + self.more[c].append(falt[400:]) + else: + self.more[c] = [falt[400:]] + falt = falt[:400]+' (more)' + await self.message(c,'[\x036usrinfo\x0f] alts: {}'.format(falt)) + async def init(self): self.userdb = self.db['user'] if not self.userdb.find_one(sync='yes'): self.userdb.insert(dict(sync='yes')) asyncio.get_event_loop().create_task(on_all(self)) + + self.help['findalt'] = ['findalt - find out who someone\'s alts are',';p'] + self.cmd['findalt'] = findalt