Giter Club home page Giter Club logo

qq-github-bot's People

Contributors

azidecupric avatar dependabot[bot] avatar he0119 avatar pre-commit-ci[bot] avatar starhearthunt avatar yanyongyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

qq-github-bot's Issues

Docs: update deployment guide

  1. Simply using Docker Hub or ghcr to pull pre-built image
  2. create config file and compose config file. eg. .env.prod
  3. docker-compose up -d

No Need to build docker image on local machine any more!!

Github Action will do it for you

disk_usage遍历到光驱会崩溃

data_source.py中函数
def disk_usage(): disk_parts = psutil.disk_partitions() for d in disk_parts: return {d.mountpoint: psutil.disk_usage(d.mountpoint)}
上面是我改完之后,原函数运行报错,因为遍历到最后一个 光驱会说无法访问,然后崩溃

tortoise.exceptions.OperationalError: 关系 "user" 不存在

俩个数据库均已配置好,成功连上了.
bot正常跑起来了,使用/auth 跳转到 github 再跳转回来的时候报错

08-08 01:49:07 [INFO] uvicorn | 127.0.0.1:43930 - "GET /github/auth?code=ea025bbac5e9efd12693&state=65fddb1a2e164f71b0e679acc7e184c0 HTTP/1.0" 500

08-08 01:49:07 [ERROR] uvicorn | Exception in ASGI application

Traceback (most recent call last):
  File "/bot/.venv/lib/python3.10/site-packages/tortoise/backends/asyncpg/client.py", line 82, in _translate_exceptions
    return await func(self, *args, **kwargs)
  File "/bot/.venv/lib/python3.10/site-packages/tortoise/backends/asyncpg/client.py", line 143, in execute_query
    rows = await connection.fetch(*params)
  File "/bot/.venv/lib/python3.10/site-packages/asyncpg/connection.py", line 620, in fetch
    return await self._execute(
  File "/bot/.venv/lib/python3.10/site-packages/asyncpg/connection.py", line 1659, in _execute
    result, _ = await self.__execute(
  File "/bot/.venv/lib/python3.10/site-packages/asyncpg/connection.py", line 1684, in __execute
    return await self._do_execute(
  File "/bot/.venv/lib/python3.10/site-packages/asyncpg/connection.py", line 1711, in _do_execute
    stmt = await self._get_statement(
  File "/bot/.venv/lib/python3.10/site-packages/asyncpg/connection.py", line 397, in _get_statement
    statement = await self._protocol.prepare(
  File "asyncpg/protocol/protocol.pyx", line 168, in prepare
    return await waiter
asyncpg.exceptions.UndefinedTableError: 关系 "user" 不存在

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/bot/bot.py", line 39, in <module>
    nonebot.run(app="__mp_main__:app")
  File "/bot/.venv/lib/python3.10/site-packages/nonebot/__init__.py", line 309, in run
    get_driver().run(*args, **kwargs)
  File "/bot/.venv/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 198, in run
    uvicorn.run(
  File "/bot/.venv/lib/python3.10/site-packages/uvicorn/main.py", line 578, in run
    server.run()
  File "/bot/.venv/lib/python3.10/site-packages/uvicorn/server.py", line 61, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
> File "/bot/.venv/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 435, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/bot/.venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/bot/.venv/lib/python3.10/site-packages/fastapi/applications.py", line 284, in __call__
    await super().__call__(scope, receive, send)
  File "/bot/.venv/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/bot/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/bot/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/bot/.venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/bot/.venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/bot/.venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/bot/.venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/bot/.venv/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/bot/.venv/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/bot/.venv/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
  File "/bot/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 241, in app
    raw_response = await run_endpoint_function(
  File "/bot/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 167, in run_endpoint_function
    return await dependant.call(**values)
  File "/bot/src/plugins/github/apis/auth.py", line 51, in auth
    await delete_state_data(state)
  File "/bot/src/plugins/github/libs/auth.py", line 45, in create_auth_user
    return await create_or_update_user(info, access_token=access_token)
  File "/bot/src/plugins/github/libs/platform/user_crud.py", line 41, in create_or_update_user
    user, _ = await User.update_or_create(
  File "/bot/.venv/lib/python3.10/site-packages/tortoise/models.py", line 1105, in update_or_create
    instance = await cls.select_for_update().using_db(connection).get_or_none(**kwargs)
  File "/bot/.venv/lib/python3.10/site-packages/tortoise/queryset.py", line 1006, in _execute
    instance_list = await self._db.executor_class(
  File "/bot/.venv/lib/python3.10/site-packages/tortoise/backends/base/executor.py", line 130, in execute_select
    _, raw_results = await self.db.execute_query(query.get_sql())
  File "/bot/.venv/lib/python3.10/site-packages/tortoise/backends/base_postgres/client.py", line 34, in _translate_exceptions
    return await self._translate_exceptions(func, *args, **kwargs)
  File "/bot/.venv/lib/python3.10/site-packages/tortoise/backends/asyncpg/client.py", line 84, in _translate_exceptions
    raise OperationalError(exc)
tortoise.exceptions.OperationalError: 关系 "user" 不存在

image
数据库里什么都没有,是不是需要什么初始化步骤?

服务器状态查看遍历到光驱会崩溃

data_source.py中函数

def disk_usage():
	disk_parts = psutil.disk_partitions()
	for d in disk_parts:
		return {d.mountpoint: psutil.disk_usage(d.mountpoint)}

上面是我改完之后,原函数运行报错,因为遍历到最后一个 光驱会说无法访问,然后崩溃

Feature: webhook event debounce

throttled event:

  • star (created, deleted)

debounced event:

  • issue (edited)
  • issue_comment (edited)
  • pull_request (edited)
  • release (edited)

event cache key should consider the backport model

Bug: k8s lb session error

在多worker负载均衡的时候,会出现session不同步,是由于nb的matchers不同步导致的,可能需要同步matchers。

Refactor: github toolkit / adapter

(WIP) Generate code from GitHub spec, build some toolkit like octokit.

Rest API

reference: https://github.com/github/rest-api-description

  • auth
  • request core
  • response data parsing
  • response error parsing
  • pagination
  • custom accept format
  • rest api client codegen

Done in https://github.com/yanyongyu/githubkit

GraphQL

reference: https://github.com/octokit/graphql-schema

  • graphql api request function
  • feature preview (accept header)
  • schema validation

Done in https://github.com/yanyongyu/githubkit

WebHooks

reference: https://github.com/octokit/webhooks

  • webhook schema parsing

Done in https://github.com/yanyongyu/githubkit


Adapter

wrap the githubkit core and webhook definition

Done in https://github.com/nonebot/adapter-github

Feature: `StateChangeIssueEvent` rendering

types:

  • marked_as_duplicate: https://github.com/nonebot/nb-cli/issues/78
  • unmarked_as_duplicate: ...
  • subscribed: ignore
  • auto_squash_enabled: https://github.com/he0119/nonebot-plugin-treehelp/pull/22
  • auto_merge_disabled: https://github.com/he0119/CoolQBot/pull/286
  • unsubscribed: ignore
  • user_blocked: https://github.com/mamoe/mirai/issues/850

Security: Please enable Autoescaping for Jinja2

Using Jinja2 templates without autoescaping enabled leaves application vulnerable to [XSS attacks](https://owasp.org/www-project-top-ten/2017/A72017-Cross-SiteScripting_(XSS).

Autoescaping is the concept of automatically escaping special characters. Special characters for HTML, XML and XHTMl are &, >, <, " as well as '. These characters carry specific meanings so need to be replaced by so called entities if you want to use them for text. Not doing so makes application susceptible to Cross Site Scripting (XSS) attacks.

When configuring the Jinja2 environment, the option to use autoescaping on input can be specified. By default, autoescaping is disabled. When enabled, Jinja2 will filter input strings to escape any HTML content submitted via template variables.

_ev = Environment(
trim_blocks=True, lstrip_blocks=True, autoescape=False, enable_async=True
)

Bug: user permission check failed when subscribe

上下文错误,要使用user token

remain: bool = True
page: int = 1
while remain:
accessible_repos = await bot.rest.apps.async_list_installation_repos_for_authenticated_user(
installation_id=repo_installation.parsed_data.id, page=page
)
if not accessible_repos.parsed_data.repositories:
remain = False
for accessible_repo in accessible_repos.parsed_data.repositories:
if accessible_repo.full_name == full_name:
break
page += 1
else:
await subscribe.reject(f"你没有权限访问仓库 {owner}/{repo} !请重新发送或取消")

私聊使用 /install 后报错

系统: Ubuntu 20.04
Docker: 24.06
镜像版本: 2.1.3
使用QQ频道通信

Logs:

2023-12-30T09:58:38.956795128Z 12-30 17:58:38 [SUCCESS] nonebot | QQ 102082715 | [EventType.DIRECT_MESSAGE_CREATE]: Message 088dddabb296f6f2b3950110d690fddbaabb8fa501380948cdd3bfac06 from MagicMC: [Text(type='text', data={'text': '/install'})]
2023-12-30T09:58:39.019977508Z 12-30 17:58:39 [INFO] nonebot | Event will be handled by Matcher(type='message', module=src.plugins.github.plugins.github_install, lineno=37)
2023-12-30T09:58:39.920385349Z 12-30 17:58:39 [INFO] httpx | HTTP Request: POST https://api.sgroup.qq.com/dms/10765797397038296717/messages "HTTP/1.1 403 Forbidden"
2023-12-30T09:58:39.923047283Z 12-30 17:58:39 [INFO] nonebot | Matcher(type='message', module=src.plugins.github.plugins.github_install, lineno=37) running complete
2023-12-30T09:58:39.931981383Z 12-30 17:58:39 [ERROR] nonebot | Running Matcher(type='message', module=src.plugins.github.plugins.github_install, lineno=37) failed.
2023-12-30T09:58:39.932076415Z Traceback (most recent call last):
2023-12-30T09:58:39.932093864Z   File "/usr/local/bin/gunicorn", line 8, in <module>
2023-12-30T09:58:39.932103717Z     sys.exit(run())
2023-12-30T09:58:39.932111144Z   File "/usr/local/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 67, in run
2023-12-30T09:58:39.932119098Z     WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2023-12-30T09:58:39.932129361Z   File "/usr/local/lib/python3.11/site-packages/gunicorn/app/base.py", line 236, in run
2023-12-30T09:58:39.932153631Z     super().run()
2023-12-30T09:58:39.932170036Z   File "/usr/local/lib/python3.11/site-packages/gunicorn/app/base.py", line 72, in run
2023-12-30T09:58:39.932185631Z     Arbiter(self).run()
2023-12-30T09:58:39.932199523Z   File "/usr/local/lib/python3.11/site-packages/gunicorn/arbiter.py", line 202, in run
2023-12-30T09:58:39.932215524Z     self.manage_workers()
2023-12-30T09:58:39.932230367Z   File "/usr/local/lib/python3.11/site-packages/gunicorn/arbiter.py", line 571, in manage_workers
2023-12-30T09:58:39.932247813Z     self.spawn_workers()
2023-12-30T09:58:39.932263172Z   File "/usr/local/lib/python3.11/site-packages/gunicorn/arbiter.py", line 642, in spawn_workers
2023-12-30T09:58:39.932278141Z     self.spawn_worker()
2023-12-30T09:58:39.932303200Z   File "/usr/local/lib/python3.11/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
2023-12-30T09:58:39.932319608Z     worker.init_process()
2023-12-30T09:58:39.932336097Z   File "/usr/local/lib/python3.11/site-packages/uvicorn/workers.py", line 66, in init_process
2023-12-30T09:58:39.932351121Z     super(UvicornWorker, self).init_process()
2023-12-30T09:58:39.932367581Z   File "/usr/local/lib/python3.11/site-packages/gunicorn/workers/base.py", line 142, in init_process
2023-12-30T09:58:39.932385362Z     self.run()
2023-12-30T09:58:39.932400593Z   File "/usr/local/lib/python3.11/site-packages/uvicorn/workers.py", line 98, in run
2023-12-30T09:58:39.932420064Z     return asyncio.run(self._serve())
2023-12-30T09:58:39.932437696Z   File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
2023-12-30T09:58:39.932454602Z     return runner.run(main)
2023-12-30T09:58:39.932521127Z   File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
2023-12-30T09:58:39.932542386Z     return self._loop.run_until_complete(task)
2023-12-30T09:58:39.932558530Z   File "/usr/local/lib/python3.11/site-packages/nonebot/message.py", line 476, in check_and_run_matcher
2023-12-30T09:58:39.932575874Z     await _run_matcher(
2023-12-30T09:58:39.932591526Z > File "/usr/local/lib/python3.11/site-packages/nonebot/message.py", line 428, in _run_matcher
2023-12-30T09:58:39.932606992Z     await matcher.run(bot, event, state, stack, dependency_cache)
2023-12-30T09:58:39.932627420Z   File "/usr/local/lib/python3.11/site-packages/nonebot/internal/matcher/matcher.py", line 846, in run
2023-12-30T09:58:39.932644263Z     await self.simple_run(bot, event, state, stack, dependency_cache)
2023-12-30T09:58:39.932660305Z   File "/usr/local/lib/python3.11/site-packages/nonebot/internal/matcher/matcher.py", line 821, in simple_run
2023-12-30T09:58:39.932677432Z     await handler(
2023-12-30T09:58:39.932697690Z   File "/usr/local/lib/python3.11/site-packages/nonebot/dependencies/__init__.py", line 113, in __call__
2023-12-30T09:58:39.932714301Z     return await cast(Callable[..., Awaitable[R]], self.call)(**values)
2023-12-30T09:58:39.932729890Z   File "/app/src/plugins/github/plugins/github_install/__init__.py", line 53, in handle_private
2023-12-30T09:58:39.932745555Z     await install.finish(
2023-12-30T09:58:39.932760900Z   File "/usr/local/lib/python3.11/site-packages/nonebot/internal/matcher/matcher.py", line 570, in finish
2023-12-30T09:58:39.932777184Z     await cls.send(message, **kwargs)
2023-12-30T09:58:39.932791878Z   File "/usr/local/lib/python3.11/site-packages/nonebot/internal/matcher/matcher.py", line 554, in send
2023-12-30T09:58:39.932808436Z     return await bot.send(event=event, message=_message, **kwargs)
2023-12-30T09:58:39.932823136Z   File "/usr/local/lib/python3.11/site-packages/nonebot/adapters/qq/bot.py", line 481, in send
2023-12-30T09:58:39.932837900Z     return await self.send_to_dms(
2023-12-30T09:58:39.932854974Z   File "/usr/local/lib/python3.11/site-packages/nonebot/adapters/qq/bot.py", line 347, in send_to_dms
2023-12-30T09:58:39.932881943Z     return await self.post_dms_messages(
2023-12-30T09:58:39.932992317Z   File "/usr/local/lib/python3.11/site-packages/nonebot/internal/adapter/bot.py", line 123, in call_api
2023-12-30T09:58:39.933225580Z     raise exception
2023-12-30T09:58:39.933378034Z   File "/usr/local/lib/python3.11/site-packages/nonebot/internal/adapter/bot.py", line 98, in call_api
2023-12-30T09:58:39.933526954Z     result = await self.adapter._call_api(self, api, **data)
2023-12-30T09:58:39.933701966Z   File "/usr/local/lib/python3.11/site-packages/nonebot/adapters/qq/adapter.py", line 416, in _call_api
2023-12-30T09:58:39.933798252Z     return await api_handler(bot, **data)
2023-12-30T09:58:39.933996039Z   File "/usr/local/lib/python3.11/site-packages/nonebot/adapters/qq/utils.py", line 64, in __call__
2023-12-30T09:58:39.934185685Z     return await self.func(inst, *args, **kwds)
2023-12-30T09:58:39.934314738Z   File "/usr/local/lib/python3.11/site-packages/nonebot/adapters/qq/bot.py", line 1079, in post_dms_messages
2023-12-30T09:58:39.934479042Z     return parse_obj_as(GuildMessage, await self._request(request))
2023-12-30T09:58:39.934677957Z   File "/usr/local/lib/python3.11/site-packages/nonebot/adapters/qq/bot.py", line 549, in _request
2023-12-30T09:58:39.934921948Z     return self._handle_response(response)
2023-12-30T09:58:39.935065234Z   File "/usr/local/lib/python3.11/site-packages/nonebot/adapters/qq/bot.py", line 538, in _handle_response
2023-12-30T09:58:39.935214018Z     raise ActionFailed(response)
2023-12-30T09:58:39.935346662Z nonebot.adapters.qq.exception.ActionFailed: <ActionFailed: 403, code=304003, message=url not allowed, trace_id=0868b2b9dae353cd4188faf30f332625>



Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.