Ejemplo n.º 1
0
def just_ack(logger, context):
    event_type = context["type"]
    logger.info(f"{event_type} is ignored")


# # Start your app in debug
# if __name__ == "__main__":
#     app.start(port=int(os.environ.get("PORT", 3000)))

# for production

from flask import Flask, request
from slack_bolt.adapter.flask import SlackRequestHandler

flask_app = Flask(__name__)
handler = SlackRequestHandler(app)


@flask_app.route("/slack/events", methods=["POST"])
def slack_events():
    return handler.handle(request)


@flask_app.route("/slack/install", methods=["GET"])
def install():
    return handler.handle(request)


@flask_app.route("/slack/oauth_redirect", methods=["GET"])
def oauth_redirect():
    return handler.handle(request)
Ejemplo n.º 2
0
 def endpoint():
     return SlackRequestHandler(app).handle(request)
Ejemplo n.º 3
0
    # ユーザーの入力テキストから、改行を削除(対 Watson入力エラー)
    text = text.replace("\n", r"")

    # Watson APIに渡して、解析
    res_output = assistant.message_less(text)

    # WatsonAPI出力から、台本生成
    script = assistant.utan_message_Switcher(res_output)

    # 台本に従い、Webhookにpost
    posting_proc(script)


app = Flask(__name__)
handler = SlackRequestHandler(utan)


@app.route(r"/")
def index():
    return r"I am うーたん bot."


@app.route(r"/slack/events", methods=[r"POST"])
def slack_events():
    return handler.handle(request)


# アプリを起動します
if __name__ == r"__main__":
    utan.start(port=int(os.environ.get(r"PORT", 3000)))
Ejemplo n.º 4
0
logging.basicConfig(level=logging.DEBUG)
bolt_app = App()


@bolt_app.command("/hey-google-app-engine")
def hello(body, ack):
    user_id = body["user_id"]
    ack(f"Hi <@{user_id}>!")


from flask import Flask, request
from slack_bolt.adapter.flask import SlackRequestHandler

app = Flask(__name__)
handler = SlackRequestHandler(bolt_app)


@app.route("/_ah/warmup")
def warmup():
    # Handle your warmup logic here, e.g. set up a database connection pool
    return "", 200, {}


@app.route("/slack/events", methods=["POST"])
def slack_events():
    return handler.handle(request)


# Only for local debug
if __name__ == "__main__":
Ejemplo n.º 5
0
config = AppConfig()

with open(config.path_logging_config, mode="r") as logging_config:
    dictConfig(yaml.safe_load(logging_config.read()))

installation_store = TeamiclinkInstallStore(data_source_name=config.dsn)
slack_handler = SlackRequestHandler(app=App(
    signing_secret=config.slack_signing_secret,
    oauth_flow=TeamiclinkOAuth(settings=OAuthSettings(
        client_id=config.slack_client_id,
        client_secret=config.slack_client_secret,
        scopes=config.slack_permissions,
        state_store=RedisOAuthStateStore(redis=Redis(
            host=config.redis_host,
            port=config.redis_port,
            db=config.redis_db_install_state,
            password=config.redis_password,
            socket_timeout=config.redis_socket_connect_timeout_seconds,
            socket_connect_timeout=config.redis_socket_connect_timeout_seconds,
        )),
        installation_store=installation_store,
    )),
))
goal_store = GoalStore(data_source_name=config.dsn)
SlackMiddleware.set_variables(
    goal_store=goal_store,
    install_store=installation_store,
    client_id=config.slack_client_id,
    client_secret=config.slack_client_secret,
)
Ejemplo n.º 6
0
    #     user=user
    # )
    #
    # Say the name of the user
    # say(userinfo["user"]["real_name"])

    pass


# Here we define a listener for some mentioning @acbot in a channel to which acbot belongs
@slack_app.event("app_mention")
def say_ack(event, client, say):
    say("ack")


# --- FLASK SETUP ------------
app = Flask(__name__)
handler = SlackRequestHandler(slack_app)


# Boiler plate code
@app.route("/slack/events", methods=["POST"])
def slack_events():
    return handler.handle(request)


# Here we define what is shown at the addresss acbot.shwilks.co.uk when acbot is online
@app.route("/")
def hello():
    return 'acbot online'
Ejemplo n.º 7
0
from flask import Flask, request
from src.config import PORT
from src.bot import bot
from slack_bolt.adapter.flask import SlackRequestHandler
import logging

app = Flask(__name__)
handler = SlackRequestHandler(bot)
logging.basicConfig(level=logging.CRITICAL)


@app.route("/slack/interactions", methods=["POST"])
def slack_interactions():
    return handler.handle(request)


@app.route("/slack/events", methods=["POST"])
def slack_events():
    return handler.handle(request)


if __name__ == "__main__":
    app.run(host='localhost', port=PORT, debug=True)
Ejemplo n.º 8
0
cred = credentials.ApplicationDefault()
firebase_admin.initialize_app(cred, {
  'projectId': "your project id",
})
db = firestore.client()


# Initializes your app with your bot token and signing secret
app = App(
    token='replace-with-your-own-token',
    signing_secret=secret
)

# Create Flask app and enable info level logging
flask_app = Flask(__name__)
handler_event = SlackRequestHandler(app)

logging.basicConfig(level=logging.WARNING)

#create client for slack message
client = WebClient(token='replace-with-your-own-token')

#set up evengt adaptor for slack event
BOT_ID = client.api_call("auth.test")["user_id"]
phrase = ""

# @app.middleware  # or app.use(log_request)
# def log_request(logger, body, next):
#     logger.debug(body)
#     return next()