# Path: log.py
# def info(s, color=''):
# def warning(s):
# def debug(s):
# def error(s, need_exc_info=False, fatal=False):
# def initLogDir():
# def write(log, s):


import time
import cache
import vkapi
from log import datetime_format


def main(a, args):
    dialogs = a.messages.getDialogs(unread=1)['items']
    messages = {}
    users = []
    chats = []
    with a.delayed() as dm:
        for msg in dialogs:
            def cb(req, resp):
                messages[req['peer_id']] = resp['items'][::-1]

            dm.messages.getHistory(peer_id=vkapi.utils.getSender(msg['message']), count=min(msg['unread'], 10)).set_callback(cb)
            if 'chat_id' in msg['message']:
                chats.append(msg['message']['chat_id'])
            else:
                users.append(msg['message']['user_id'])
    uc = cache.UserCache(a, 'online')
    cc = cache.ConfCache(a)
    uc.load(users)
    cc.load(chats)
    mids = []
    if dialogs:
        print('-------------------------\n')
    else:
        print('Nothing here')
    for msg in dialogs:
        m = msg['message']
        if 'chat_id' in m:
            print('Chat "{}" ({}): {}'.format(cc[m['chat_id']]['title'], m['chat_id'], msg['unread']))

# Path: log.py
# def info(s, color=''):
# def warning(s):
# def debug(s):
# def error(s, need_exc_info=False, fatal=False):
# def initLogDir():
# def write(log, s):


# Path: scripts/read.py
import time
import cache
import vkapi
from log import datetime_format



def main(a, args):
    dialogs = a.messages.getDialogs(unread=1)['items']
    messages = {}
    users = []
    chats = []
    with a.delayed() as dm:
        for msg in dialogs:
            def cb(req, resp):
                messages[req['peer_id']] = resp['items'][::-1]

            dm.messages.getHistory(peer_id=vkapi.utils.getSender(msg['message']), count=min(msg['unread'], 10)).set_callback(cb)
            if 'chat_id' in msg['message']:
                chats.append(msg['message']['chat_id'])
            else:
                users.append(msg['message']['user_id'])
    uc = cache.UserCache(a, 'online')
    cc = cache.ConfCache(a)
    uc.load(users)
    cc.load(chats)
    mids = []
    if dialogs:
        print('-------------------------\n')
    else:
        print('Nothing here')
    for msg in dialogs:
        m = msg['message']
        if 'chat_id' in m:
            print('Chat "{}" ({}): {}'.format(cc[m['chat_id']]['title'], m['chat_id'], msg['unread']))

        else: