Its-VrxxDev / zlapi

Zalo API for Python (Unofficial)
MIT License
20 stars 14 forks source link
api python zalo zaloapi zlapi

Logo

zlapi - Zalo API (Unofficial) for Python

Project version Supported python versions: >= 3. and pypy License: MIT License Documentation

Language

What is zlapi?

A powerful and efficient library to interact with Zalo Website. This is not an official API, Zalo has that over here for chat bots. This library differs by using a normal Zalo account instead (More flexible).

zlapi currently support:

Essentially, everything you need to make an amazing Zalo Bot!

Caveats

zlapi works by imitating what the browser does, and thereby tricking Zalo into thinking it's accessing the website normally.

However, there's a catch! Using this library may not comply with Zalo's Terms Of Service, so be! We are not responsible if your account gets banned or disabled!

What's New?

This is an updated version for zlapi to improve features and fix bugs (v1.0.2)

Improvements

Bugfixes


Installation

pip install zlapi

If you don't have pip, this guide can guide you through the process.

You can also install directly from source, provided you have pip>=19.0:

pip install git+https://github.com/Its-VrxxDev/zlapi.git


How to get IMEI and Cookies?

Download Extension

Extension Usage Tutorial

  1. Enable the extension downloaded above.
  2. Go to https://chat.zalo.me, Sign in to your account.
  3. After successfully logging in, go back to extension and get IMEI, Cookies.

[!TIP] If you have opened the website chat.zalo.me but the extension does not have IMEI & Cookies, please click Refresh Page.

Windows


Android

  • Use kiwibrowser instead of chrome to be able to use the extension.
  • If you are redirect when accessing https://chat.zalo.me. Watch this video


Basic Usage

Login Account Using Cookies

# > Normal
# from zlapi import ZaloAPI

# > Async
# from zlapi.Async import ZaloAPI

from zlapi import ZaloAPI
from zlapi.models import *

imei = "<imei>"
cookies = {} # Cookies Dict
bot = ZaloAPI("<phone>", "<password>", imei=imei, session_cookies=cookies)


from zlapi.simple import ZaloAPI
from zlapi.models import *

imei = "<imei>"
cookies = {} # Cookies Dict
bot = ZaloAPI("</>", "</>", imei, cookies, prefix="<your bot prefix>")


Listen Message, Event, ...

bot.listen(thread=True)
bot.listen(type="<listen type>")
bot.listen(run_forever=True)


# > Normal
# from zlapi import ZaloAPI

# > Async
# from zlapi.Async import ZaloAPI

from zlapi import ZaloAPI
from zlapi.models import *

imei = "<imei>"
cookies = {} # Cookies Dict

bot = ZaloAPI("<phone>", "<password>", imei=imei, session_cookies=cookies)
# bot.listen(type="...")
bot.listen()


from zlapi.simple import ZaloAPI
from zlapi.models import *

imei = "<imei>"
cookies = {} # Cookies Dict

bot = ZaloAPI("</>", "</>", imei, cookies, prefix="<your bot prefix>")
bot.listen()


Custom On Message Function

onMessage function will be called when receiving a message from listen function. So we can handle that message here.

from zlapi import ZaloAPI
from zlapi.models import *

imei = "<imei>"
cookies = {} # Cookies Dict

class CustomBot(ZaloAPI):
    def onMessage(self, mid, author_id, message, message_object, thread_id, thread_type):
        # Handle Message Here
        pass

bot = CustomBot("<phone>", "<password>", imei=imei, session_cookies=cookies)
bot.listen()


from zlapi.Async import ZaloAPI
from zlapi.models import *

imei = "<imei>"
cookies = {} # Cookies Dict

class CustomBot(ZaloAPI):
    async def onMessage(self, mid, author_id, message, message_object, thread_id, thread_type):
        # Handle Message Here
        pass

bot = CustomBot("<phone>", "<password>", imei=imei, session_cookies=cookies)
bot.listen()


from zlapi.simple import ZaloAPI
from zlapi.models import *

imei = "<imei>"
cookies = {} # Cookies Dict
bot = ZaloAPI("</>", "</>", imei, cookies, prefix="<bot prefix>")

@bot.event
async def on_message(ctx):
    # Handle Message Here
    pass

bot.listen()


Example Handle Message

Normal code style ```py from zlapi import ZaloAPI from zlapi.models import * imei = "" cookies = {} # Cookies Dict class CustomBot(ZaloAPI): def onMessage(self, mid, author_id, message, message_object, thread_id, thread_type): if not isinstance(message, str): return if message == ".hi": print(f"{author_id} sent message .hi") bot = CustomBot("", "", imei=imei, session_cookies=cookies) bot.listen() ``` > - If the message is not ``string`` do not process this message. > - If the message is ``.hi`` will print author id of message to terminal.
Async code style ```py from zlapi.Async import ZaloAPI from zlapi.models import * imei = "" cookies = {} # Cookies Dict class CustomBot(ZaloAPI): async def onMessage(self, mid, author_id, message, message_object, thread_id, thread_type): if not isinstance(message, str): return if message == ".hi": print(f"{author_id} sent message .hi") bot = CustomBot("", "", imei=imei, session_cookies=cookies) bot.listen() ``` > - If the message is not ``string`` do not process this message. > - If the message is ``.hi`` will print author id of message to terminal.
Simple code style - Method 1 ```py from zlapi.simple import ZaloAPI from zlapi.models import * imei = "" cookies = {} # Cookies Dict bot = ZaloAPI("", "", imei, cookies, prefix="") @bot.event async def on_message(ctx): if ctx.message == ".hi": print(f"{ctx.author_id} sent message .hi") bot.listen() ```
- Method 2 ```py from zlapi.simple import ZaloAPI from zlapi.models import * imei = "" cookies = {} # Cookies Dict bot = ZaloAPI("", "", imei, cookies, prefix=".") @bot.register_handler(commands=["hi"]) async def handle_hi(ctx): print(f"{ctx.author_id} sent message .hi") bot.listen() ``` > - ``@bot.register_handler(commands=["hi"])`` is a decoration class used to register a command. When an incoming message matches the bot prefix + registered commands, the message will be processed.


Fetch Account Information

This function will get the account information you are using in zlapi.

Normal code style - Outside Module Function ```py bot.fetchAccountInfo() ```
- Inside Module Function ```py self.fetchAccountInfo() ```
Async code style - Outside Module Function ```py asyncio.run(bot.fetchAccountInfo()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.fetchAccountInfo() ```
Simple code style - Outside Module Function ```py asyncio.run(bot.fetch_account_info()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.fetch_account_info() ```


Fetch Phone Number

This function will get user information using that user phone number.

[!NOTE] Can't get information of hidden phone number or locked account

Normal code style - Outside Module Function ```py bot.fetchPhoneNumber("") ```
- Inside Module Function ```py self.fetchPhoneNumber("") ```
Async code style - Outside Module Function ```py asyncio.run(bot.fetchPhoneNumber("")) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.fetchPhoneNumber("") ```
Simple code style - Outside Module Function ```py asyncio.run(bot.fetch_phone_number("")) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.fetch_phone_number("") ```


Fetch User Info

This function will get user information using that user ID.

  • In Normal/Async code style you can get user id with author_id argument
  • In Simple code style you can get user id with ctx.author_id argument
  • Or you can use user id if you already have one
Normal code style - Outside Module Function ```py bot.fetchUserInfo() ```
- Inside Module Function ```py self.fetchUserInfo() ```
Async code style - Outside Module Function ```py asyncio.run(bot.fetchUserInfo()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.fetchUserInfo() ```
Simple code style - Outside Module Function ```py asyncio.run(bot.fetch_user_info()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.fetch_user_info() ```


Fetch Group Info

This function will get group information using that group ID.

  • In Normal/Async code style you can get user id with thread_id argument
  • In Simple code style you can get user id with ctx.thread_id argument
  • Or you can use group id if you already have one
Normal code style - Outside Module Function ```py bot.fetchGroupInfo() ```
- Inside Module Function ```py self.fetchGroupInfo() ```
Async code style - Outside Module Function ```py asyncio.run(bot.fetchGroupInfo()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.fetchGroupInfo() ```
Simple code style - Outside Module Function ```py asyncio.run(bot.fetch_group_info()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.fetch_group_info() ```


Fetch All Friends

This function will get all the friends information of the account currently using the zlapi.

Normal code style - Outside Module Function ```py bot.fetchAllFriends() ```
- Inside Module Function ```py self.fetchAllFriends() ```
Async code style - Outside Module Function ```py asyncio.run(bot.fetchAllFriends()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.fetchAllFriends() ```
Simple code style - Outside Module Function ```py asyncio.run(bot.fetch_all_friends()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.fetch_all_friends() ```


Fetch All Groups

This function will get all the groups id of the account currently using the zlapi.

Normal code style - Outside Module Function ```py bot.fetchAllGroups() ```
- Inside Module Function ```py self.fetchAllGroups() ```
Async code style - Outside Module Function ```py asyncio.run(bot.fetchAllGroups()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.fetchAllGroups() ```
Simple code style - Outside Module Function ```py asyncio.run(bot.fetch_all_groups()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.fetch_all_groups() ```


Change Account Setting

This function will change setting of the account currently using the zlapi.

  • Args:
    • name (str): The new account name
    • dob (str): Date of birth wants to change (format: year-month-day)
    • gender (int | str): Gender wants to change (0 = Male, 1 = Female)
Normal code style - Outside Module Function ```py bot.changeAccountSetting(, , ) ```
- Inside Module Function ```py self.changeAccountSetting(, , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.changeAccountSetting(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.changeAccountSetting(, , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.change_account_setting(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.change_account_setting(, , ) ```


Change Account Avatar

This function will upload/change avatar of the account currently using the zlapi.

  • Args:
    • filePath (str): A path to the image to upload/change avatar
    • size (int): Avatar image size (default = auto)
    • width (int): Width of avatar image
    • height (int): height of avatar image
    • language (int | str): Zalo Website language ? (idk)
Normal code style - Outside Module Function ```py bot.changeAccountAvatar() ```
- Inside Module Function ```py self.changeAccountAvatar() ```
Async code style - Outside Module Function ```py asyncio.run(bot.changeAccountAvatar()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.changeAccountAvatar() ```
Simple code style - Outside Module Function ```py asyncio.run(bot.change_account_avatar()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.change_account_avatar() ```


Send Friend Request

This function will send friend request to a user by ID.

  • Args:
    • userId (int | str): User ID to send friend request
    • msg (str): Friend request message
    • language (str): Response language or Zalo interface language
Normal code style - Outside Module Function ```py bot.sendFriendRequest(, ) ```
- Inside Module Function ```py self.sendFriendRequest(, ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.sendFriendRequest(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.sendFriendRequest(, ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.send_friend_request(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.send_friend_request(, ) ```


Accept Friend Request

This function will accept friend request from user by ID.

  • Args:
    • userId (int | str): User ID to accept friend request
    • language (str): Response language or Zalo interface language
Normal code style - Outside Module Function ```py bot.acceptFriendRequest() ```
- Inside Module Function ```py self.acceptFriendRequest() ```
Async code style - Outside Module Function ```py asyncio.run(bot.acceptFriendRequest()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.acceptFriendRequest() ```
Simple code style - Outside Module Function ```py asyncio.run(bot.accept_friend_request()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.accept_friend_request() ```


Block View Feed

This function will Block/Unblock friend view feed by ID.

  • Args:
    • userId (int | str): User ID to block/unblock view feed
    • isBlockFeed (int): Block/Unblock friend view feed (1 = True | 0 = False)
Normal code style - Outside Module Function ```py bot.blockViewFeed(, ) ```
- Inside Module Function ```py self.blockViewFeed(, ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.blockViewFeed(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.blockViewFeed(, ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.block_view_feed(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.block_view_feed(, ) ```


Block User

This function will block user by ID.

  • Args:
    • userId (int | str): User ID to block
Normal code style - Outside Module Function ```py bot.blockUser() ```
- Inside Module Function ```py self.blockUser() ```
Async code style - Outside Module Function ```py asyncio.run(bot.blockUser()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.blockUser() ```
Simple code style - Outside Module Function ```py asyncio.run(bot.block_user()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.block_user() ```


Unblock User

This function will unblock user by ID.

  • Args:
    • userId (int | str): User ID to unblock
Normal code style - Outside Module Function ```py bot.unblockUser() ```
- Inside Module Function ```py self.unblockUser() ```
Async code style - Outside Module Function ```py asyncio.run(bot.unblockUser()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.unblockUser() ```
Simple code style - Outside Module Function ```py asyncio.run(bot.unblock_user()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.unblock_user() ```


Create Group

This function will Create a new group.

  • Args:
    • name (str): The new group name
    • description (str): Description of the new group
    • members (str | list): List/String member IDs add to new group
    • nameChanged (int - auto): Will use default name if disabled (0), else (1)
    • createLink (int - default): Create a group link? Default = 1 (True)
Normal code style - Outside Module Function ```py bot.createGroup(, , ) ```
- Inside Module Function ```py self.createGroup(, , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.createGroup(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.createGroup(, , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.create_group(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.create_group(, , ) ```


Change Group Avatar

This function will Upload/Change group avatar by ID.

  • Args:
    • filePath (str): A path to the image to upload/change avatar
    • groupId (int | str): Group ID to upload/change avatar
Normal code style - Outside Module Function ```py bot.changeGroupAvatar(, ) ```
- Inside Module Function ```py self.changeGroupAvatar(, ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.changeGroupAvatar(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.changeGroupAvatar(, ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.change_group_avatar(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.change_group_avatar(, ) ```

[!NOTE] Client must be the Owner of the group (If the group does not allow members to upload/change)


Change Group Name

This function will Set/Change group name by ID.

  • Args:
    • groupName (str): Group name to change
    • groupId (int | str): Group ID to change name
Normal code style - Outside Module Function ```py bot.changeGroupName(, ) ```
- Inside Module Function ```py self.changeGroupName(, ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.changeGroupName(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.changeGroupName(, ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.change_group_name(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.change_group_name(, ) ```

[!NOTE] Client must be the Owner of the group (If the group does not allow members to upload/change)


Change Group Setting

This function will Update group settings by ID.

  • Args:

    • groupId (int | str): Group ID to update settings

    • defaultMode (str): Default mode of settings

      • default: Group default settings
      • anti-raid: Group default settings for anti-raid
    • **kwargs: Group settings kwargs, Value: (1 = True, 0 = False)

      • blockName: Không cho phép user đổi tên & ảnh đại diện nhóm
      • signAdminMsg: Đánh dấu tin nhắn từ chủ/phó nhóm
      • addMemberOnly: Chỉ thêm members (Khi tắt link tham gia nhóm)
      • setTopicOnly: Cho phép members ghim (tin nhắn, ghi chú, bình chọn)
      • enableMsgHistory: Cho phép new members đọc tin nhắn gần nhất
      • lockCreatePost: Không cho phép members tạo ghi chú, nhắc hẹn
      • lockCreatePoll: Không cho phép members tạo bình chọn
      • joinAppr: Chế độ phê duyệt thành viên
      • bannFeature: Default (No description)
      • dirtyMedia: Default (No description)
      • banDuration: Default (No description)
      • lockSendMsg: Không cho phép members gửi tin nhắn
      • lockViewMember: Không cho phép members xem thành viên nhóm
      • blocked_members: Danh sách members bị chặn
Normal code style - Outside Module Function ```py bot.changeGroupSetting(, **kwargs) ```
- Inside Module Function ```py self.changeGroupSetting(, **kwargs) ```
Async code style - Outside Module Function ```py asyncio.run(bot.changeGroupSetting(, **kwargs)) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.changeGroupSetting(, **kwargs) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.change_group_setting(, **kwargs)) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.change_group_setting(, **kwargs) ```

[!WARNING] Other settings will default value if not set. See defaultMode


Change Group Owner

This function will Change group owner by ID.

  • Args:
    • newAdminId (int | str): members ID to changer owner
    • groupId (int | str): ID of the group to changer owner
Normal code style - Outside Module Function ```py bot.changeGroupOwner(, ) ```
- Inside Module Function ```py self.changeGroupOwner(, ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.changeGroupOwner(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.changeGroupOwner(, ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.change_group_owner(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.change_group_owner(, ) ```

[!NOTE] Client must be the Owner of the group.


Add Users To Group

This function will Add friends/users to a group.

  • Args:
    • user_ids (str | list): One or more friend/user IDs to add
    • groupId (int | str): Group ID to add friend/user to
Normal code style - Outside Module Function ```py bot.addUsersToGroup(, ) ```
- Inside Module Function ```py self.addUsersToGroup(, ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.addUsersToGroup(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.addUsersToGroup(, ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.add_users_to_group(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.add_users_to_group(, ) ```


Kick Users In Group

This function will Kickout members in group by ID.

  • Args:
    • members (str | list): One or More member IDs to kickout
    • groupId (int | str): Group ID to kick member from
Normal code style - Outside Module Function ```py bot.kickUsersInGroup(, ) ```
- Inside Module Function ```py self.kickUsersInGroup(, ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.kickUsersInGroup(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.kickUsersInGroup(, ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.kick_users_in_group(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.kick_users_in_group(, ) ```

[!NOTE] Client must be the Owner of the group.


Block Users In Group

This function will Blocked members in group by ID.

  • Args:
    • members (str | list): One or More member IDs to block
    • groupId (int | str): Group ID to block member from
Normal code style - Outside Module Function ```py bot.blockUsersInGroup(, ) ```
- Inside Module Function ```py self.blockUsersInGroup(, ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.blockUsersInGroup(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.blockUsersInGroup(, ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.block_users_in_group(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.block_users_in_group(, ) ```

[!NOTE] Client must be the Owner of the group.


Unblock Users In Group

This function will Unblock members in group by ID.

  • Args:
    • members (str | list): One or More member IDs to unblock
    • groupId (int | str): Group ID to unblock member from
Normal code style - Outside Module Function ```py bot.unblockUsersInGroup(, ) ```
- Inside Module Function ```py self.unblockUsersInGroup(, ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.unblockUsersInGroup(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.unblockUsersInGroup(, ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.unblock_users_in_group(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.unblock_users_in_group(, ) ```

[!NOTE] Client must be the Owner of the group.


Add Group Admins

This function will Add admins to the group by ID.

  • Args:
    • members (str | list): One or More member IDs to add
    • groupId (int | str): Group ID to add admins
Normal code style - Outside Module Function ```py bot.addGroupAdmins(, ) ```
- Inside Module Function ```py self.addGroupAdmins(, ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.addGroupAdmins(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.addGroupAdmins(, ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.add_group_admins(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.add_group_admins(, ) ```

[!NOTE] Client must be the Owner of the group.


Remove Group Admins

This function will Remove admins in the group by ID.

  • Args:
    • members (str | list): One or More admin IDs to remove
    • groupId (int | str): Group ID to remove admins
Normal code style - Outside Module Function ```py bot.removeGroupAdmins(, ) ```
- Inside Module Function ```py self.removeGroupAdmins(, ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.removeGroupAdmins(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.removeGroupAdmins(, ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.remove_group_admins(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.remove_group_admins(, ) ```

[!NOTE] Client must be the Owner of the group.


Pin Group Message

This function will Pin message in group by ID.

  • Args:
    • pinMsg (Message): Message Object to pin
    • groupId (int | str): Group ID to pin message
Normal code style - Outside Module Function ```py bot.pinGroupMsg(, ) ```
- Inside Module Function ```py self.pinGroupMsg(, ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.pinGroupMsg(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.pinGroupMsg(, ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.pin_group_msg(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.pin_group_msg(, ) ```


Unpin Group Message

This function will Unpin message in group by ID.

  • Args:
    • pinId (int | str): Pin ID to unpin
    • pinTime (int): Pin start time
    • groupId (int | str): Group ID to unpin message
Normal code style - Outside Module Function ```py bot.unpinGroupMsg(, , ) ```
- Inside Module Function ```py self.unpinGroupMsg(, , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.unpinGroupMsg(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.unpinGroupMsg(, , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.unpin_group_msg(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.unpin_group_msg(, , ) ```


Delete Group Message

This function will Delete message in group by ID.

  • Args:
    • msgId (int | str): Message ID to delete
    • ownerId (int | str): Owner ID of the message to delete
    • clientMsgId (int | str): Client message ID to delete message
    • groupId (int | str): Group ID to delete message
Normal code style - Outside Module Function ```py bot.deleteGroupMsg(, , , ) ```
- Inside Module Function ```py self.deleteGroupMsg(, , , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.deleteGroupMsg(, , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.deleteGroupMsg(, , , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.delete_group_msg(, , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.delete_group_msg(, , , ) ```


View Group Pending

This function will Give list of people pending approval in group by ID.

  • Args:
    • groupId (int | str): Group ID to view pending members
Normal code style - Outside Module Function ```py bot.viewGroupPending() ```
- Inside Module Function ```py self.viewGroupPending() ```
Async code style - Outside Module Function ```py asyncio.run(bot.viewGroupPending()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.viewGroupPending() ```
Simple code style - Outside Module Function ```py asyncio.run(bot.view_group_pending()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.view_group_pending() ```


Handle Group Pending

This function will Approve/Deny pending users to the group from the group's approval.

  • Args:
    • members (str | list): One or More member IDs to handle
    • groupId (int | str): ID of the group to handle pending members
    • isApprove (bool): Approve/Reject pending members (True | False)
Normal code style - Outside Module Function ```py bot.handleGroupPending(, ) ```
- Inside Module Function ```py self.handleGroupPending(, ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.handleGroupPending(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.handleGroupPending(, ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.handle_group_pending(, )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.handle_group_pending(, ) ```


View Poll Detail

This function will Give poll data by ID.

  • Args:
    • pollId (int | str): Poll ID to view detail
Normal code style - Outside Module Function ```py bot.viewPollDetail() ```
- Inside Module Function ```py self.viewPollDetail() ```
Async code style - Outside Module Function ```py asyncio.run(bot.viewPollDetail()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.viewPollDetail() ```
Simple code style - Outside Module Function ```py asyncio.run(bot.view_poll_detail()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.view_poll_detail() ```


Create Poll

This function will Create poll in group by ID.

  • Args:
    • question (str): Question for poll
    • options (str | list): List options for poll
    • groupId (int | str): Group ID to create poll from
    • expiredTime (int): Poll expiration time (0 = no expiration)
    • pinAct (bool): Pin action (pin poll)
    • multiChoices (bool): Allows multiple poll choices
    • allowAddNewOption (bool): Allow members to add new options
    • hideVotePreview (bool): Hide voting results when haven't voted
    • isAnonymous (bool): Hide poll voters
Normal code style - Outside Module Function ```py bot.createPoll(, , ) ```
- Inside Module Function ```py self.createPoll(, , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.createPoll(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.createPoll(, , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.create_poll(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.create_poll(, , ) ```


Lock Poll

This function will Lock/end poll by ID.

  • Args:
    • pollId (int | str): Poll ID to lock
Normal code style - Outside Module Function ```py bot.lockPoll() ```
- Inside Module Function ```py self.lockPoll() ```
Async code style - Outside Module Function ```py asyncio.run(bot.lockPoll()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.lockPoll() ```
Simple code style - Outside Module Function ```py asyncio.run(bot.lock_poll()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.lock_poll() ```


Disperse Group

This function will Disperse group by ID.

  • Args:
    • groupId (int | str): Group ID to disperse
Normal code style - Outside Module Function ```py bot.disperseGroup() ```
- Inside Module Function ```py self.disperseGroup() ```
Async code style - Outside Module Function ```py asyncio.run(bot.disperseGroup()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.disperseGroup() ```
Simple code style - Outside Module Function ```py asyncio.run(bot.disperse_group()) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.disperse_group() ```


Send Message

This function will Send message to a thread (user/group).

  • Args:
    • message (Message): Message Object to send
    • thread_id (int | str): User/Group ID to send to
    • thread_type (ThreadType): ThreadType.USER, ThreadType.GROUP
    • mark_message (str): Send messages as Urgent or Important mark
Normal code style - Outside Module Function ```py bot.send(, , ) ``` or ```py bot.sendMessage(, , ) ```
- Inside Module Function ```py self.send(, , ) ``` or ```py self.sendMessage(, , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.send(, , )) ``` or ```py asyncio.run(bot.sendMessage(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.send(, , ) ``` or ```py await self.sendMessage(, , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.send(, , )) ``` or ```py asyncio.run(bot.send_message(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.send(, , ) ``` or ```py await bot.send_message(, , ) ```


Reply Message

This function will Reply message in thread (user/group).

  • Args:
    • message (Message): Message Object to send
    • replyMsg (Message): Message Object to reply
    • thread_id (int | str): User/Group ID to send to.
    • thread_type (ThreadType): ThreadType.USER, ThreadType.GROUP
Normal code style - Outside Module Function ```py bot.replyMessage(, , , ) ```
- Inside Module Function ```py self.replyMessage(, , , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.replyMessage(, , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.replyMessage(, , , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.reply_message(, , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.reply_message(, , , ) ```


Undo Message

This function will Undo message from the client (self) by ID.

  • Args:
    • msgId (int | str): Message ID to undo
    • cliMsgId (int | str): Client Msg ID to undo
    • thread_id (int | str): User/Group ID to undo message
    • thread_type (ThreadType): ThreadType.USER, ThreadType.GROUP
Normal code style - Outside Module Function ```py bot.undoMessage(, , , ) ```
- Inside Module Function ```py self.undoMessage(, , , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.undoMessage(, , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.undoMessage(, , , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.undo_message(, , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.undo_message(, , , ) ```


Send Reaction

This function will Reaction message in thread (user/group) by ID.

  • Args:
    • messageObject (Message): Message Object to reaction
    • reactionIcon (str): Icon/Text to reaction
    • thread_id (int | str): Group/User ID contain message to reaction
    • thread_type (ThreadType): ThreadType.USER, ThreadType.GROUP
Normal code style - Outside Module Function ```py bot.sendReaction(, , , ) ```
- Inside Module Function ```py self.sendReaction(, , , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.sendReaction(, , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.sendReaction(, , , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.send_reaction(, , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.send_reaction(, , , ) ```


Send Multiple Reactions

This function will Reaction multi message in thread (user/group) by ID.

  • Args:
    • reactionObj (MessageReaction): Message(s) data to reaction
    • reactionIcon (str): Icon/Text to reaction
    • thread_id (int | str): Group/User ID contain message to reaction
    • thread_type (ThreadType): ThreadType.USER, ThreadType.GROUP
Normal code style - Outside Module Function ```py bot.sendMultiReaction(, , , ) ```
- Inside Module Function ```py self.sendMultiReaction(, , , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.sendMultiReaction(, , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.sendMultiReaction(, , , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.send_multi_reaction(, , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.send_multi_reaction(, , , ) ```


Send Remote File

This function will Send File to a User/Group with url.

  • Args:
    • fileUrl (str): File url to send
    • thread_id (int | str): User/Group ID to send to.
    • thread_type (ThreadType): ThreadType.USER, ThreadType.GROUP
    • fileName (str): File name to send
    • fileSize (int): File size to send
    • extension (str): type of file to send (py, txt, mp4, ...)
Normal code style - Outside Module Function ```py bot.sendRemoteFile(, , ) ```
- Inside Module Function ```py self.sendRemoteFile(, , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.sendRemoteFile(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.sendRemoteFile(, , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.send_remote_file(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.send_remote_file(, , ) ```


Send Remote Video

This function will Send video to a User/Group with url.

  • Args:
    • videoUrl (str): Video link to send
    • thumbnailUrl (str): Thumbnail link for video
    • duration (int | str): Time for video (ms)
    • thread_id (int | str): User/Group ID to send to.
    • thread_type (ThreadType): ThreadType.USER, ThreadType.GROUP
    • width (int): Width of the video
    • height (int): Height of the video
    • message (Message): Message Object to send with video
Normal code style - Outside Module Function ```py bot.sendRemoteVideo(, , , , ) ```
- Inside Module Function ```py self.sendRemoteVideo(, , , , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.sendRemoteVideo(, , , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.sendRemoteVideo(, , , , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.send_remote_video(, , , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.send_remote_video(, , , , ) ```


Send Remote Voice

This function will Send voice to a User/Group with url.

  • Args:
    • voiceUrl (str): Voice link to send
    • thread_id (int | str): User/Group ID to change status in
    • thread_type (ThreadType): ThreadType.USER, ThreadType.GROUP
    • fileSize (int | str): Voice content length (size) to send
Normal code style - Outside Module Function ```py bot.sendRemoteVoice(, , ) ```
- Inside Module Function ```py self.sendRemoteVoice(, , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.sendRemoteVoice(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.sendRemoteVoice(, , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.send_remote_voice(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.send_remote_voice(, , ) ```


Send Local Image

This function will Send Image to a User/Group with local file.

  • Args:
    • imagePath (str): Image directory to send
    • thread_id (int | str): User/Group ID to send to.
    • thread_type (ThreadType): ThreadType.USER, ThreadType.GROUP
    • width (int): Image width to send
    • height (int): Image height to send
    • message (Message): Message Object to send with image
Normal code style - Outside Module Function ```py bot.sendLocalImage(, , ) ```
- Inside Module Function ```py self.sendLocalImage(, , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.sendLocalImage(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.sendLocalImage(, , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.send_local_image(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.send_local_image(, , ) ```


Send Multiple Local Image

This function will Send Multiple Image to a User/Group with local file.

  • Args:
    • imagePathList (list): List image directory to send
    • thread_id (int | str): User/Group ID to send to.
    • thread_type (ThreadType): ThreadType.USER, ThreadType.GROUP
    • width (int): Image width to send
    • height (int): Image height to send
    • message (Message): Message Object to send with image
Normal code style - Outside Module Function ```py bot.sendMultiLocalImage(, , ) ```
- Inside Module Function ```py self.sendMultiLocalImage(, , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.sendMultiLocalImage(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.sendMultiLocalImage(, , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.send_multi_local_image(, , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.send_multi_local_image(, , ) ```


Send Local Gif

This function will Send Gif to a User/Group with local file.

  • Args:
    • gifPath (str): Gif path to send
    • thumbnailUrl (str): Thumbnail of gif to send
    • thread_id (int | str): User/Group ID to send to.
    • thread_type (ThreadType): ThreadType.USER, ThreadType.GROUP
    • gifName (str): Gif name to send
    • width (int): Gif width to send
    • height (int): Gif height to send
Normal code style - Outside Module Function ```py bot.sendLocalGif(, , , ) ```
- Inside Module Function ```py self.sendLocalGif(, , , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.sendLocalGif(, , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.sendLocalGif(, , , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.send_local_gif(, , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.send_local_gif(, , , ) ```


Send Sticker

This function will Send Sticker to a User/Group.

  • Args:
    • stickerType (int | str): Sticker type to send
    • stickerId (int | str): Sticker id to send
    • cateId (int | str): Sticker category id to send
    • thread_id (int | str): User/Group ID to send to.
    • thread_type (ThreadType): ThreadType.USER, ThreadType.GROUP
Normal code style - Outside Module Function ```py bot.sendSticker(, , , , ) ```
- Inside Module Function ```py self.sendSticker(, , , , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.sendSticker(, , , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.sendSticker(, , , , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.send_sticker(, , , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.send_sticker(, , , , ) ```


Send Custom Sticker

This function will Send custom (static/animation) sticker to a User/Group with url.

  • Args:
    • staticImgUrl (str): Image url (png, jpg, jpeg) format to create sticker
    • animationImgUrl (str): Static/Animation image url (webp) format to create sticker
    • thread_id (int | str): User/Group ID to send sticker to.
    • thread_type (ThreadType): ThreadType.USER, ThreadType.GROUP
    • reply (int | str): Message ID to send stickers with quote
    • width (int | str): Width of photo/sticker
    • height (int | str): Height of photo/sticker
Normal code style - Outside Module Function ```py bot.sendCustomSticker(, , , ) ```
- Inside Module Function ```py self.sendCustomSticker(, , , ) ```
Async code style - Outside Module Function ```py asyncio.run(bot.sendCustomSticker(, , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await self.sendCustomSticker(, , , ) ```
Simple code style - Outside Module Function ```py asyncio.run(bot.send_custom_sticker(, , , )) ```
- Inside Module Function (You can use ``await`` instead.) ```py await bot.send_custom_sticker(, , , ) ```


Send Link

This function will Send link to a User/Group with url.

  • Args:
    • linkUrl (str): Link url to send
    • title (str): Title for card to send
    • thread_id (int | str): User/Group ID to send link to
    • thread_type (ThreadType): ThreadType.USER, ThreadType.GROUP
    • thumbnailUrl (str): Thumbnail link url for card to send
    • domainUrl (str): Main domain of Link to send (eg: github.com)
    • desc (str): Description for card to send
    • message (Message): Message Object to send with the link
Normal code style - Outside Module Function ```py bot.sendLink(, , <thread_id>, <thread_type>) ``` </br> - Inside Module Function ```py self.sendLink(<linkUrl>, <title>, <thread_id>, <thread_type>) ``` </details> <details> <summary><b><i>Async</b> code style</i></summary> - Outside Module Function ```py asyncio.run(bot.sendLink(<linkUrl>, <title>, <thread_id>, <thread_type>)) ``` </br> - Inside Module Function (You can use ``await`` instead.) ```py await self.sendLink(<linkUrl>, <title>, <thread_id>, <thread_type>) ``` </details> <details> <summary><b><i>Simple</b> code style</i></summary> - Outside Module Function ```py asyncio.run(bot.send_link(<linkUrl>, <title>, <thread_id>, <thread_type>)) ``` </br> - Inside Module Function (You can use ``await`` instead.) ```py await bot.send_link(<linkUrl>, <title>, <thread_id>, <thread_type>) ``` </details> <!-- END sendLink --> <p></br></p> <!-- sendReport --> <h3>Send Report</h3> <p>This function will Send report to Zalo.</p> <blockquote> <ul> <li> <p>Args:</p> <ul> <li> <p>user_id (int | str): User ID to report</p> </li> <li> <p>reason (int): Reason for reporting</p> <ul> <li>1 = Nội dung nhạy cảm</li> <li>2 = Làm phiền</li> <li>3 = Lừa đảo</li> <li>0 = custom</li> </ul> </li> <li> <p>content (str): Report content (work if reason = custom)</p> </li> </ul> </li> </ul> </blockquote> <details> <summary><b><i>Normal</b> code style</i></summary> - Outside Module Function ```py bot.sendReport(<user_id>) ``` </br> - Inside Module Function ```py self.sendReport(<user_id>) ``` </details> <details> <summary><b><i>Async</b> code style</i></summary> - Outside Module Function ```py asyncio.run(bot.sendReport(<user_id>)) ``` </br> - Inside Module Function (You can use ``await`` instead.) ```py await self.sendReport(<user_id>) ``` </details> <details> <summary><b><i>Simple</b> code style</i></summary> - Outside Module Function ```py asyncio.run(bot.send_report(<user_id>)) ``` </br> - Inside Module Function (You can use ``await`` instead.) ```py await bot.send_report(<user_id>) ``` </details> <!-- END sendReport --> <p></br></p> <!-- sendBusinessCard --> <h3>Send Business Card</h3> <p>This function will Send business card to thread (user/group) by user ID.</p> <blockquote> <ul> <li>Args: <ul> <li>userId (int | str): Business card user ID</li> <li>qrCodeUrl (str): QR Code link with business card profile information</li> <li>thread_id (int | str): User/Group ID to change status in</li> <li>thread_type (ThreadType): <code>ThreadType.USER</code>, <code>ThreadType.GROUP</code></li> <li>phone (int | str): Send business card with phone number</li> </ul></li> </ul> </blockquote> <details> <summary><b><i>Normal</b> code style</i></summary> - Outside Module Function ```py bot.sendBusinessCard(<userId>, <qrCodeUrl>, <thread_id>, <thread_type>) ``` </br> - Inside Module Function ```py self.sendBusinessCard(<userId>, <qrCodeUrl>, <thread_id>, <thread_type>) ``` </details> <details> <summary><b><i>Async</b> code style</i></summary> - Outside Module Function ```py asyncio.run(bot.sendBusinessCard(<userId>, <qrCodeUrl>, <thread_id>, <thread_type>)) ``` </br> - Inside Module Function (You can use ``await`` instead.) ```py await self.sendBusinessCard(<userId>, <qrCodeUrl>, <thread_id>, <thread_type>) ``` </details> <details> <summary><b><i>Simple</b> code style</i></summary> - Outside Module Function ```py asyncio.run(bot.send_business_card(<userId>, <qrCodeUrl>, <thread_id>, <thread_type>)) ``` </br> - Inside Module Function (You can use ``await`` instead.) ```py await bot.send_business_card(<userId>, <qrCodeUrl>, <thread_id>, <thread_type>) ``` </details> <!-- END sendBusinessCard --> <p></br></p> <!-- setTypingStatus --> <h3>Set Typing Status</h3> <p>This function will Set users typing status.</p> <blockquote> <ul> <li>Args: <ul> <li>thread_id: User/Group ID to change status in.</li> <li>thread_type (ThreadType): <code>ThreadType.USER</code>, <code>ThreadType.GROUP</code></li> </ul></li> </ul> </blockquote> <details> <summary><b><i>Normal</b> code style</i></summary> - Outside Module Function ```py bot.setTyping(<thread_id>, <thread_type>) ``` </br> - Inside Module Function ```py self.setTyping(<thread_id>, <thread_type>) ``` </details> <details> <summary><b><i>Async</b> code style</i></summary> - Outside Module Function ```py asyncio.run(bot.setTyping(<thread_id>, <thread_type>)) ``` </br> - Inside Module Function (You can use ``await`` instead.) ```py await self.setTyping(<thread_id>, <thread_type>) ``` </details> <details> <summary><b><i>Simple</b> code style</i></summary> - Outside Module Function ```py asyncio.run(bot.set_typing(<thread_id>, <thread_type>)) ``` </br> - Inside Module Function (You can use ``await`` instead.) ```py await bot.set_typing(<thread_id>, <thread_type>) ``` </details> <!-- END setTypingStatus --> <p></br></p> <!-- markAsDelivered --> <h3>Mark Message As Delivered</h3> <p>This function will Mark a message as delivered.</p> <blockquote> <ul> <li>Args: <ul> <li>msgId (int | str): Message ID to set as delivered</li> <li>cliMsgId (int | str): Client message ID</li> <li>senderId (int | str): Message sender Id</li> <li>thread_id (int | str): User/Group ID to mark as delivered</li> <li>thread_type (ThreadType): <code>ThreadType.USER</code>, <code>ThreadType.GROUP</code></li> </ul></li> </ul> </blockquote> <details> <summary><b><i>Normal</b> code style</i></summary> - Outside Module Function ```py bot.markAsDelivered(<msgId>, <cliMsgId>, <senderId>, <thread_id>, <thread_type>) ``` </br> - Inside Module Function ```py self.markAsDelivered(<msgId>, <cliMsgId>, <senderId>, <thread_id>, <thread_type>) ``` </details> <details> <summary><b><i>Async</b> code style</i></summary> - Outside Module Function ```py asyncio.run(bot.markAsDelivered(<msgId>, <cliMsgId>, <senderId>, <thread_id>, <thread_type>)) ``` </br> - Inside Module Function (You can use ``await`` instead.) ```py await self.markAsDelivered(<msgId>, <cliMsgId>, <senderId>, <thread_id>, <thread_type>) ``` </details> <details> <summary><b><i>Simple</b> code style</i></summary> - Outside Module Function ```py asyncio.run(bot.mark_as_delivered(<msgId>, <cliMsgId>, <senderId>, <thread_id>, <thread_type>)) ``` </br> - Inside Module Function (You can use ``await`` instead.) ```py await bot.mark_as_delivered(<msgId>, <cliMsgId>, <senderId>, <thread_id>, <thread_type>) ``` </details> <!-- END markAsDelivered --> <p></br></p> <!-- markAsRead --> <h3>Mark Message As Read</h3> <p>This function will Mark a message as read.</p> <blockquote> <ul> <li>Args: <ul> <li>msgId (int | str): Message ID to set as delivered</li> <li>cliMsgId (int | str): Client message ID</li> <li>senderId (int | str): Message sender Id</li> <li>thread_id (int | str): User/Group ID to mark as read</li> <li>thread_type (ThreadType): <code>ThreadType.USER</code>, <code>ThreadType.GROUP</code></li> </ul></li> </ul> </blockquote> <details> <summary><b><i>Normal</b> code style</i></summary> - Outside Module Function ```py bot.markAsRead(<msgId>, <cliMsgId>, <senderId>, <thread_id>, <thread_type>) ``` </br> - Inside Module Function ```py self.markAsRead(<msgId>, <cliMsgId>, <senderId>, <thread_id>, <thread_type>) ``` </details> <details> <summary><b><i>Async</b> code style</i></summary> - Outside Module Function ```py asyncio.run(bot.markAsRead(<msgId>, <cliMsgId>, <senderId>, <thread_id>, <thread_type>)) ``` </br> - Inside Module Function (You can use ``await`` instead.) ```py await self.markAsRead(<msgId>, <cliMsgId>, <senderId>, <thread_id>, <thread_type>) ``` </details> <details> <summary><b><i>Simple</b> code style</i></summary> - Outside Module Function ```py asyncio.run(bot.mark_as_read(<msgId>, <cliMsgId>, <senderId>, <thread_id>, <thread_type>)) ``` </br> - Inside Module Function (You can use ``await`` instead.) ```py await bot.mark_as_read(<msgId>, <cliMsgId>, <senderId>, <thread_id>, <thread_type>) ``` </details> <!-- END markAsRead --> <p></br></p> <!-- listen --> <h3>Listen</h3> <p>This function will Initialize and runs the listening loop continually.</p> <blockquote> <ul> <li>Args: <ul> <li>delay (int): Delay time for each message fetch for <code>requests</code> type (Default: 1)</li> <li>thread (bool): Handle messages within the thread for <code>requests</code> type (Default: False)</li> <li>type (str): Type of listening (Default: websocket)</li> <li>reconnect (int): Delay interval when reconnecting</li> </ul></li> </ul> </blockquote> <ul> <li>Use Outside Of Function</li> </ul> <pre><code class="language-py">bot.listen()</code></pre> <!-- END listen --> <p></br></p> <!-- onListening --> <h3>On Listening</h3> <p>This function is called when the client is listening.</p> <details> <summary><b><i>Normal</b> code style</i></summary> - Inside Module Custom Class ```py def onListening(self): .... ``` </details> <details> <summary><b><i>Async</b> code style</i></summary> - Inside Module Custom Class ```py async def onListening(self): .... ``` </details> <details> <summary><b><i>Simple</b> code style</i></summary> - Outside Module Class ```py @bot.event async def on_listening(): .... ``` </details> <!-- END onListening --> <p></br></p> <!-- onMessage --> <h3>On Message</h3> <p>This function is called when the client is listening, and somebody sends a message.</p> <blockquote> <ul> <li>Args: <ul> <li>mid: The message ID</li> <li>author_id: The ID of the author</li> <li>message: The message content of the author</li> <li>message_object: The message (As a <code>Message</code> object)</li> <li>thread_id: Thread ID that the message was sent to.</li> <li>thread_type (ThreadType): Type of thread that the message was sent to.</li> </ul></li> </ul> </blockquote> <details> <summary><b><i>Normal</b> code style</i></summary> - Inside Module Custom Class ```py def onMessage(self, mid, author_id, message, message_object, thread_id, thread_type): .... ``` </details> <details> <summary><b><i>Async</b> code style</i></summary> - Inside Module Custom Class ```py async def onMessage(self, mid, author_id, message, message_object, thread_id, thread_type): .... ``` </details> <details> <summary><b><i>Simple</b> code style</i></summary> > - In simple type, all event or register_handler functions use args with context. > > - Args Context Example: > - ctx.message_id > - ctx.author_id > - ctx.message > - ctx.message_object > - ctx.thread_id > - ctx.thread_type - Outside Module Class ```py @bot.event async def on_message(ctx): .... ``` </details> <!-- END onMessage --> <p></br></p> <!-- onEvent --> <h3>On Event</h3> <p>This function is called when the client listening, and some events occurred.</p> <blockquote> <ul> <li>Args: <ul> <li>event_data (EventObject): Event data (As a <code>EventObject</code> object)</li> <li>event_type (EventType/GroupEventType): Event Type</li> </ul></li> </ul> </blockquote> <details> <summary><b><i>Normal</b> code style</i></summary> - Inside Module Custom Class ```py def onEvent(self, event_data, event_type): .... ``` </details> <details> <summary><b><i>Async</b> code style</i></summary> - Inside Module Custom Class ```py async def onEvent(self, event_data, event_type): .... ``` </details> <details> <summary><b><i>Simple</b> code style</i></summary> > - In simple type, all event or register_handler functions use args with context. > > - Args Context Example: > - ctx.event_data > - ctx.event_type - Outside Module Class ```py @bot.event async def on_event(ctx): .... ``` </details> <!-- END onEvent --> <p></br></p> <!-- Messages --> <h3>Messages</h3> <p>Represents a Zalo message.</p> <blockquote> <ul> <li>Args: <ul> <li>text (str): The actual message</li> <li>style (MessageStyle/MultiMsgStyle): A <code>MessageStyle</code> or <code>MultiMsgStyle</code> objects</li> <li>mention (Mention/MultiMention): A <code>Mention</code> or <code>MultiMention</code> objects</li> <li>parse_mode (str): Format messages in <code>Markdown</code>, <code>HTML</code> style</li> </ul></li> </ul> </blockquote> <pre><code class="language-py">Message(text=<text>, mention=<mention>, style=<style>)</code></pre> <!-- END Messages --> <p></br></p> <!-- MessageStyle --> <h3>Message Style</h3> <p>Style for message.</p> <blockquote> <ul> <li>Args: <ul> <li>offset (int): The starting position of the style. Defaults to 0.</li> <li>length (int): The length of the style. Defaults to 1.</li> <li>style (str): The type of style. Can be "font", "bold", "italic", "underline", "strike", or "color". Defaults to "font".</li> <li>color (str): The color of the style in hexadecimal format (e.g. "ffffff"). Only applicable when style is "color". Defaults to "ffffff".</li> <li>size (int | str): The font size of the style. Only applicable when style is "font". Defaults to "18".</li> <li>auto_format (bool): If there are multiple styles (used in <code>MultiMsgStyle</code>) then set it to False. Default is True (1 style)</li> </ul></li> </ul> </blockquote> <ul> <li> <p>Example</p> <ul> <li><strong>bold</strong> style with offset is 5, length is 10.</li> </ul> <pre><code class="language-py">style = MessageStyle(offset=5, length=10, style="bold") ...</code></pre> <p></br></p> <ul> <li>color style with offset is 10, length is 5 and color="<img referrerpolicy="no-referrer" src="https://placehold.co/20x15/ff0000/ff0000.png" alt="#ff0000" /> <code>#ff0000</code>"</li> </ul> <pre><code class="language-py">style = MessageStyle(offset=10, ``length=5``, style="color", color="ff0000") ...</code></pre> <p></br></p> <ul> <li>font style with offset is 15, length is 8 and size="24" (Customize font size to 24)</li> </ul> <pre><code class="language-py">style = MessageStyle(offset=15, length=8, style="font", size="24") ...</code></pre> </li> </ul> <!-- END MessageStyle --> <p></br></p> <!-- MultiMsgStyle --> <h3>Multiple Message Style</h3> <p>Multiple style for message.</p> <blockquote> <ul> <li>Args: <ul> <li>listStyle (MessageStyle): A list of <code>MessageStyle</code> objects to be combined into a single style format.</li> </ul></li> </ul> </blockquote> <pre><code class="language-py">style = MultiMsgStyle([ MessageStyle(offset=<text>, length=<mention>, style=<style>, color=<color>, size=<size>, auto_format=False), MessageStyle(offset=<text>, length=<mention>, style=<style>, color=<color>, size=<size>, auto_format=False), ... ])</code></pre> <!-- END MultiMsgStyle --> <p></br></p> <!-- Mention --> <h3>Mention</h3> <p>Represents a @mention.</p> <blockquote> <ul> <li>Args: <ul> <li>uid (str): The user ID to be mentioned.</li> <li>length (int): The length of the mention. Defaults to 1.</li> <li>offset (int): The starting position of the mention. Defaults to 0.</li> <li>auto_format (bool): If there are multiple mention (used in <code>MultiMention</code>) then set it to False. Default is True (1 mention).</li> </ul></li> </ul> </blockquote> <pre><code class="language-py">mention = Mention(uid=<uid>, length=<length>, offset=<offset>) ...</code></pre> <p></br></p> <ul> <li>Mention user id <em>1234567890</em> with offset is 10 and length is 5.</li> </ul> <pre><code class="language-py">mention = Mention("1234567890", length=5, offset=10) ...</code></pre> <!-- END Mention --> <p></br></p> <!-- MultiMention --> <h3>Multiple Mention</h3> <p>Represents multiple @mentions.</p> <blockquote> <ul> <li>Args: <ul> <li>listMention (Mention): A list of <code>Mention</code> objects to be combined into a single mention format.</li> </ul></li> </ul> </blockquote> <pre><code class="language-py">mention = MultiMention([ Mention(uid=<uid>, length=<length>, offset=<offset>, auto_format=False), Mention(uid=<uid>, length=<length>, offset=<offset>, auto_format=False), ... ])</code></pre> <p></br></p> <ul> <li>Mention user id <em>1234567890</em> with offset is 10 and length is 5.</li> <li>Mention user id <em>9876543210</em> with offset is 20 and length is 3.</li> </ul> <pre><code class="language-py">mention1 = Mention("1234567890", length=5, offset=10) mention2 = Mention("9876543210", length=3, offset=20) mention = MultiMention([mention1, mention2])</code></pre> <!-- END MultiMention --> <p></br></p> <h2>Example</h2> <p>See <a rel="noreferrer nofollow" target="_blank" href="https://github.com/Its-VrxxDev/zlapi/blob/master/examples">examples</a> folder to learn more about <code>zlapi</code>.</p> <p></br></p> <h2>Acknowledgments</h2> <ul> <li> <p>This project was originally inspired by <a rel="noreferrer nofollow" target="_blank" href="https://github.com/fbchat-dev/fbchat">fbchat</a>.</p> </li> <li> <p>listen <code>websocket</code> type taken from <a rel="noreferrer nofollow" target="_blank" href="https://github.com/RFS-ADRENO/zca-js">zca-js</a>.</p> </li> <li> <p>Thanks for support:</p> <ul> <li><a rel="noreferrer nofollow" target="_blank" href="https://t.me/crowmatacc">Crow</a> for Hosting.</li> <li><a rel="noreferrer nofollow" target="_blank" href="https://t.me/Tcp_API">Duy Hoang</a> for the Video Tutorial.</li> <li><a rel="noreferrer nofollow" target="_blank" href="https://t.me/ducknha">Nguyen Hong Anh Duc</a> for the Example.</li> <li><a rel="noreferrer nofollow" target="_blank" href="https://www.facebook.com/khang.phan27.info">Khang Phan</a> for help fix the <code>listen</code> function error.</li> </ul> </li> </ul> <h2>Contact For Help</h2> <ul> <li><img referrerpolicy="no-referrer" src="https://upload.wikimedia.org/wikipedia/commons/8/83/Telegram_2019_Logo.svg" alt="Telegram Icon" width=20 height=15/> Telegram: <a rel="noreferrer nofollow" target="_blank" href="https://t.me/vrxx1337">Vexx</a></li> <li><img referrerpolicy="no-referrer" src="https://raw.githubusercontent.com/dheereshagrwal/colored-icons/master/public/logos/facebook/facebook.svg" alt="Facebook Icon" width=20 height=15/> Facebook: <a rel="noreferrer nofollow" target="_blank" href="https://www.facebook.com/profile.php?id=100094031375075">Lê Quốc Việt</a></li> </ul></div> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>