### Install Dependencies Source: https://github.com/xfgryujk/blivedm/blob/dev/README.md Install the required Python packages for blivedm using pip. ```sh pip install -r requirements.txt ``` -------------------------------- ### OpenLiveClient - Open Platform API Example Source: https://context7.com/xfgryujk/blivedm/llms.txt Connects to a Bilibili live room using the official Open Platform API. Requires developer keys, app ID, and an anchor authorization code. Supports a wider range of events including likes, room entry, and live start/end. ```python import asyncio import blivedm import blivedm.models.open_live as open_models import blivedm.models.web as web_models # 开放平台配置 ACCESS_KEY_ID = 'your_access_key_id' ACCESS_KEY_SECRET = 'your_access_key_secret' APP_ID = 1234567890 # 项目ID ROOM_OWNER_AUTH_CODE = 'anchor_auth_code' # 主播身份码 class MyHandler(blivedm.BaseHandler): def _on_heartbeat(self, client: blivedm.BLiveClient, message: web_models.HeartbeatMessage): print(f'[{client.room_id}] 心跳') def _on_open_live_danmaku(self, client: blivedm.OpenLiveClient, message: open_models.DanmakuMessage): print(f'[{message.room_id}] {message.uname}:{message.msg}') def _on_open_live_gift(self, client: blivedm.OpenLiveClient, message: open_models.GiftMessage): coin_type = '金瓜子' if message.paid else '银瓜子' total_coin = message.price * message.gift_num print(f'[{message.room_id}] {message.uname} 赠送{message.gift_name}x{message.gift_num}' f' ({coin_type}x{total_coin})') def _on_open_live_buy_guard(self, client: blivedm.OpenLiveClient, message: open_models.GuardBuyMessage): print(f'[{message.room_id}] {message.user_info.uname} 购买 大航海等级={message.guard_level}') def _on_open_live_super_chat(self, client: blivedm.OpenLiveClient, message: open_models.SuperChatMessage): print(f'[{message.room_id}] 醒目留言 ¥{message.rmb} {message.uname}:{message.message}') def _on_open_live_like(self, client: blivedm.OpenLiveClient, message: open_models.LikeMessage): print(f'[{message.room_id}] {message.uname} 点赞') def _on_open_live_enter_room(self, client: blivedm.OpenLiveClient, message: open_models.RoomEnterMessage): print(f'[{message.room_id}] {message.uname} 进入房间') def _on_open_live_start_live(self, client: blivedm.OpenLiveClient, message: open_models.LiveStartMessage): print(f'[{message.room_id}] 开始直播') def _on_open_live_end_live(self, client: blivedm.OpenLiveClient, message: open_models.LiveEndMessage): print(f'[{message.room_id}] 结束直播') async def main(): client = blivedm.OpenLiveClient( access_key_id=ACCESS_KEY_ID, access_key_secret=ACCESS_KEY_SECRET, app_id=APP_ID, room_owner_auth_code=ROOM_OWNER_AUTH_CODE, ) client.set_handler(MyHandler()) client.start() try: await client.join() finally: await client.stop_and_close() asyncio.run(main()) ``` -------------------------------- ### BLiveClient - Web Interface Example Source: https://context7.com/xfgryujk/blivedm/llms.txt Connects to a Bilibili live room using the web interface to receive danmaku and interaction messages. Optionally uses logged-in user cookies for full user information. Requires aiohttp and blivedm libraries. ```python import asyncio import http.cookies import aiohttp import blivedm import blivedm.models.web as web_models # 配置 session(可选:添加登录cookie以获取完整用户信息) cookies = http.cookies.SimpleCookie() cookies['SESSDATA'] = 'your_sessdata_here' # 从浏览器获取 cookies['SESSDATA']['domain'] = 'bilibili.com' session = aiohttp.ClientSession() session.cookie_jar.update_cookies(cookies) # 创建处理器 class MyHandler(blivedm.BaseHandler): def _on_heartbeat(self, client: blivedm.BLiveClient, message: web_models.HeartbeatMessage): print(f'[{client.room_id}] 心跳') def _on_danmaku(self, client: blivedm.BLiveClient, message: web_models.DanmakuMessage): print(f'[{client.room_id}] {message.uname}:{message.msg}') def _on_gift(self, client: blivedm.BLiveClient, message: web_models.GiftMessage): print(f'[{client.room_id}] {message.uname} 赠送{message.gift_name}x{message.num}' f' ({message.coin_type}瓜子x{message.total_coin})') def _on_super_chat(self, client: blivedm.BLiveClient, message: web_models.SuperChatMessage): print(f'[{client.room_id}] 醒目留言 ¥{message.price} {message.uname}:{message.message}') def _on_user_toast_v2(self, client: blivedm.BLiveClient, message: web_models.UserToastV2Message): if message.source != 2: # 过滤赠送消息 print(f'[{client.room_id}] {message.username} 上舰,guard_level={message.guard_level}') async def main(): room_id = 12235923 # 直播间ID(可用短ID) client = blivedm.BLiveClient(room_id, session=session) client.set_handler(MyHandler()) client.start() try: await asyncio.sleep(60) # 运行60秒 client.stop() await client.join() finally: await client.stop_and_close() await session.close() asyncio.run(main()) ``` -------------------------------- ### Configure Linear Retry Policy Source: https://context7.com/xfgryujk/blivedm/llms.txt Sets a retry policy that starts at 1 second, increases by 0.5 seconds each time, up to a maximum of 5 seconds. ```python linear_policy = utils.make_linear_retry_policy( start_interval=1, interval_step=0.5, max_interval=5 ) ``` -------------------------------- ### Monitor Multiple Live Rooms Source: https://context7.com/xfgryujk/blivedm/llms.txt Demonstrates creating multiple client instances to monitor different rooms while sharing a single session and handler. ```python import asyncio import aiohttp import blivedm import blivedm.models.web as web_models class MyHandler(blivedm.BaseHandler): def _on_danmaku(self, client: blivedm.BLiveClient, message: web_models.DanmakuMessage): print(f'[{client.room_id}] {message.uname}:{message.msg}') async def main(): session = aiohttp.ClientSession() room_ids = [12235923, 14327465, 21396545] # 创建多个客户端 clients = [blivedm.BLiveClient(room_id, session=session) for room_id in room_ids] handler = MyHandler() # 设置处理器并启动 for client in clients: client.set_handler(handler) client.start() try: # 等待所有客户端完成 await asyncio.gather(*(client.join() for client in clients)) finally: await asyncio.gather(*(client.stop_and_close() for client in clients)) await session.close() asyncio.run(main()) ``` -------------------------------- ### Simultaneously Listen to Multiple Live Rooms Source: https://context7.com/xfgryujk/blivedm/llms.txt Demonstrates how to create multiple BLiveClient instances to monitor different live rooms concurrently. It shows how to share a common handler and session across these clients for efficiency. ```APIDOC ## Simultaneously Listen to Multiple Live Rooms Supports creating multiple client instances to listen to different live rooms simultaneously. All clients can share the same handler and session. ### Code Example ```python import asyncio import aiohttp import blivedm import blivedm.models.web as web_models class MyHandler(blivedm.BaseHandler): def _on_danmaku(self, client: blivedm.BLiveClient, message: web_models.DanmakuMessage): print(f'[{client.room_id}] {message.uname}:{message.msg}') async def main(): session = aiohttp.ClientSession() room_ids = [12235923, 14327465, 21396545] # Create multiple clients clients = [blivedm.BLiveClient(room_id, session=session) for room_id in room_ids] handler = MyHandler() # Set handler and start clients for client in clients: client.set_handler(handler) client.start() try: # Wait for all clients to complete await asyncio.gather(*(client.join() for client in clients)) finally: await asyncio.gather(*(client.stop_and_close() for client in clients)) await session.close() asyncio.run(main()) ``` ``` -------------------------------- ### Configure Reconnection Strategy Source: https://context7.com/xfgryujk/blivedm/llms.txt Initializes the reconnection utility module for defining custom reconnection intervals. ```python import blivedm from blivedm import utils ``` -------------------------------- ### blivedm Integration Options Source: https://context7.com/xfgryujk/blivedm/llms.txt Explains the two main integration methods for the blivedm library: Web API and Open Platform API. ```APIDOC ## blivedm Integration Options ### Description The blivedm library can be integrated using either Web API or Open Platform API, each suited for different development needs. ### Web API - **Description**: Simple configuration, suitable for personal projects and rapid prototyping. - **Use Cases**: Real-time danmaku display, basic interaction information. ### Open Platform API - **Description**: More comprehensive features, suitable for formal commercial applications. - **Features**: Includes additional events like liking, entering rooms, and broadcasting status changes (start/end). - **Use Cases**: Advanced data analysis, automation tools, interactive applications. ### Handler Base Class Both Web API and Open Platform API can utilize the same Handler base class, facilitating easy switching or migration between interfaces. ``` -------------------------------- ### Add Custom Message Callbacks Source: https://context7.com/xfgryujk/blivedm/llms.txt Shows how to extend the _CMD_CALLBACK_DICT to handle message types not natively supported by the library. ```python import blivedm class MyHandler(blivedm.BaseHandler): # 复制基类的回调字典 _CMD_CALLBACK_DICT = blivedm.BaseHandler._CMD_CALLBACK_DICT.copy() # 添加自定义回调处理 WATCHED_CHANGE 消息 def __watched_change_callback(self, client: blivedm.BLiveClient, command: dict): print(f'[{client.room_id}] WATCHED_CHANGE: {command}') # 注册回调 _CMD_CALLBACK_DICT['WATCHED_CHANGE'] = __watched_change_callback ``` -------------------------------- ### Implement BaseHandler Message Callbacks Source: https://context7.com/xfgryujk/blivedm/llms.txt Provides a template for overriding callback methods in BaseHandler to process various Web and Open Platform live stream events. ```python import blivedm import blivedm.models.web as web_models import blivedm.models.open_live as open_models class MyHandler(blivedm.BaseHandler): # ========== Web端消息回调 ========== def _on_heartbeat(self, client: blivedm.BLiveClient, message: web_models.HeartbeatMessage): """收到心跳包""" pass def _on_danmaku(self, client: blivedm.BLiveClient, message: web_models.DanmakuMessage): """弹幕消息""" # message.uid - 用户ID # message.uname - 用户名 # message.msg - 弹幕内容 # message.dm_type - 弹幕类型(0文本,1表情,2语音) # message.medal_name - 勋章名 # message.medal_level - 勋章等级 # message.privilege_type - 舰队类型(0非舰队,1总督,2提督,3舰长) pass def _on_gift(self, client: blivedm.BLiveClient, message: web_models.GiftMessage): """礼物消息""" # message.gift_name - 礼物名 # message.num - 数量 # message.coin_type - 瓜子类型(silver/gold) # message.total_coin - 总瓜子数 pass def _on_buy_guard(self, client: blivedm.BLiveClient, message: web_models.GuardBuyMessage): """上舰消息""" # message.guard_level - 舰队等级(1总督,2提督,3舰长) pass def _on_user_toast_v2(self, client: blivedm.BLiveClient, message: web_models.UserToastV2Message): """另一个上舰消息(数据更完整)""" # message.source - 0付费购买,2赠送 pass def _on_super_chat(self, client: blivedm.BLiveClient, message: web_models.SuperChatMessage): """醒目留言""" # message.price - 价格(人民币) # message.message - 留言内容 # message.id - 醒目留言ID pass def _on_super_chat_delete(self, client: blivedm.BLiveClient, message: web_models.SuperChatDeleteMessage): """删除醒目留言""" # message.ids - 被删除的醒目留言ID数组 pass def _on_interact_word_v2(self, client: blivedm.BLiveClient, message: web_models.InteractWordV2Message): """进入房间、关注等互动消息""" # message.msg_type - 1进入,2关注,3分享,4特别关注,5互粉,6点赞 pass # ========== 开放平台消息回调 ========== def _on_open_live_danmaku(self, client: blivedm.OpenLiveClient, message: open_models.DanmakuMessage): """开放平台弹幕""" pass def _on_open_live_gift(self, client: blivedm.OpenLiveClient, message: open_models.GiftMessage): """开放平台礼物""" # message.paid - 是否付费礼物 # message.r_price - 实际价值 pass def _on_open_live_buy_guard(self, client: blivedm.OpenLiveClient, message: open_models.GuardBuyMessage): """开放平台上舰""" pass def _on_open_live_super_chat(self, client: blivedm.OpenLiveClient, message: open_models.SuperChatMessage): """开放平台醒目留言""" # message.rmb - 价格(元) pass def _on_open_live_like(self, client: blivedm.OpenLiveClient, message: open_models.LikeMessage): """点赞消息(仅开放平台)""" # message.like_count - 2秒内点赞次数聚合 pass def _on_open_live_enter_room(self, client: blivedm.OpenLiveClient, message: open_models.RoomEnterMessage): """进入房间(仅开放平台)""" pass def _on_open_live_start_live(self, client: blivedm.OpenLiveClient, message: open_models.LiveStartMessage): """开始直播(仅开放平台)""" # message.area_name - 分区名 # message.title - 直播间标题 pass def _on_open_live_end_live(self, client: blivedm.OpenLiveClient, message: open_models.LiveEndMessage): """结束直播(仅开放平台)""" pass ``` -------------------------------- ### Add Custom Message Callbacks Source: https://context7.com/xfgryujk/blivedm/llms.txt Explains how to extend the `_CMD_CALLBACK_DICT` to handle message types not natively supported by the library. This allows for custom processing of specific commands. ```APIDOC ## Add Custom Message Callbacks By extending `_CMD_CALLBACK_DICT`, you can handle message types not built into the library. ### Code Example ```python import blivedm class MyHandler(blivedm.BaseHandler): # Copy the base class's callback dictionary _CMD_CALLBACK_DICT = blivedm.BaseHandler._CMD_CALLBACK_DICT.copy() # Add a custom callback for WATCHED_CHANGE messages def __watched_change_callback(self, client: blivedm.BLiveClient, command: dict): print(f'[{client.room_id}] WATCHED_CHANGE: {command}') # Register the callback _CMD_CALLBACK_DICT['WATCHED_CHANGE'] = __watched_change_callback ``` ``` -------------------------------- ### Set Reconnect Policy for BLiveClient Source: https://context7.com/xfgryujk/blivedm/llms.txt Applies a configured retry policy to the BLiveClient instance. ```python client = blivedm.BLiveClient(room_id=12235923) client.set_reconnect_policy(linear_policy) ``` -------------------------------- ### Configure Constant Retry Policy Source: https://context7.com/xfgryujk/blivedm/llms.txt Sets a fixed 2-second interval for reconnections. ```python constant_policy = utils.make_constant_retry_policy(interval=2) ``` -------------------------------- ### Set Reconnection Strategy Source: https://context7.com/xfgryujk/blivedm/llms.txt Details how to customize the reconnection interval strategy after a disconnection. Supports constant interval and linear increasing interval modes. ```APIDOC ## Set Reconnection Strategy You can customize the disconnection reconnection interval strategy, supporting constant interval and linear increasing interval modes. ### Code Example ```python import blivedm from blivedm import utils ``` ``` -------------------------------- ### Handle Client Stop Event Source: https://context7.com/xfgryujk/blivedm/llms.txt Implement the on_client_stopped method to execute custom logic when the client stops, such as automatic restarts or error handling. This method is called with the client instance and an optional exception object. ```python import asyncio from typing import Optional import blivedm class MyHandler(blivedm.BaseHandler): def on_client_stopped(self, client: blivedm.BLiveClient, exception: Optional[Exception]): """客户端停止时调用,可以在这里重新启动或处理异常""" if exception is not None: print(f'[{client.room_id}] 客户端异常停止: {exception}') # 可以在这里重新启动客户端 # client.start() else: print(f'[{client.room_id}] 客户端正常停止') ``` -------------------------------- ### Combo Gift Information Source: https://context7.com/xfgryujk/blivedm/llms.txt This section details the structure for combo gift information received from the blivedm library. ```APIDOC ## Combo Gift Information ### Description Provides details about combo gifts, including whether a gift is part of a combo, the combo count, the base number for each combo, and the timeout duration for combos. ### Fields - **message.combo_gift** (boolean) - Indicates if the gift is a combo gift. - **message.combo_info.combo_count** (integer) - The number of times the gift has been comboed. - **message.combo_info.combo_base_num** (integer) - The quantity of gifts in each combo. - **message.combo_info.combo_timeout** (integer) - The duration in seconds for which the combo is valid. ``` -------------------------------- ### BaseHandler - Message Handler Base Class Source: https://context7.com/xfgryujk/blivedm/llms.txt Explains the BaseHandler class, which provides message dispatching and type conversion. Users can inherit from this class and override callback methods to handle various types of messages. ```APIDOC ## BaseHandler - Message Handler Base Class BaseHandler provides message dispatching and type conversion functionality. Inherit from it and override the corresponding callback methods to handle various types of messages. ### Web Message Callbacks - `_on_heartbeat(self, client: blivedm.BLiveClient, message: web_models.HeartbeatMessage)`: Called when a heartbeat packet is received. - `_on_danmaku(self, client: blivedm.BLiveClient, message: web_models.DanmakuMessage)`: Handles danmaku (bullet comment) messages. - `message.uid`: User ID - `message.uname`: Username - `message.msg`: Danmaku content - `message.dm_type`: Danmaku type (0 text, 1 emoji, 2 voice) - `message.medal_name`: Medal name - `message.medal_level`: Medal level - `message.privilege_type`: Guard type (0 none, 1 Admiral, 2 Commander, 3 Captain) - `_on_gift(self, client: blivedm.BLiveClient, message: web_models.GiftMessage)`: Handles gift messages. - `message.gift_name`: Gift name - `message.num`: Quantity - `message.coin_type`: Coin type (silver/gold) - `message.total_coin`: Total coins - `_on_buy_guard(self, client: blivedm.BLiveClient, message: web_models.GuardBuyMessage)`: Handles guard purchase messages. - `message.guard_level`: Guard level (1 Admiral, 2 Commander, 3 Captain) - `_on_user_toast_v2(self, client: blivedm.BLiveClient, message: web_models.UserToastV2Message)`: Handles another type of guard purchase message with more complete data. - `message.source`: 0 paid purchase, 2 gifted - `_on_super_chat(self, client: blivedm.BLiveClient, message: web_models.SuperChatMessage)`: Handles super chat messages. - `message.price`: Price (in RMB) - `message.message`: Chat message content - `message.id`: Super chat ID - `_on_super_chat_delete(self, client: blivedm.BLiveClient, message: web_models.SuperChatDeleteMessage)`: Handles deletion of super chat messages. - `message.ids`: Array of deleted super chat IDs - `_on_interact_word_v2(self, client: blivedm.BLiveClient, message: web_models.InteractWordV2Message)`: Handles interaction messages like room entry and follows. - `message.msg_type`: 1 enter, 2 follow, 3 share, 4 special follow, 5 mutual follow, 6 like ### Open Live Platform Message Callbacks - `_on_open_live_danmaku(self, client: blivedm.OpenLiveClient, message: open_models.DanmakuMessage)`: Handles danmaku messages from the Open Live platform. - `_on_open_live_gift(self, client: blivedm.OpenLiveClient, message: open_models.GiftMessage)`: Handles gift messages from the Open Live platform. - `message.paid`: Whether the gift is paid - `message.r_price`: Actual value - `_on_open_live_buy_guard(self, client: blivedm.OpenLiveClient, message: open_models.GuardBuyMessage)`: Handles guard purchase messages from the Open Live platform. - `_on_open_live_super_chat(self, client: blivedm.OpenLiveClient, message: open_models.SuperChatMessage)`: Handles super chat messages from the Open Live platform. - `message.rmb`: Price (in Yuan) - `_on_open_live_like(self, client: blivedm.OpenLiveClient, message: open_models.LikeMessage)`: Handles like messages (Open Live platform only). - `message.like_count`: Aggregated like count within 2 seconds - `_on_open_live_enter_room(self, client: blivedm.OpenLiveClient, message: open_models.RoomEnterMessage)`: Handles room entry messages (Open Live platform only). - `_on_open_live_start_live(self, client: blivedm.OpenLiveClient, message: open_models.LiveStartMessage)`: Handles live start messages (Open Live platform only). - `message.area_name`: Area name - `message.title`: Live room title - `_on_open_live_end_live(self, client: blivedm.OpenLiveClient, message: open_models.LiveEndMessage)`: Handles live end messages (Open Live platform only). ### Code Example ```python import blivedm import blivedm.models.web as web_models import blivedm.models.open_live as open_models class MyHandler(blivedm.BaseHandler): # ========== Web端消息回调 ========== def _on_heartbeat(self, client: blivedm.BLiveClient, message: web_models.HeartbeatMessage): """收到心跳包""" pass def _on_danmaku(self, client: blivedm.BLiveClient, message: web_models.DanmakuMessage): """弹幕消息""" # message.uid - 用户ID # message.uname - 用户名 # message.msg - 弹幕内容 # message.dm_type - 弹幕类型(0文本,1表情,2语音) # message.medal_name - 勋章名 # message.medal_level - 勋章等级 # message.privilege_type - 舰队类型(0非舰队,1总督,2提督,3舰长) pass def _on_gift(self, client: blivedm.BLiveClient, message: web_models.GiftMessage): """礼物消息""" # message.gift_name - 礼物名 # message.num - 数量 # message.coin_type - 瓜子类型(silver/gold) # message.total_coin - 总瓜子数 pass def _on_buy_guard(self, client: blivedm.BLiveClient, message: web_models.GuardBuyMessage): """上舰消息""" # message.guard_level - 舰队等级(1总督,2提督,3舰长) pass def _on_user_toast_v2(self, client: blivedm.BLiveClient, message: web_models.UserToastV2Message): """另一个上舰消息(数据更完整)""" # message.source - 0付费购买,2赠送 pass def _on_super_chat(self, client: blivedm.BLiveClient, message: web_models.SuperChatMessage): """醒目留言""" # message.price - 价格(人民币) # message.message - 留言内容 # message.id - 醒目留言ID pass def _on_super_chat_delete(self, client: blivedm.BLiveClient, message: web_models.SuperChatDeleteMessage): """删除醒目留言""" # message.ids - 被删除的醒目留言ID数组 pass def _on_interact_word_v2(self, client: blivedm.BLiveClient, message: web_models.InteractWordV2Message): """进入房间、关注等互动消息""" # message.msg_type - 1进入,2关注,3分享,4特别关注,5互粉,6点赞 pass # ========== 开放平台消息回调 ========== def _on_open_live_danmaku(self, client: blivedm.OpenLiveClient, message: open_models.DanmakuMessage): """开放平台弹幕""" pass def _on_open_live_gift(self, client: blivedm.OpenLiveClient, message: open_models.GiftMessage): """开放平台礼物""" # message.paid - 是否付费礼物 # message.r_price - 实际价值 pass def _on_open_live_buy_guard(self, client: blivedm.OpenLiveClient, message: open_models.GuardBuyMessage): """开放平台上舰""" pass def _on_open_live_super_chat(self, client: blivedm.OpenLiveClient, message: open_models.SuperChatMessage): """开放平台醒目留言""" # message.rmb - 价格(元) pass def _on_open_live_like(self, client: blivedm.OpenLiveClient, message: open_models.LikeMessage): """点赞消息(仅开放平台)""" # message.like_count - 2秒内点赞次数聚合 pass def _on_open_live_enter_room(self, client: blivedm.OpenLiveClient, message: open_models.RoomEnterMessage): """进入房间(仅开放平台)""" pass def _on_open_live_start_live(self, client: blivedm.OpenLiveClient, message: open_models.LiveStartMessage): """开始直播(仅开放平台)""" # message.area_name - 分区名 # message.title - 直播间标题 pass def _on_open_live_end_live(self, client: blivedm.OpenLiveClient, message: open_models.LiveEndMessage): """结束直播(仅开放平台)""" pass ``` ``` -------------------------------- ### Open Platform DanmakuMessage Model Fields Source: https://context7.com/xfgryujk/blivedm/llms.txt Details the fields for DanmakuMessage in the Open Platform API, using open_id as the unique user identifier. Includes message content, user info, room details, and @ functionality. ```python import blivedm.models.open_live as open_models message: open_models.DanmakuMessage # 基本信息 message.msg # 弹幕内容 message.open_id # 用户唯一标识 message.uname # 用户昵称 message.uface # 用户头像 message.room_id # 直播间ID message.timestamp # 时间戳(秒) message.msg_id # 消息唯一ID # 弹幕属性 message.dm_type # 弹幕类型(0普通,1表情包) message.emoji_img_url # 表情包图片地址 message.is_admin # 是否房管 message.is_mirror # 是否跨房弹幕 # 勋章信息 message.fans_medal_name # 粉丝勋章名 message.fans_medal_level # 粉丝勋章等级 message.fans_medal_wearing_status # 是否佩戴勋章 message.guard_level # 大航海等级 message.glory_level # 直播荣耀等级 # @功能 message.reply_open_id # 被@用户的open_id message.reply_uname # 被@用户的昵称 ``` -------------------------------- ### Web SuperChatMessage Model Fields Source: https://context7.com/xfgryujk/blivedm/llms.txt Details the fields available in the SuperChatMessage model for web clients, including message content, price, sender information, and styling. Covers message ID, translation, price, sender details, and background colors. ```python import blivedm.models.web as web_models message: web_models.SuperChatMessage # 留言信息 message.id # 醒目留言ID message.message # 留言内容 message.message_trans # 日文翻译 message.price # 价格(人民币) message.time # 剩余时间 message.start_time # 开始时间戳 message.end_time # 结束时间戳 # 用户信息 message.uid # 用户ID message.uname # 用户名 message.face # 用户头像URL message.guard_level # 舰队等级 message.user_level # 用户等级 # 样式信息 message.background_color # 背景色 message.background_bottom_color # 底部背景色 message.background_image # 背景图URL message.background_price_color # 价格颜色 ``` -------------------------------- ### Open Platform GiftMessage Model Fields Source: https://context7.com/xfgryujk/blivedm/llms.txt Details the fields for GiftMessage in the Open Platform API, including gift specifics, sender information, and anchor details. Covers gift ID, name, quantity, price, sender's open_id, and anchor's information. ```python import blivedm.models.open_live as open_models message: open_models.GiftMessage # 礼物信息 message.gift_id # 礼物ID message.gift_name # 礼物名 message.gift_num # 赠送数量 message.gift_icon # 礼物图标URL message.price # 单价(1000=1元=10电池) message.r_price # 实际价值(折扣后) message.paid # 是否付费礼物 # 用户信息 message.open_id # 用户唯一标识 message.uname # 用户昵称 message.uface # 用户头像 # 主播信息 message.anchor_info.uid # 主播UID message.anchor_info.open_id # 主播open_id message.anchor_info.uname # 主播昵称 ``` -------------------------------- ### Web DanmakuMessage Model Fields Source: https://context7.com/xfgryujk/blivedm/llms.txt Details the fields available in the DanmakuMessage model for web clients, including basic information, message attributes, user identity, and medal information. Also covers parameters for emoticons and voice messages. ```python import blivedm.models.web as web_models # DanmakuMessage 主要字段 message: web_models.DanmakuMessage # 基本信息 message.msg # 弹幕内容 message.uid # 用户ID message.uname # 用户名 message.face # 用户头像URL message.timestamp # 时间戳(毫秒) # 弹幕属性 message.mode # 显示模式(滚动、顶部、底部) message.color # 颜色 message.font_size # 字体尺寸 message.dm_type # 弹幕类型(0文本,1表情,2语音) message.is_mirror # 是否跨房弹幕 # 用户身份 message.admin # 是否房管 message.privilege_type # 舰队类型(0非舰队,1总督,2提督,3舰长) message.user_level # 用户等级 message.wealth_level # 荣耀等级 # 勋章信息 message.medal_name # 勋章名 message.medal_level # 勋章等级 message.medal_room_id # 勋章房间ID # 表情和语音 emoticon_dict = message.emoticon_options_dict # 表情参数 voice_dict = message.voice_config_dict # 语音参数 extra_dict = message.extra_dict # 附加参数 ``` -------------------------------- ### Web GiftMessage Model Fields Source: https://context7.com/xfgryujk/blivedm/llms.txt Details the fields available in the GiftMessage model for web clients, including gift information, user details, and medal information. Covers gift name, quantity, price, sender, and icon URL. ```python import blivedm.models.web as web_models message: web_models.GiftMessage # 礼物信息 message.gift_name # 礼物名 message.gift_id # 礼物ID message.num # 数量 message.price # 单价瓜子数 message.total_coin # 总瓜子数 message.coin_type # 瓜子类型('silver'银瓜子/'gold'金瓜子) message.action # 动作('喂食'/'赠送') message.gift_img_basic # 礼物图标URL # 用户信息 message.uid # 用户ID message.uname # 用户名 message.face # 用户头像URL message.guard_level # 舰队等级 # 勋章信息 message.medal_name # 勋章名 message.medal_level # 勋章等级 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.