Example #1
0
def new_message(message_body):
    html_message = to_html(message_body)
    message = Message(author=current_user._get_current_object(), body=html_message, room_id=escape(session['room_id']))
    db.session.add(message)
    db.session.commit()
    emit('new message',
         {'message_html': render_template('chat/_message.html', message=message),
          'message_body': html_message,
          'gravatar': current_user.gravatar,
          'nickname': current_user.nickname,
          'user_id': current_user.id},
         broadcast=True)
Example #2
0
def new_anonymous_message(message_body):
    html_message = to_html(message_body)
    avatar = 'https://www.gravatar.com/avatar?d=mm'
    nickname = 'Anonymous'
    emit('new message', {
        'message_html':
        render_template('chat/_anonymous_message.html',
                        message=html_message,
                        avatar=avatar,
                        nickname=nickname)
    },
         broadcast=True,
         namespace='/anonymous')
Example #3
0
def new_anonymous_message(message_body):
    html_message = to_html(message_body)
    avatar = 'https//www.gravatar.com/avatar?d=mm'
    nickname = '匿名用户'
    emit('new message', {
        'message_html':
        render_template('chat/_anonymous_message.html',
                        message=html_message,
                        avatar=avatar,
                        nickname=nickname),
        'message_body':
        html_message,
        'gravatar':
        avatar,
        'nickname':
        nickname,
        'user_id':
        current_user.id
    },
         broadcast=True,
         namespace='/anonymous')