在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:NiklasRosenstein/python-github-bot-api开源软件地址:https://github.com/NiklasRosenstein/python-github-bot-api开源编程语言:Python 100.0%开源软件介绍:github-bot-apiAPI for creating GitHub bots and webhooks in Python.
Quickstart (Webhook)
from github_bot_api import Event, Webhook
from github_bot_api.flask import create_flask_app
def on_any_event(event: Event) -> bool:
print(event)
return True
webhook = Webhook(secret=None)
webhook.listen('*', on_any_event)
import os; os.environ['FLASK_ENV'] = 'development'
flask_app = create_flask_app(__name__, webhook)
flask_app.run() Quickstart (Application)
import os
from github_bot_api import GithubApp
with open(os.environ['PRIVATE_KEY_FILE']) as fp:
private_key = fp.read()
app = GithubApp(
user_agent='my-bot/0.0.0',
app_id=int(os.environ['APP_ID']),
private_key=private_key)
print(app.app_client().get_app().owner) Combined Example# ...
app = GithubApp(...)
webhook = Webhook()
@webhook.listen('pull_request')
def on_pull_request(event: Event) -> bool:
client = app.installation_client(event.payload['installation']['id'])
repo = client.get_repo(event['repository']['full_name'])
pr = repo.get_pull(event['pull_request']['number'])
pr.create_issue_comment('Hello from my own bot!')
return True
# ... |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论