initial
This commit is contained in:
commit
b25cd86314
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.*secret
|
||||
6
.vscode/settings.json
vendored
Normal file
6
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"[python]": {
|
||||
"editor.defaultFormatter": "ms-python.black-formatter"
|
||||
},
|
||||
"python.formatting.provider": "none"
|
||||
}
|
||||
11
Pipfile
Normal file
11
Pipfile
Normal file
@ -0,0 +1,11 @@
|
||||
[[source]]
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3.11"
|
||||
20
Pipfile.lock
generated
Normal file
20
Pipfile.lock
generated
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "ed6d5d614626ae28e274e453164affb26694755170ccab3aa5866f093d51d3e4"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.11"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {},
|
||||
"develop": {}
|
||||
}
|
||||
BIN
images/lmao.png
Normal file
BIN
images/lmao.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 852 KiB |
46
main.py
Normal file
46
main.py
Normal file
@ -0,0 +1,46 @@
|
||||
import slack
|
||||
from flask import Flask
|
||||
from slackeventsapi import SlackEventAdapter
|
||||
from pprint import pprint
|
||||
|
||||
with open(".slacksecret") as f:
|
||||
SLACK_TOKEN = f.read().strip()
|
||||
|
||||
with open(".slacksigningsecret") as f:
|
||||
SIGNING_SECRET = f.read().strip()
|
||||
|
||||
app = Flask(__name__)
|
||||
slack_event_adapter = SlackEventAdapter(SIGNING_SECRET, "/slack/events", app)
|
||||
|
||||
client = slack.WebClient(token=SLACK_TOKEN)
|
||||
|
||||
|
||||
@slack_event_adapter.on("message")
|
||||
def message(payload):
|
||||
pprint(payload)
|
||||
event = payload.get("event", {})
|
||||
channel_id = event.get("channel")
|
||||
user_id = event.get("uesr")
|
||||
text = event.get("text")
|
||||
|
||||
if text == "cn":
|
||||
client.chat_postMessage(
|
||||
channel=channel_id,
|
||||
text="Don't get me started on them! :coff:",
|
||||
)
|
||||
|
||||
# if text == "image":
|
||||
# try:
|
||||
# response = client.files_upload(
|
||||
# file="./images/lmao.png",
|
||||
# initial_comment="I can read the chat messages",
|
||||
# channels=channel_id,
|
||||
# )
|
||||
# except slack.SlackApiError as e:
|
||||
# assert e.response["ok"] is False
|
||||
# assert e.response["error"]
|
||||
# print(f"Got an error: {e.response['error']}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True, host="0.0.0.0")
|
||||
Reference in New Issue
Block a user