Its-VrxxDev / zlapi

Zalo API for Python (Unofficial)
MIT License
20 stars 14 forks source link

how to listen onEvent Group? #4

Open akunzz opened 1 month ago

akunzz commented 1 month ago

from zlapi import ZaloAPI from zlapi.models import *

imei, session_cookies = load_config()

class Bot(ZaloAPI):

def __init__(self, api_key, secret_key, imei=None, session_cookies=None):
    super().__init__(api_key, secret_key, imei, session_cookies)

def onEvent(self, event_data, event_type):
    print(event_data, event_type)

def onMessage(self, mid, author_id, message, message_object, thread_id, thread_type):
    self.markAsDelivered(mid, message_object.cliMsgId, author_id, thread_id, thread_type, message_object.msgType)

    print(f"{message}")

bot = Bot('api_key', 'secret_key', imei=imei, session_cookies=session_cookies) bot.listen(run_forever=True, delay=0, thread=True)

Its-VrxxDev commented 4 days ago

What is the error?