-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.py
37 lines (26 loc) · 1.03 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
import lightning as L
import slack
from flask import request
from slack_command_bot import SlackCommandBot
class DemoSlackCommandBot(SlackCommandBot):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def handle_command(self):
"""Customize this method the way you want your bot to interact with the command."""
data: dict = request.form
client = slack.WebClient(token=self.bot_token)
client.chat_postMessage(channel=data.get("channel_id"), text="Testing send msg")
return "Hey there! command was received successfully", 200
class LitApp(L.LightningFlow):
def __init__(self) -> None:
super().__init__()
self.slack_command_bot = DemoSlackCommandBot()
def run(self):
if os.environ.get("TESTING_LAI"):
print(
"this is a simple Lightning app to verify your component is working as expected"
)
self.slack_command_bot.run()
if __name__ == "__main__":
app = L.LightningApp(LitApp())