Documents

Installation

You may use this script to install danmu:

pip install danmu

Simple uses

The following is a simple demo of how to use danmu.

importtime,sysfromdanmuimportDanMuClientdefpp(msg):print(msg.encode(sys.stdin.encoding,'ignore').decode(sys.stdin.encoding))dmc=DanMuClient('http://www.douyu.com/lslalala')ifnotdmc.isValid():print('Url not valid')@dmc.danmudefdanmu_fn(msg):pp('[%s] %s'%(msg['NickName'],msg['Content']))@dmc.giftdefgift_fn(msg):pp('[%s] sent a gift!'%msg['NickName'])@dmc.otherdefother_fn(msg):pp('Other message received')dmc.start(blockThread=True)

Advanced uses

Set default chat message dealer

Messages are split into three types to be registered: danmu, gift, other.