teams_api.messages.create(room.id,
                                      text='Hello, person who has email ' +
                                      str(email) + ' and sent the message ' +
                                      str(message))
    else:
        print('received none post request, not handled!')


if __name__ == '__main__':

    # Read the configuration that contains the bot access token
    config = read_yaml_data('/opt/config/config.yaml')['hello_bot']
    teams_api = WebexTeamsAPI(access_token=config['teams_access_token'])

    # Get some required NGrok information
    ngrok_url = get_ngrok_url()

    # Define the name of webhook
    webhook_name = 'hello-bot-wb-hook'

    # Find any existing webhooks with this name and if this already exists then delete it
    dev_webhook = find_webhook_by_name(teams_api, webhook_name)
    if dev_webhook:
        delete_webhook(teams_api, dev_webhook)

    # Create a new teams webhook with the name defined above
    create_webhook(teams_api, webhook_name, ngrok_url + '/teamswebhook')

    # Host flask web server on port 5000
    flask_app.run(host='0.0.0.0', port=5000)
예제 #2
0
import eventlet
eventlet.monkey_patch()

import os
from flask import Flask
from flask_socketio import SocketIO, send, emit
from flask_bootstrap import Bootstrap
from flask_sqlalchemy import SQLAlchemy
from config import Config
from celery import Celery
from helpers import get_ngrok_url, make_celery

app = Flask(__name__)
Bootstrap(app)
app.config.from_object(Config)
db = SQLAlchemy(app)
celery = make_celery(app)

socketio = SocketIO(app, message_queue=app.config['CELERY_BROKER_URL'])

from views import *

NGROK_HOST = get_ngrok_url()
if NGROK_HOST:
    app.config['CALLBACK_HOST'] = NGROK_HOST

if __name__ == '__main__':
    socketio.run(app, debug=True)