Compare commits

1 Commits

Author SHA1 Message Date
izzylys fc8a8e3adc feat(bot): sample empty bot 2022-04-28 13:03:44 +02:00
7 changed files with 919 additions and 421 deletions
+48
View File
@@ -0,0 +1,48 @@
from specklepy.api.wrapper import StreamWrapper
from devtools import debug
class StarterBot(object):
def __init__(self) -> None:
# set some additional class attrs if you need them here
pass
def on_event_received(self, event, payload):
method = getattr(self, f"on_{event}", None)
if not method:
print(f"Event {event} not supported.")
return
method(
payload["server"],
payload["user"],
payload["stream"],
payload["webhook"],
payload["event"].get("data", {}),
)
def on_commit_create(
self, server_info, user_info, stream_info, webhook_info, event_info
):
server_url = server_info["canonicalUrl"].rstrip("/")
commit_id = event_info["id"]
commit_info = event_info["commit"]
wrapper = StreamWrapper(f"{server_url}/streams/{stream_info['id']}")
client = wrapper.get_client()
commit_obj = client.object.get(stream_info["id"], commit_info["objectId"])
# def on_stream_update(
# self, server_info, user_info, stream_info, webhook_info, event_info
# ):
# pass
# def on_branch_update(
# self, server_info, user_info, stream_info, webhook_info, event_info
# ):
# pass
# def on_branch_delete(
# self, server_info, user_info, stream_info, webhook_info, event_info
# ):
# pass
Generated
+860 -416
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -8,7 +8,7 @@ authors = ["izzy lyseggen <izzy.lyseggen@gmail.com>"]
python = "^3.8"
CherryPy = "^18.6.1"
requests = "^2.26.0"
specklepy = "^2.2.3"
specklepy = "^2.6.7"
[tool.poetry.dev-dependencies]
black = "^21.7b0"
+6
View File
@@ -0,0 +1,6 @@
CherryPy==18.6.1
requests==2.26.0
specklepy==2.6.7
black==21.7b0
pylint==2.9.3
devtools==0.6.1
View File
+4 -4
View File
@@ -3,18 +3,18 @@ import os
import json
import hmac
import cherrypy
from webhooks_server.discordbot import DiscordBot
from bots.starterbot import StarterBot
from devtools import debug
# Web server:
class WebhookServer(object):
SECRET: str = os.environ.get("SECRET", None)
BOT: DiscordBot
SECRET: str = os.environ.get("SECRET", '')
BOT: StarterBot
def __init__(self, bot_url: str) -> None:
super().__init__()
self.BOT = DiscordBot(bot_url)
self.BOT = StarterBot()
@cherrypy.expose
@cherrypy.tools.json_in()