def cmd_whereis(self, command, data): splitcmd = [a.strip() for a in command.split(':')] who = splitcmd[1] reply = [] try: loc_data = shelve.open(self.loc_file) if who not in loc_data: replystr = "No idea!" elif loc_data[who][-1]['where'].lower() in NOLOC: replystr = "Who knows?" else: replyfmtstr = "%(who)s %(atstr)s %(where)s (%(whenstr)s)" replydict = {} replydict['who'] = ('you' if who == data['source_user'] else who) replydict.update(loc_data[who][-1]) replydict['whenstr'] = prettier_date(replydict['when']) replystr = replyfmtstr % replydict except: reply = ['(shh.. someone made me do something wrong!)'] finally: reply.append(replystr) loc_data.close() return reply_to_user(data, reply)
def cmd_whereis(self, command, data): splitcmd = [a.strip() for a in command.split(':')] who = splitcmd[1] reply = [] if who == data['source_user']: reply.append("Don't you know where you are?") try: loc_data = shelve.open(self.loc_file) if who not in loc_data: replystr = "No idea!" elif loc_data[who][-1]['where'].lower() in NOLOC: replystr = "Who knows?" else: replyfmtstr = "%(who)s %(atstr)s %(where)s (%(whenstr)s)" replydict = {'who': who} replydict.update(loc_data[who][-1]) replydict['whenstr'] = prettier_date(replydict['when']) replystr = replyfmtstr % replydict except: reply = ['(shh.. someone made me do something wrong!)'] finally: reply.append(replystr) loc_data.close() return reply_to_user(data, reply)
def cmd_whereiseveryone(self, command, data): try: loc_data = shelve.open(self.loc_file) asker = data['source_user'] reply = [ '_{0}_: {1} ({2})'.format(nick, loc[-1]['where'], prettier_date(loc[-1]['when'])) for nick, loc in loc_data.items() if nick != asker and loc[-1]['where'].lower() not in NOLOC ] if not reply: if asker in loc_data: reply = ['You are the only one I know about!'] else: reply = ['Nobody has told me anything!'] except: reply = ['(shh.. someone made me do something wrong!)'] finally: loc_data.close() return reply_to_user(data, reply)