本文整理汇总了Python中room.Room.history_add方法的典型用法代码示例。如果您正苦于以下问题:Python Room.history_add方法的具体用法?Python Room.history_add怎么用?Python Room.history_add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类room.Room
的用法示例。
在下文中一共展示了Room.history_add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: room_message
# 需要导入模块: from room import Room [as 别名]
# 或者: from room.Room import history_add [as 别名]
def room_message(sock, data):
# logging.info(' room_message data{}: %r', data)
sender = data['sender']
destination = data['destination']
t = time.time()
u = User.find_user_by_sock(sock)
if 'message' in data:
message = data['message']
alias = Room.find_alias_by_room(destination)
r = Room.find_room_by_name(data['destination'])
r.last_message = t
target = data['target'] if 'target' in data else ''
message_id = str(uuid.uuid4())
Room.history_add(sender, destination, message, alias, target, message_id, t)
info = {
"type": "chat",
"payload": {
"command": "room_message",
"dt": t,
"message": message,
"room_id": destination,
"sender": sender,
"alias": alias,
"target": target,
"message_id": message_id
}
}
list_user = Room.find_users_by_room(destination)
send_broadcast(list_user, info, u.resource)
if not sender == "system_info":
sub_list = Room.find_users_instance_by_room(destination, u.networkId)
sub_list.remove({'networkId': u.networkId, 'username': sender})
send_to_parse_multicast(info, sub_list)