コード例 #1
0
        peer.mark_read()
    if msg.text is not None \
        and peer.name == TRADEBOT_PEER_NAME \
        and trade_peer \
        :
            if r'Твой склад с материалами' in msg.text.encode('utf8') and not to_trade:
                to_trade = list()
                # parse stock
                for line in msg.text.encode('utf8').split('\n'):
                    print line
                    m = re.match('(/add_\d+)\D+(\d+)', line)
                    if m:
                        to_trade.append(m.group(1) + ' ' + m.group(2))
                        print to_trade
                print len(to_trade)
                if len(to_trade):
                    trade_peer.send_msg(to_trade.pop())
                return
            if r'Твой склад с материалами' in msg.text.encode('utf8') and to_trade and len(to_trade):
                time.sleep(1)
                trade_peer.send_msg(to_trade.pop())
                return

def on_loop():
    pass
            

tgl.set_on_our_id(on_our_id)
tgl.set_on_msg_receive(on_msg_receive)
tgl.get_dialog_list(dialog_list_cb)
tgl.set_on_loop(on_loop)
コード例 #2
0
def on_binlog_replay_end():
    print('Fetching dialog list')
    tgl.get_dialog_list(dialog_list_cb)
    return True