'Implement function using the Msg methods'

def func(self):

    caller = self.caller
    pages_we_sent = Msg.objects.get_messages_by_sender(caller, exclude_channel_messages=True)
    pages_we_got = Msg.objects.get_messages_by_receiver(caller)
    if ('last' in self.switches):
        if pages_we_sent:
            recv = ','.join((obj.key for obj in pages_we_sent[(-1)].receivers))
            self.msg(('You    last    paged    |c%s|n:%s' % (recv, pages_we_sent[(-1)].message)))
            return
        else:
            self.msg("You    haven't    paged    anyone    yet.")
            return
    if ((not self.args) or (not self.rhs)):
        pages = (pages_we_sent + pages_we_got)
        pages.sort((lambda x, y: cmp(x.date_created, y.date_created)))
        number = 5
        if self.args:
            try:
                number = int(self.args)
            except ValueError:
                self.msg('Usage:    tell    [<player>    =    msg]')
                return
        if (len(pages) > number):
            lastpages = pages[(- number):]
        else:
            lastpages = pages
        template = '|w%s|n    |c%s|n    to    |c%s|n:    %s'
        lastpages = '\n    '.join(((template % (utils.datetime_format(page.date_created), ','.join((obj.key for obj in page.senders)), '|n,|c    '.join([obj.name for obj in page.receivers]), page.message)) for page in lastpages))
        if lastpages:
            string = ('Your    latest    pages:\n    %s' % lastpages)
        else:
            string = "You    haven't    paged    anyone    yet."
        self.msg(string)
        return
    if (not self.lhs):
        if pages_we_sent:
            receivers = pages_we_sent[(-1)].receivers
        else:
            self.msg('Who    do    you    want    to    page?')
            return
    else:
        receivers = self.lhslist
    recobjs = []
    for receiver in set(receivers):
        if isinstance(receiver, basestring):
            pobj = caller.search(receiver)
        elif hasattr(receiver, 'character'):
            pobj = receiver
        else:
            self.msg('Who    do    you    want    to    page?')
            return
        if pobj:
            recobjs.append(pobj)
    if (not recobjs):
        self.msg('Noone    found    to    page.')
        return
    header = ('|wPlayer|n    |c%s|n    |wpages:|n' % caller.key)
    message = self.rhs
    if message.startswith(':'):
        message = ('%s    %s' % (caller.key, message.strip(':').strip()))
    create.create_message(caller, message, receivers=recobjs)
    received = []
    rstrings = []
    for pobj in recobjs:
        if (not pobj.access(caller, 'msg')):
            rstrings.append(('You    are    not    allowed    to    page    %s.' % pobj))
            continue
        pobj.msg(('%s    %s' % (header, message)))
        if (hasattr(pobj, 'sessions') and (not pobj.sessions.count())):
            received.append(('|C%s|n' % pobj.name))
            rstrings.append(('%s    is    offline.    They    will    see    your    message    if    they    list    their    pages    later.' % received[(-1)]))
        else:
            received.append(('|c%s|n' % pobj.name))
    if rstrings:
        self.msg('\n'.join(rstrings))
    self.msg(("You    paged    %s    with:    '%s'." % (',    '.join(received), message)))
