commit d3c0afcadb555ccc29be762dff8d17916634cdb4 Author: woodchen Date: Fri Jun 23 18:53:44 2023 +0800 1.0 diff --git a/.github/ISSUE_TEMPLATE/document.md b/.github/ISSUE_TEMPLATE/document.md new file mode 100644 index 0000000..62a65ce --- /dev/null +++ b/.github/ISSUE_TEMPLATE/document.md @@ -0,0 +1,26 @@ +--- +name: 文档改善 +about: 欢迎分享您的文档改善建议! +title: "📝 文档改善" +labels: ["documentation"] +--- + +# 文档改善建议 📝 + +欢迎在此分享您对文档的改善建议,我们期待听到您的想法和建议。 + +## 您的建议是什么? 🤔 + +请简要描述您的文档改善建议,包括您的目标和想法。 + +如果您的建议是解决某个特定问题的,请尽可能提供更多的上下文和细节。 + +## 您的建议有哪些优势? 🌟 + +请简要描述您的建议的优势和特点,比如: + +- 是否可以提高文档的可读性和易用性? +- 是否可以使文档更加详细和准确? +- 是否可以让文档更好地反映项目的实际情况? + +感谢您的分享和支持!🙏 diff --git a/.github/ISSUE_TEMPLATE/enhancement.md b/.github/ISSUE_TEMPLATE/enhancement.md new file mode 100644 index 0000000..c7ad180 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/enhancement.md @@ -0,0 +1,19 @@ +--- +name: 功能改善 +about: 欢迎分享您的改善建议! +title: "🚀 功能改善" +labels: ["enhancement"] +--- + +# 功能改善建议 🚀 + +欢迎在此分享您对功能的改善建议,我们期待听到您的想法和建议。 + +## 您的建议是什么? 🤔 + +请简要描述您的功能改善建议,包括您的目标和想法。 + +如果您的建议是解决某个特定问题的,请尽可能提供更多的上下文和细节。 + + +感谢您的分享和支持!🙏 diff --git a/.github/ISSUE_TEMPLATE/error.md b/.github/ISSUE_TEMPLATE/error.md new file mode 100644 index 0000000..114ea69 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/error.md @@ -0,0 +1,26 @@ +--- +name: 错误报告 +about: 提出关于此项目的错误报告 +title: "🐞 错误报告" +labels: ["bug"] +--- + +# 错误报告 🐞 + +如果您在使用此项目时遇到了错误,请在此报告,我们会尽快解决此问题。 + +## 错误描述 🤔 + +请详细地描述您遇到的问题,包括出现问题的环境和步骤,以及您已经尝试过的解决方法。 + +另外,如果您在解决问题时已经查看过其他 GitHub Issue,请务必在文本中说明并引用相关信息。 + +## 附加信息 📝 + +请提供以下信息以帮助我们更快地解决问题: + +- 输出日志,包括错误信息和堆栈跟踪 +- 相关的代码片段或文件 +- 您的操作系统、软件版本等环境信息 + +感谢您的反馈!🙏 diff --git a/.github/ISSUE_TEMPLATE/maintenance.md b/.github/ISSUE_TEMPLATE/maintenance.md new file mode 100644 index 0000000..9c1f4e9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/maintenance.md @@ -0,0 +1,29 @@ +--- +name: 项目维护 +about: 欢迎提交您的项目维护问题和建议! +title: "🔧 项目维护" +labels: ["maintenance"] +--- + +# 项目维护问题和建议 🔧 + +欢迎在此分享您对项目维护的问题和建议,我们期待听到您的想法和建议。 + +## 您的问题或建议是什么? 🤔 + +请简要描述您遇到的项目维护问题或者您的项目维护建议,包括您的目标和想法。 + +注意:如果您的建议涉及到以下方面,请在描述中加以说明,以帮助我们更好地理解您的意见。 + +- 代码重构 +- 设计模式加强 +- 优化算法 +- 依赖升级 + +## 您期望的解决方案是什么? 💡 + +请简要描述您期望的解决方案,包括您的期望和想法。 + +如果您期望的解决方案是解决某个特定问题的,请尽可能提供更多的上下文和细节。 + +感谢您的分享和支持!🙏 diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000..ecd224a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,26 @@ +--- +name: 部署问题反馈 +about: 如果您在部署中遇到任何问题,欢迎在这里与我们交流。 +title: "🚰 部署问题反馈" +labels: ["question"] +--- + +# 问题交流 💬 + +欢迎在此提交您遇到的问题,我们会尽快回复您并提供帮助。 + +## 问题描述 🤔 + +请详细描述您遇到的问题,包括出现问题的环境和步骤,以及您已经尝试过的解决方法。 + +如果您在解决问题时已经查看过其他 GitHub Issue,请务必在文本中说明并引用相关信息。 + +## 附加信息 📝 + +为了更好地了解您遇到的问题,我们需要您提供以下信息: + +- 输出日志,包括错误信息和堆栈跟踪。 +- 相关的代码片段或文件。 +- 操作系统、golang 版本等环境信息。 + +感谢您的反馈和支持!🙏 diff --git a/.github/pull-request-template.md b/.github/pull-request-template.md new file mode 100644 index 0000000..9a93019 --- /dev/null +++ b/.github/pull-request-template.md @@ -0,0 +1,6 @@ + +## 描述 +请简要描述此Pull Request中的更改。 + +## 相关问题 +- [问题编号](问题链接) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..18b77ff --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,43 @@ +# Configuration for Release Drafter: https://github.com/toolmantim/release-drafter +name-template: 'v$NEXT_PATCH_VERSION 🌈' +tag-template: 'v$NEXT_PATCH_VERSION' +version-template: $MAJOR.$MINOR.$PATCH +# Emoji reference: https://gitmoji.carloscuesta.me/ +categories: + - title: 🚀 Features + labels: + - 'feature' + - 'enhancement' + - 'kind/feature' + - title: 🚑️ Bug Fixes + labels: + - 'fix' + - 'bugfix' + - 'bug' + - 'regression' + - 'kind/bug' + - title: 📝 Documentation updates + labels: + - 'doc' + - 'documentation' + - 'kind/doc' + - title: 👷 Maintenance + labels: + - refactor + - chore + - dependencies + - 'kind/chore' + - 'kind/dep' + - title: 🚦 Tests + labels: + - test + - tests +exclude-labels: + - reverted + - no-changelog + - skip-changelog + - invalid +change-template: '* $TITLE (#$NUMBER) @$AUTHOR' +template: | + ## What’s Changed + $CHANGES diff --git a/.github/workflows/binary-release.yml b/.github/workflows/binary-release.yml new file mode 100644 index 0000000..6282a09 --- /dev/null +++ b/.github/workflows/binary-release.yml @@ -0,0 +1,39 @@ +name: Build Release + +on: + release: + types: [created,published] + +permissions: + contents: read + +jobs: + build-go-binary: + permissions: + contents: write # for build-go-binary + runs-on: ubuntu-latest + strategy: + matrix: + goos: [ linux, windows, darwin ] # 需要打包的系统 + goarch: [ amd64, arm64 ] # 需要打包的架构 + exclude: # 排除某些平台和架构 + - goarch: arm64 + goos: windows + steps: + - name: Checkout the code + uses: actions/checkout@v2 + - name: Create version file + run: echo ${{ github.event.release.tag_name }} > VERSION + - name: Parallel build + uses: wangyoucao577/go-release-action@v1.30 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + goos: ${{ matrix.goos }} + goarch: ${{ matrix.goarch }} + goversion: 1.18 + pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 + executable_compression: "upx -9" + md5sum: false + project_path: "./code" + binary_name: "feishu-chatgpt" + extra_files: ./code/config.example.yaml readme.md LICENSE ./code/role_list.yaml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..531e42b --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,59 @@ +name: build docker image + +# release 事件触发 + Master 分支触发 + 手动触发 +on: +# push: +# branches: +# - master + release: + types: [created,published] + + # 可以手动触发 + workflow_dispatch: + inputs: + logLevel: + description: 'Log level' + required: true + default: 'warning' + tags: + description: 'Test scenario tags' + +jobs: + buildx: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Available platforms + run: echo ${{ steps.buildx.outputs.platforms }} + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + # 所需要的体系结构,可以在 Available platforms 步骤中获取所有的可用架构 + platforms: linux/amd64,linux/arm64/v8 + # 镜像推送时间 + push: ${{ github.event_name != 'pull_request' }} + # 给清单打上多个标签 + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.GITHUB_REPOSITORY_NAME_PART }}:${{ env.GITHUB_REF_NAME }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.GITHUB_REPOSITORY_NAME_PART }}:latest diff --git a/.github/workflows/release-draft.yml b/.github/workflows/release-draft.yml new file mode 100644 index 0000000..94b21c7 --- /dev/null +++ b/.github/workflows/release-draft.yml @@ -0,0 +1,38 @@ +name: Release Drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - master + # pull_request event is required only for autolabeler + pull_request: + # Only following types are handled by the action, but one can default to all as well + types: [opened, reopened, synchronize] + # pull_request_target event is required for autolabeler to support PRs from forks + # pull_request_target: + # types: [opened, reopened, synchronize] + +permissions: + contents: read + +jobs: + update_release_draft: + permissions: + contents: write # for release-drafter/release-drafter to create a github release + pull-requests: write # for release-drafter/release-drafter to add label to PR + runs-on: ubuntu-latest + steps: + # (Optional) GitHub Enterprise requires GHE_HOST variable set + #- name: Set GHE_HOST + # run: | + # echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV + + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml + # with: + # config-name: my-config.yml + # disable-autolabeler: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5d7ebc6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,40 @@ +### Go template +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work +./code/target +.idea +.vscode +.s + +config.yaml + + + +/code/target/ +start-feishubot +.env + +docker.md +# Mac OS +.DS_Store +**/.DS_Store +*.pem diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b154ee3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM golang:1.18 as golang + +ENV GO111MODULE=on \ + CGO_ENABLED=1 \ + GOPROXY=https://goproxy.cn,direct + +WORKDIR /build +ADD /code /build + +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags '-w -s' -o feishu_chatgpt + +FROM alpine:latest + +WORKDIR /app + +RUN apk add --no-cache bash +COPY --from=golang /build/feishu_chatgpt /app +COPY --from=golang /build/role_list.yaml /app +EXPOSE 9000 +ENTRYPOINT ["/app/feishu_chatgpt"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/code/.gitignore b/code/.gitignore new file mode 100644 index 0000000..d742ec8 --- /dev/null +++ b/code/.gitignore @@ -0,0 +1,2 @@ +/apikey_usage.json +*.pem diff --git a/code/config.example.yaml b/code/config.example.yaml new file mode 100644 index 0000000..68d00c5 --- /dev/null +++ b/code/config.example.yaml @@ -0,0 +1,27 @@ +# 飞书 +APP_ID: cli_axxx +APP_SECRET: xxx +APP_ENCRYPT_KEY: xxx +APP_VERIFICATION_TOKEN: xxx +# 请确保和飞书应用管理平台中的设置一致 +BOT_NAME: chatGpt +# openAI key 支持负载均衡 可以填写多个key 用逗号分隔 +OPENAI_KEY: sk-xxx,sk-xxx,sk-xxx +# 服务器配置 +HTTP_PORT: 9000 +HTTPS_PORT: 9001 +USE_HTTPS: false +CERT_FILE: cert.pem +KEY_FILE: key.pem +# openai 地址, 一般不需要修改, 除非你有自己的反向代理 +API_URL: https://oapi.czl.net +# 代理设置, 例如 "http://127.0.0.1:7890", ""代表不使用代理 +HTTP_PROXY: "" + +# AZURE OPENAI +AZURE_ON: false # set true to use Azure rather than OpenAI +AZURE_API_VERSION: 2023-03-15-preview # 2023-03-15-preview or 2022-12-01 refer https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference#completions +AZURE_RESOURCE_NAME: xxxx # you can find in endpoint url. Usually looks like https://{RESOURCE_NAME}.openai.azure.com +AZURE_DEPLOYMENT_NAME: xxxx # usually looks like ...openai.azure.com/openai/deployments/{DEPLOYMENT_NAME}/chat/completions. +AZURE_OPENAI_TOKEN: xxxx # Authentication key. We can use Azure Active Directory Authentication(TBD). + diff --git a/code/go.mod b/code/go.mod new file mode 100644 index 0000000..0ddc315 --- /dev/null +++ b/code/go.mod @@ -0,0 +1,55 @@ +module start-feishubot + +go 1.18 + +require github.com/larksuite/oapi-sdk-go/v3 v3.0.14 + +require ( + github.com/duke-git/lancet/v2 v2.1.17 + github.com/gin-gonic/gin v1.8.2 + github.com/google/uuid v1.3.0 + github.com/larksuite/oapi-sdk-gin v1.0.0 + github.com/pandodao/tokenizer-go v0.2.0 + github.com/patrickmn/go-cache v2.1.0+incompatible + github.com/pion/opus v0.0.0-20230123082803-1052c3e89e58 + github.com/spf13/pflag v1.0.5 + github.com/spf13/viper v1.14.0 + gopkg.in/yaml.v2 v2.4.0 +) + +require ( + github.com/dlclark/regexp2 v1.8.1 // indirect + github.com/dop251/goja v0.0.0-20230304130813-e2f543bf4b4c // indirect + github.com/dop251/goja_nodejs v0.0.0-20230226152057-060fa99b809f // indirect + github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.0 // indirect + github.com/go-playground/validator/v10 v10.11.1 // indirect + github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect + github.com/goccy/go-json v0.10.0 // indirect + github.com/google/pprof v0.0.0-20230309165930-d61513b1440d // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/leodido/go-urn v1.2.1 // indirect + github.com/magiconair/properties v1.8.7 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pelletier/go-toml v1.9.5 // indirect + github.com/pelletier/go-toml/v2 v2.0.6 // indirect + github.com/spf13/afero v1.9.3 // indirect + github.com/spf13/cast v1.5.0 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/subosito/gotenv v1.4.1 // indirect + github.com/ugorji/go/codec v1.2.8 // indirect + golang.org/x/crypto v0.5.0 // indirect + golang.org/x/exp v0.0.0-20221208152030-732eee02a75a // indirect + golang.org/x/net v0.5.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.8.0 // indirect + google.golang.org/protobuf v1.28.1 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/code/go.sum b/code/go.sum new file mode 100644 index 0000000..7f870c9 --- /dev/null +++ b/code/go.sum @@ -0,0 +1,589 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= +github.com/dlclark/regexp2 v1.8.1 h1:6Lcdwya6GjPUNsBct8Lg/yRPwMhABj269AAzdGSiR+0= +github.com/dlclark/regexp2 v1.8.1/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= +github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= +github.com/dop251/goja v0.0.0-20221118162653-d4bf6fde1b86/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs= +github.com/dop251/goja v0.0.0-20230304130813-e2f543bf4b4c h1:/utv6nmTctV6OVgfk5+O6lEMEWL+6KJy4h9NZ5fnkQQ= +github.com/dop251/goja v0.0.0-20230304130813-e2f543bf4b4c/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4= +github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= +github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= +github.com/dop251/goja_nodejs v0.0.0-20230226152057-060fa99b809f h1:mmnNidRg3cMfcgyeNtIBSDZgjf/85lA/2pplccwSxYg= +github.com/dop251/goja_nodejs v0.0.0-20230226152057-060fa99b809f/go.mod h1:0tlktQL7yHfYEtjcRGi/eiOkbDR5XF7gyFFvbC5//E0= +github.com/duke-git/lancet/v2 v2.1.17 h1:4u9oAGgmTPTt2D7AcjjLp0ubbcaQlova8xeTIuyupDw= +github.com/duke-git/lancet/v2 v2.1.17/go.mod h1:hNcc06mV7qr+crH/0nP+rlC3TB0Q9g5OrVnO8/TGD4c= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.8.2 h1:UzKToD9/PoFj/V4rvlKqTRKnQYyz8Sc1MJlv4JHPtvY= +github.com/gin-gonic/gin v1.8.2/go.mod h1:qw5AYuDrzRTnhvusDsrov+fDIxp9Dleuu12h8nfB398= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= +github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= +github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= +github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= +github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA= +github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg= +github.com/google/pprof v0.0.0-20230309165930-d61513b1440d h1:um9/pc7tKMINFfP1eE7Wv6PRGXlcCSJkVajF7KJw3uQ= +github.com/google/pprof v0.0.0-20230309165930-d61513b1440d/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/larksuite/oapi-sdk-gin v1.0.0 h1:pf2JyCSECZ2ra16JoQEgbl7PPaaOpoAEBno+Y91HFO0= +github.com/larksuite/oapi-sdk-gin v1.0.0/go.mod h1:17QKeJMEkIYBUOrUoP0HBVErfzdu7cuJ9XiXitUwe/s= +github.com/larksuite/oapi-sdk-go/v3 v3.0.14 h1:WxRAudM5eTTBZgmXs0BRp3Pq8/sxsc0lcfIl43veDJI= +github.com/larksuite/oapi-sdk-go/v3 v3.0.14/go.mod h1:FKi8vBgtkBt/xNRQUwdWvoDmsPh7/wP75Sn5IBIBQLk= +github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/pandodao/tokenizer-go v0.2.0 h1:NhfI8fGvQkDld2cZCag6NEU3pJ/ugU9zoY1R/zi9YCs= +github.com/pandodao/tokenizer-go v0.2.0/go.mod h1:t6qFbaleKxbv0KNio2XUN/mfGM5WKv4haPXDQWVDG00= +github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= +github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= +github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= +github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= +github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= +github.com/pion/opus v0.0.0-20230123082803-1052c3e89e58 h1:wi5XffRvL9Ghx8nRAdZyAjmLV/ccnn2xJ4w6S6fELgA= +github.com/pion/opus v0.0.0-20230123082803-1052c3e89e58/go.mod h1:m8ODxkLrcNvLY6BPvOj7yLxK1wMQWA+2jqKcsrZ293U= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= +github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk= +github.com/spf13/afero v1.9.3/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= +github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= +github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.14.0 h1:Rg7d3Lo706X9tHsJMUjdiwMpHB7W8WnSVOssIY+JElU= +github.com/spf13/viper v1.14.0/go.mod h1:WT//axPky3FdvXHzGw33dNdXXXfFQqmEalje+egj8As= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= +github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= +github.com/ugorji/go/codec v1.2.8 h1:sgBJS6COt0b/P40VouWKdseidkDgHxYGm0SAglUHfP0= +github.com/ugorji/go/codec v1.2.8/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= +golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20221208152030-732eee02a75a h1:4iLhBPcpqFmylhnkbY3W0ONLUYYkDAW9xMFLfxgsvCw= +golang.org/x/exp v0.0.0-20221208152030-732eee02a75a/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= +golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/code/handlers/card_ai_mode_action.go b/code/handlers/card_ai_mode_action.go new file mode 100644 index 0000000..f544b3c --- /dev/null +++ b/code/handlers/card_ai_mode_action.go @@ -0,0 +1,38 @@ +package handlers + +import ( + "context" + + "start-feishubot/services" + "start-feishubot/services/openai" + + larkcard "github.com/larksuite/oapi-sdk-go/v3/card" +) + +// AIModeChooseKind is the kind of card action for choosing AI mode +func NewAIModeCardHandler(cardMsg CardMsg, + m MessageHandler) CardHandlerFunc { + return func(ctx context.Context, cardAction *larkcard.CardAction) (interface{}, error) { + + if cardMsg.Kind == AIModeChooseKind { + newCard, err, done := CommonProcessAIMode(cardMsg, cardAction, + m.sessionCache) + if done { + return newCard, err + } + return nil, nil + } + return nil, ErrNextHandler + } +} + +// CommonProcessAIMode is the common process for choosing AI mode +func CommonProcessAIMode(msg CardMsg, cardAction *larkcard.CardAction, + cache services.SessionServiceCacheInterface) (interface{}, + error, bool) { + option := cardAction.Action.Option + replyMsg(context.Background(), "已选择AI模式:"+option, + &msg.MsgId) + cache.SetAIMode(msg.SessionId, openai.AIModeMap[option]) + return nil, nil, true +} diff --git a/code/handlers/card_clear_action.go b/code/handlers/card_clear_action.go new file mode 100644 index 0000000..51bd582 --- /dev/null +++ b/code/handlers/card_clear_action.go @@ -0,0 +1,45 @@ +package handlers + +import ( + "context" + + "start-feishubot/services" + + larkcard "github.com/larksuite/oapi-sdk-go/v3/card" +) + +func NewClearCardHandler(cardMsg CardMsg, m MessageHandler) CardHandlerFunc { + return func(ctx context.Context, cardAction *larkcard.CardAction) (interface{}, error) { + if cardMsg.Kind == ClearCardKind { + newCard, err, done := CommonProcessClearCache(cardMsg, m.sessionCache) + if done { + return newCard, err + } + return nil, nil + } + return nil, ErrNextHandler + } +} + +func CommonProcessClearCache(cardMsg CardMsg, session services.SessionServiceCacheInterface) ( + interface{}, error, bool) { + if cardMsg.Value == "1" { + session.Clear(cardMsg.SessionId) + newCard, _ := newSendCard( + withHeader("️🆑 机器人提醒", larkcard.TemplateGrey), + withMainMd("已删除此话题的上下文信息"), + withNote("我们可以开始一个全新的话题,继续找我聊天吧"), + ) + //fmt.Printf("session: %v", newCard) + return newCard, nil, true + } + if cardMsg.Value == "0" { + newCard, _ := newSendCard( + withHeader("️🆑 机器人提醒", larkcard.TemplateGreen), + withMainMd("依旧保留此话题的上下文信息"), + withNote("我们可以继续探讨这个话题,期待和您聊天。如果您有其他问题或者想要讨论的话题,请告诉我哦"), + ) + return newCard, nil, true + } + return nil, nil, false +} diff --git a/code/handlers/card_common_action.go b/code/handlers/card_common_action.go new file mode 100644 index 0000000..7d89eef --- /dev/null +++ b/code/handlers/card_common_action.go @@ -0,0 +1,47 @@ +package handlers + +import ( + "context" + "encoding/json" + "fmt" + + larkcard "github.com/larksuite/oapi-sdk-go/v3/card" +) + +type CardHandlerMeta func(cardMsg CardMsg, m MessageHandler) CardHandlerFunc + +type CardHandlerFunc func(ctx context.Context, cardAction *larkcard.CardAction) ( + interface{}, error) + +var ErrNextHandler = fmt.Errorf("next handler") + +func NewCardHandler(m MessageHandler) CardHandlerFunc { + handlers := []CardHandlerMeta{ + NewClearCardHandler, + NewPicResolutionHandler, + NewPicTextMoreHandler, + NewPicModeChangeHandler, + NewRoleTagCardHandler, + NewRoleCardHandler, + NewAIModeCardHandler, + } + + return func(ctx context.Context, cardAction *larkcard.CardAction) (interface{}, error) { + var cardMsg CardMsg + actionValue := cardAction.Action.Value + actionValueJson, _ := json.Marshal(actionValue) + if err := json.Unmarshal(actionValueJson, &cardMsg); err != nil { + return nil, err + } + //pp.Println(cardMsg) + for _, handler := range handlers { + h := handler(cardMsg, m) + i, err := h(ctx, cardAction) + if err == ErrNextHandler { + continue + } + return i, err + } + return nil, nil + } +} diff --git a/code/handlers/card_pic_action.go b/code/handlers/card_pic_action.go new file mode 100644 index 0000000..9e4a33b --- /dev/null +++ b/code/handlers/card_pic_action.go @@ -0,0 +1,95 @@ +package handlers + +import ( + "context" + + "start-feishubot/services" + + larkcard "github.com/larksuite/oapi-sdk-go/v3/card" +) + +func NewPicResolutionHandler(cardMsg CardMsg, m MessageHandler) CardHandlerFunc { + return func(ctx context.Context, cardAction *larkcard.CardAction) (interface{}, error) { + if cardMsg.Kind == PicResolutionKind { + CommonProcessPicResolution(cardMsg, cardAction, m.sessionCache) + return nil, nil + } + return nil, ErrNextHandler + } +} + +func NewPicModeChangeHandler(cardMsg CardMsg, m MessageHandler) CardHandlerFunc { + return func(ctx context.Context, cardAction *larkcard.CardAction) (interface{}, error) { + if cardMsg.Kind == PicModeChangeKind { + newCard, err, done := CommonProcessPicModeChange(cardMsg, m.sessionCache) + if done { + return newCard, err + } + return nil, nil + } + return nil, ErrNextHandler + } +} + +func NewPicTextMoreHandler(cardMsg CardMsg, m MessageHandler) CardHandlerFunc { + return func(ctx context.Context, cardAction *larkcard.CardAction) (interface{}, error) { + if cardMsg.Kind == PicTextMoreKind { + go func() { + m.CommonProcessPicMore(cardMsg) + }() + return nil, nil + } + return nil, ErrNextHandler + } +} + +func CommonProcessPicResolution(msg CardMsg, + cardAction *larkcard.CardAction, + cache services.SessionServiceCacheInterface) { + option := cardAction.Action.Option + //fmt.Println(larkcore.Prettify(msg)) + cache.SetPicResolution(msg.SessionId, services.Resolution(option)) + //send text + replyMsg(context.Background(), "已更新图片分辨率为"+option, + &msg.MsgId) +} + +func (m MessageHandler) CommonProcessPicMore(msg CardMsg) { + resolution := m.sessionCache.GetPicResolution(msg.SessionId) + //fmt.Println("resolution: ", resolution) + //fmt.Println("msg: ", msg) + question := msg.Value.(string) + bs64, _ := m.gpt.GenerateOneImage(question, resolution) + replayImageCardByBase64(context.Background(), bs64, &msg.MsgId, + &msg.SessionId, question) +} + +func CommonProcessPicModeChange(cardMsg CardMsg, + session services.SessionServiceCacheInterface) ( + interface{}, error, bool) { + if cardMsg.Value == "1" { + + sessionId := cardMsg.SessionId + session.Clear(sessionId) + session.SetMode(sessionId, + services.ModePicCreate) + session.SetPicResolution(sessionId, + services.Resolution256) + + newCard, _ := + newSendCard( + withHeader("🖼️ 已进入图片创作模式", larkcard.TemplateBlue), + withPicResolutionBtn(&sessionId), + withNote("提醒:回复文本或图片,让AI生成相关的图片。")) + return newCard, nil, true + } + if cardMsg.Value == "0" { + newCard, _ := newSendCard( + withHeader("️🎒 机器人提醒", larkcard.TemplateGreen), + withMainMd("依旧保留此话题的上下文信息"), + withNote("我们可以继续探讨这个话题,期待和您聊天。如果您有其他问题或者想要讨论的话题,请告诉我哦"), + ) + return newCard, nil, true + } + return nil, nil, false +} diff --git a/code/handlers/card_role_action.go b/code/handlers/card_role_action.go new file mode 100644 index 0000000..6a10150 --- /dev/null +++ b/code/handlers/card_role_action.go @@ -0,0 +1,77 @@ +package handlers + +import ( + "context" + + "start-feishubot/initialization" + "start-feishubot/services" + "start-feishubot/services/openai" + + larkcard "github.com/larksuite/oapi-sdk-go/v3/card" +) + +func NewRoleTagCardHandler(cardMsg CardMsg, + m MessageHandler) CardHandlerFunc { + return func(ctx context.Context, cardAction *larkcard.CardAction) (interface{}, error) { + + if cardMsg.Kind == RoleTagsChooseKind { + newCard, err, done := CommonProcessRoleTag(cardMsg, cardAction, + m.sessionCache) + if done { + return newCard, err + } + return nil, nil + } + return nil, ErrNextHandler + } +} + +func NewRoleCardHandler(cardMsg CardMsg, + m MessageHandler) CardHandlerFunc { + return func(ctx context.Context, cardAction *larkcard.CardAction) (interface{}, error) { + + if cardMsg.Kind == RoleChooseKind { + newCard, err, done := CommonProcessRole(cardMsg, cardAction, + m.sessionCache) + if done { + return newCard, err + } + return nil, nil + } + return nil, ErrNextHandler + } +} + +func CommonProcessRoleTag(msg CardMsg, cardAction *larkcard.CardAction, + cache services.SessionServiceCacheInterface) (interface{}, + error, bool) { + option := cardAction.Action.Option + //replyMsg(context.Background(), "已选择tag:"+option, + // &msg.MsgId) + roles := initialization.GetTitleListByTag(option) + //fmt.Printf("roles: %s", roles) + SendRoleListCard(context.Background(), &msg.SessionId, + &msg.MsgId, option, *roles) + return nil, nil, true +} + +func CommonProcessRole(msg CardMsg, cardAction *larkcard.CardAction, + cache services.SessionServiceCacheInterface) (interface{}, + error, bool) { + option := cardAction.Action.Option + contentByTitle, error := initialization.GetFirstRoleContentByTitle(option) + if error != nil { + return nil, error, true + } + cache.Clear(msg.SessionId) + systemMsg := append([]openai.Messages{}, openai.Messages{ + Role: "system", Content: contentByTitle, + }) + cache.SetMsg(msg.SessionId, systemMsg) + //pp.Println("systemMsg: ", systemMsg) + sendSystemInstructionCard(context.Background(), &msg.SessionId, + &msg.MsgId, contentByTitle) + //replyMsg(context.Background(), "已选择角色:"+contentByTitle, + // &msg.MsgId) + return nil, nil, true +} diff --git a/code/handlers/common.go b/code/handlers/common.go new file mode 100644 index 0000000..0885461 --- /dev/null +++ b/code/handlers/common.go @@ -0,0 +1,200 @@ +package handlers + +import ( + "encoding/json" + "fmt" + "regexp" + "strconv" + "strings" +) + +// func sendCard +func msgFilter(msg string) string { + //replace @到下一个非空的字段 为 '' + regex := regexp.MustCompile(`@[^ ]*`) + return regex.ReplaceAllString(msg, "") + +} + +// Parse rich text json to text +func parsePostContent(content string) string { + /* + { + "title":"我是一个标题", + "content":[ + [ + { + "tag":"text", + "text":"第一行 :", + "style": ["bold", "underline"] + }, + { + "tag":"a", + "href":"http://www.feishu.cn", + "text":"超链接", + "style": ["bold", "italic"] + }, + { + "tag":"at", + "user_id":"@_user_1", + "user_name":"", + "style": [] + } + ], + [ + { + "tag":"img", + "image_key":"img_47354fbc-a159-40ed-86ab-2ad0f1acb42g" + } + ], + [ + { + "tag":"text", + "text":"第二行:", + "style": ["bold", "underline"] + }, + { + "tag":"text", + "text":"文本测试", + "style": [] + } + ], + [ + { + "tag":"img", + "image_key":"img_47354fbc-a159-40ed-86ab-2ad0f1acb42g" + } + ], + [ + { + "tag":"media", + "file_key": "file_v2_0dcdd7d9-fib0-4432-a519-41d25aca542j", + "image_key": "img_7ea74629-9191-4176-998c-2e603c9c5e8g" + } + ], + [ + { + "tag": "emotion", + "emoji_type": "SMILE" + } + ] + ] + } + */ + var contentMap map[string]interface{} + err := json.Unmarshal([]byte(content), &contentMap) + + if err != nil { + fmt.Println(err) + } + + if contentMap["content"] == nil { + return "" + } + var text string + // deal with title + if contentMap["title"] != nil && contentMap["title"] != "" { + text += contentMap["title"].(string) + "\n" + } + // deal with content + contentList := contentMap["content"].([]interface{}) + for _, v := range contentList { + for _, v1 := range v.([]interface{}) { + if v1.(map[string]interface{})["tag"] == "text" { + text += v1.(map[string]interface{})["text"].(string) + } + } + // add new line + text += "\n" + } + return msgFilter(text) +} + +func parseContent(content, msgType string) string { + //"{\"text\":\"@_user_1 hahaha\"}", + //only get text content hahaha + if msgType == "post" { + return parsePostContent(content) + } + + var contentMap map[string]interface{} + err := json.Unmarshal([]byte(content), &contentMap) + if err != nil { + fmt.Println(err) + } + if contentMap["text"] == nil { + return "" + } + text := contentMap["text"].(string) + return msgFilter(text) +} + +func processMessage(msg interface{}) (string, error) { + msg = strings.TrimSpace(msg.(string)) + msgB, err := json.Marshal(msg) + if err != nil { + return "", err + } + + msgStr := string(msgB) + + if len(msgStr) >= 2 { + msgStr = msgStr[1 : len(msgStr)-1] + } + return msgStr, nil +} + +func processNewLine(msg string) string { + return strings.Replace(msg, "\\n", ` +`, -1) +} + +func processQuote(msg string) string { + return strings.Replace(msg, "\\\"", "\"", -1) +} + +// 将字符中 \u003c 替换为 < 等等 +func processUnicode(msg string) string { + regex := regexp.MustCompile(`\\u[0-9a-fA-F]{4}`) + return regex.ReplaceAllStringFunc(msg, func(s string) string { + r, _ := regexp.Compile(`\\u`) + s = r.ReplaceAllString(s, "") + i, _ := strconv.ParseInt(s, 16, 32) + return string(rune(i)) + }) +} + +func cleanTextBlock(msg string) string { + msg = processNewLine(msg) + msg = processUnicode(msg) + msg = processQuote(msg) + return msg +} + +func parseFileKey(content string) string { + var contentMap map[string]interface{} + err := json.Unmarshal([]byte(content), &contentMap) + if err != nil { + fmt.Println(err) + return "" + } + if contentMap["file_key"] == nil { + return "" + } + fileKey := contentMap["file_key"].(string) + return fileKey +} + +func parseImageKey(content string) string { + var contentMap map[string]interface{} + err := json.Unmarshal([]byte(content), &contentMap) + if err != nil { + fmt.Println(err) + return "" + } + if contentMap["image_key"] == nil { + return "" + } + imageKey := contentMap["image_key"].(string) + return imageKey +} diff --git a/code/handlers/event_audio_action.go b/code/handlers/event_audio_action.go new file mode 100644 index 0000000..e01bce2 --- /dev/null +++ b/code/handlers/event_audio_action.go @@ -0,0 +1,69 @@ +package handlers + +import ( + "context" + "fmt" + "os" + + "start-feishubot/initialization" + "start-feishubot/utils/audio" + + larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1" +) + +type AudioAction struct { /*语音*/ +} + +func (*AudioAction) Execute(a *ActionInfo) bool { + check := AzureModeCheck(a) + if !check { + return true + } + + // 只有私聊才解析语音,其他不解析 + if a.info.handlerType != UserHandler { + return true + } + + //判断是否是语音 + if a.info.msgType == "audio" { + fileKey := a.info.fileKey + //fmt.Printf("fileKey: %s \n", fileKey) + msgId := a.info.msgId + //fmt.Println("msgId: ", *msgId) + req := larkim.NewGetMessageResourceReqBuilder().MessageId( + *msgId).FileKey(fileKey).Type("file").Build() + resp, err := initialization.GetLarkClient().Im.MessageResource.Get(context.Background(), req) + //fmt.Println(resp, err) + if err != nil { + fmt.Println(err) + return true + } + f := fmt.Sprintf("%s.ogg", fileKey) + resp.WriteFile(f) + defer os.Remove(f) + + //fmt.Println("f: ", f) + output := fmt.Sprintf("%s.mp3", fileKey) + // 等待转换完成 + audio.OggToWavByPath(f, output) + defer os.Remove(output) + //fmt.Println("output: ", output) + + text, err := a.handler.gpt.AudioToText(output) + if err != nil { + fmt.Println(err) + + sendMsg(*a.ctx, fmt.Sprintf("🤖️:语音转换失败,请稍后再试~\n错误信息: %v", err), a.info.msgId) + return false + } + + replyMsg(*a.ctx, fmt.Sprintf("🤖️:%s", text), a.info.msgId) + //fmt.Println("text: ", text) + a.info.qParsed = text + return true + } + + return true + +} diff --git a/code/handlers/event_common_action.go b/code/handlers/event_common_action.go new file mode 100644 index 0000000..4f79e16 --- /dev/null +++ b/code/handlers/event_common_action.go @@ -0,0 +1,167 @@ +package handlers + +import ( + "context" + "fmt" + + "start-feishubot/initialization" + "start-feishubot/services/openai" + "start-feishubot/utils" + + larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1" +) + +type MsgInfo struct { + handlerType HandlerType + msgType string + msgId *string + chatId *string + qParsed string + fileKey string + imageKey string + sessionId *string + mention []*larkim.MentionEvent +} +type ActionInfo struct { + handler *MessageHandler + ctx *context.Context + info *MsgInfo +} + +type Action interface { + Execute(a *ActionInfo) bool +} + +type ProcessedUniqueAction struct { //消息唯一性 +} + +func (*ProcessedUniqueAction) Execute(a *ActionInfo) bool { + if a.handler.msgCache.IfProcessed(*a.info.msgId) { + return false + } + a.handler.msgCache.TagProcessed(*a.info.msgId) + return true +} + +type ProcessMentionAction struct { //是否机器人应该处理 +} + +func (*ProcessMentionAction) Execute(a *ActionInfo) bool { + // 私聊直接过 + if a.info.handlerType == UserHandler { + return true + } + // 群聊判断是否提到机器人 + if a.info.handlerType == GroupHandler { + if a.handler.judgeIfMentionMe(a.info.mention) { + return true + } + return false + } + return false +} + +type EmptyAction struct { /*空消息*/ +} + +func (*EmptyAction) Execute(a *ActionInfo) bool { + if len(a.info.qParsed) == 0 { + sendMsg(*a.ctx, "🤖️:你想知道什么呢~", a.info.chatId) + fmt.Println("msgId", *a.info.msgId, + "message.text is empty") + return false + } + return true +} + +type ClearAction struct { /*清除消息*/ +} + +func (*ClearAction) Execute(a *ActionInfo) bool { + if _, foundClear := utils.EitherTrimEqual(a.info.qParsed, + "/clear", "清除"); foundClear { + sendClearCacheCheckCard(*a.ctx, a.info.sessionId, + a.info.msgId) + return false + } + return true +} + +type RolePlayAction struct { /*角色扮演*/ +} + +func (*RolePlayAction) Execute(a *ActionInfo) bool { + if system, foundSystem := utils.EitherCutPrefix(a.info.qParsed, + "/system ", "角色扮演 "); foundSystem { + a.handler.sessionCache.Clear(*a.info.sessionId) + systemMsg := append([]openai.Messages{}, openai.Messages{ + Role: "system", Content: system, + }) + a.handler.sessionCache.SetMsg(*a.info.sessionId, systemMsg) + sendSystemInstructionCard(*a.ctx, a.info.sessionId, + a.info.msgId, system) + return false + } + return true +} + +type HelpAction struct { /*帮助*/ +} + +func (*HelpAction) Execute(a *ActionInfo) bool { + if _, foundHelp := utils.EitherTrimEqual(a.info.qParsed, "/help", + "帮助"); foundHelp { + sendHelpCard(*a.ctx, a.info.sessionId, a.info.msgId) + return false + } + return true +} + +type BalanceAction struct { /*余额*/ +} + +func (*BalanceAction) Execute(a *ActionInfo) bool { + if _, foundBalance := utils.EitherTrimEqual(a.info.qParsed, + "/balance", "余额"); foundBalance { + balanceResp, err := a.handler.gpt.GetBalance() + if err != nil { + replyMsg(*a.ctx, "查询余额失败,请稍后再试", a.info.msgId) + return false + } + sendBalanceCard(*a.ctx, a.info.sessionId, *balanceResp) + return false + } + return true +} + +type RoleListAction struct { /*角色列表*/ +} + +func (*RoleListAction) Execute(a *ActionInfo) bool { + if _, foundSystem := utils.EitherTrimEqual(a.info.qParsed, + "/roles", "角色列表"); foundSystem { + //a.handler.sessionCache.Clear(*a.info.sessionId) + //systemMsg := append([]openai.Messages{}, openai.Messages{ + // Role: "system", Content: system, + //}) + //a.handler.sessionCache.SetMsg(*a.info.sessionId, systemMsg) + //sendSystemInstructionCard(*a.ctx, a.info.sessionId, + // a.info.msgId, system) + tags := initialization.GetAllUniqueTags() + SendRoleTagsCard(*a.ctx, a.info.sessionId, a.info.msgId, *tags) + return false + } + return true +} + +type AIModeAction struct { /*AI模式*/ +} + +func (*AIModeAction) Execute(a *ActionInfo) bool { + if _, foundMode := utils.EitherCutPrefix(a.info.qParsed, + "/ai_mode", "AI模式"); foundMode { + SendAIModeListsCard(*a.ctx, a.info.sessionId, a.info.msgId, openai.AIModeStrs) + return false + } + return true +} diff --git a/code/handlers/event_msg_action.go b/code/handlers/event_msg_action.go new file mode 100644 index 0000000..7175541 --- /dev/null +++ b/code/handlers/event_msg_action.go @@ -0,0 +1,41 @@ +package handlers + +import ( + "fmt" + + "start-feishubot/services/openai" +) + +type MessageAction struct { /*消息*/ +} + +func (*MessageAction) Execute(a *ActionInfo) bool { + msg := a.handler.sessionCache.GetMsg(*a.info.sessionId) + msg = append(msg, openai.Messages{ + Role: "user", Content: a.info.qParsed, + }) + // get ai mode as temperature + aiMode := a.handler.sessionCache.GetAIMode(*a.info.sessionId) + completions, err := a.handler.gpt.Completions(msg, aiMode) + if err != nil { + replyMsg(*a.ctx, fmt.Sprintf( + "🤖️:消息机器人摆烂了,请稍后再试~\n错误信息: %v", err), a.info.msgId) + return false + } + msg = append(msg, completions) + a.handler.sessionCache.SetMsg(*a.info.sessionId, msg) + //if new topic + if len(msg) == 2 { + //fmt.Println("new topic", msg[1].Content) + sendNewTopicCard(*a.ctx, a.info.sessionId, a.info.msgId, + completions.Content) + return false + } + err = replyMsg(*a.ctx, completions.Content, a.info.msgId) + if err != nil { + replyMsg(*a.ctx, fmt.Sprintf( + "🤖️:消息机器人摆烂了,请稍后再试~\n错误信息: %v", err), a.info.msgId) + return false + } + return true +} diff --git a/code/handlers/event_pic_action.go b/code/handlers/event_pic_action.go new file mode 100644 index 0000000..0fb6939 --- /dev/null +++ b/code/handlers/event_pic_action.go @@ -0,0 +1,107 @@ +package handlers + +import ( + "context" + "fmt" + "os" + + "start-feishubot/initialization" + "start-feishubot/services" + "start-feishubot/services/openai" + "start-feishubot/utils" + + larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1" +) + +type PicAction struct { /*图片*/ +} + +func (*PicAction) Execute(a *ActionInfo) bool { + check := AzureModeCheck(a) + if !check { + return true + } + // 开启图片创作模式 + if _, foundPic := utils.EitherTrimEqual(a.info.qParsed, + "/picture", "图片创作"); foundPic { + a.handler.sessionCache.Clear(*a.info.sessionId) + a.handler.sessionCache.SetMode(*a.info.sessionId, + services.ModePicCreate) + a.handler.sessionCache.SetPicResolution(*a.info.sessionId, + services.Resolution256) + sendPicCreateInstructionCard(*a.ctx, a.info.sessionId, + a.info.msgId) + return false + } + + mode := a.handler.sessionCache.GetMode(*a.info.sessionId) + //fmt.Println("mode: ", mode) + + // 收到一张图片,且不在图片创作模式下, 提醒是否切换到图片创作模式 + if a.info.msgType == "image" && mode != services.ModePicCreate { + sendPicModeCheckCard(*a.ctx, a.info.sessionId, a.info.msgId) + return false + } + + if a.info.msgType == "image" && mode == services.ModePicCreate { + //保存图片 + imageKey := a.info.imageKey + //fmt.Printf("fileKey: %s \n", imageKey) + msgId := a.info.msgId + //fmt.Println("msgId: ", *msgId) + req := larkim.NewGetMessageResourceReqBuilder().MessageId( + *msgId).FileKey(imageKey).Type("image").Build() + resp, err := initialization.GetLarkClient().Im.MessageResource.Get(context.Background(), req) + //fmt.Println(resp, err) + if err != nil { + //fmt.Println(err) + replyMsg(*a.ctx, fmt.Sprintf("🤖️:图片下载失败,请稍后再试~\n 错误信息: %v", err), + a.info.msgId) + return false + } + + f := fmt.Sprintf("%s.png", imageKey) + resp.WriteFile(f) + defer os.Remove(f) + resolution := a.handler.sessionCache.GetPicResolution(*a. + info.sessionId) + + openai.ConvertJpegToPNG(f) + openai.ConvertToRGBA(f, f) + + //图片校验 + err = openai.VerifyPngs([]string{f}) + if err != nil { + replyMsg(*a.ctx, fmt.Sprintf("🤖️:无法解析图片,请发送原图并尝试重新操作~"), + a.info.msgId) + return false + } + bs64, err := a.handler.gpt.GenerateOneImageVariation(f, resolution) + if err != nil { + replyMsg(*a.ctx, fmt.Sprintf( + "🤖️:图片生成失败,请稍后再试~\n错误信息: %v", err), a.info.msgId) + return false + } + replayImagePlainByBase64(*a.ctx, bs64, a.info.msgId) + return false + + } + + // 生成图片 + if mode == services.ModePicCreate { + resolution := a.handler.sessionCache.GetPicResolution(*a. + info.sessionId) + bs64, err := a.handler.gpt.GenerateOneImage(a.info.qParsed, + resolution) + if err != nil { + replyMsg(*a.ctx, fmt.Sprintf( + "🤖️:图片生成失败,请稍后再试~\n错误信息: %v", err), a.info.msgId) + return false + } + replayImageCardByBase64(*a.ctx, bs64, a.info.msgId, a.info.sessionId, + a.info.qParsed) + return false + } + + return true +} diff --git a/code/handlers/handler.go b/code/handlers/handler.go new file mode 100644 index 0000000..240d8f4 --- /dev/null +++ b/code/handlers/handler.go @@ -0,0 +1,135 @@ +package handlers + +import ( + "context" + "fmt" + "strings" + + "start-feishubot/initialization" + "start-feishubot/services" + "start-feishubot/services/openai" + + larkcard "github.com/larksuite/oapi-sdk-go/v3/card" + larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1" +) + +// 责任链 +func chain(data *ActionInfo, actions ...Action) bool { + for _, v := range actions { + if !v.Execute(data) { + return false + } + } + return true +} + +type MessageHandler struct { + sessionCache services.SessionServiceCacheInterface + msgCache services.MsgCacheInterface + gpt *openai.ChatGPT + config initialization.Config +} + +func (m MessageHandler) cardHandler(ctx context.Context, + cardAction *larkcard.CardAction) (interface{}, error) { + messageHandler := NewCardHandler(m) + return messageHandler(ctx, cardAction) +} + +func judgeMsgType(event *larkim.P2MessageReceiveV1) (string, error) { + msgType := event.Event.Message.MessageType + + switch *msgType { + case "text", "image", "audio", "post": + return *msgType, nil + default: + return "", fmt.Errorf("unknown message type: %v", *msgType) + } +} + +func (m MessageHandler) msgReceivedHandler(ctx context.Context, event *larkim.P2MessageReceiveV1) error { + handlerType := judgeChatType(event) + if handlerType == "otherChat" { + fmt.Println("unknown chat type") + return nil + } + //fmt.Println(larkcore.Prettify(event.Event.Message)) + + msgType, err := judgeMsgType(event) + if err != nil { + fmt.Printf("error getting message type: %v\n", err) + return nil + } + + content := event.Event.Message.Content + msgId := event.Event.Message.MessageId + rootId := event.Event.Message.RootId + chatId := event.Event.Message.ChatId + mention := event.Event.Message.Mentions + + sessionId := rootId + if sessionId == nil || *sessionId == "" { + sessionId = msgId + } + msgInfo := MsgInfo{ + handlerType: handlerType, + msgType: msgType, + msgId: msgId, + chatId: chatId, + qParsed: strings.Trim(parseContent(*content, msgType), " "), + fileKey: parseFileKey(*content), + imageKey: parseImageKey(*content), + sessionId: sessionId, + mention: mention, + } + data := &ActionInfo{ + ctx: &ctx, + handler: &m, + info: &msgInfo, + } + actions := []Action{ + &ProcessedUniqueAction{}, //避免重复处理 + &ProcessMentionAction{}, //判断机器人是否应该被调用 + &AudioAction{}, //语音处理 + &EmptyAction{}, //空消息处理 + &ClearAction{}, //清除消息处理 + &PicAction{}, //图片处理 + &AIModeAction{}, //模式切换处理 + &RoleListAction{}, //角色列表处理 + &HelpAction{}, //帮助处理 + &BalanceAction{}, //余额处理 + &RolePlayAction{}, //角色扮演处理 + &MessageAction{}, //消息处理 + + } + chain(data, actions...) + return nil +} + +var _ MessageHandlerInterface = (*MessageHandler)(nil) + +func NewMessageHandler(gpt *openai.ChatGPT, + config initialization.Config) MessageHandlerInterface { + return &MessageHandler{ + sessionCache: services.GetSessionCache(), + msgCache: services.GetMsgCache(), + gpt: gpt, + config: config, + } +} + +func (m MessageHandler) judgeIfMentionMe(mention []*larkim. + MentionEvent) bool { + if len(mention) != 1 { + return false + } + return *mention[0].Name == m.config.FeishuBotName +} + +func AzureModeCheck(a *ActionInfo) bool { + if a.handler.config.AzureOn { + //sendMsg(*a.ctx, "Azure Openai 接口下,暂不支持此功能", a.info.chatId) + return false + } + return true +} diff --git a/code/handlers/init.go b/code/handlers/init.go new file mode 100644 index 0000000..5589359 --- /dev/null +++ b/code/handlers/init.go @@ -0,0 +1,72 @@ +package handlers + +import ( + "context" + + "start-feishubot/initialization" + "start-feishubot/services/openai" + + larkcard "github.com/larksuite/oapi-sdk-go/v3/card" + larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1" +) + +type MessageHandlerInterface interface { + msgReceivedHandler(ctx context.Context, event *larkim.P2MessageReceiveV1) error + cardHandler(ctx context.Context, cardAction *larkcard.CardAction) (interface{}, error) +} + +type HandlerType string + +const ( + GroupHandler = "group" + UserHandler = "personal" +) + +// handlers 所有消息类型类型的处理器 +var handlers MessageHandlerInterface + +func InitHandlers(gpt *openai.ChatGPT, config initialization.Config) { + handlers = NewMessageHandler(gpt, config) +} + +func Handler(ctx context.Context, event *larkim.P2MessageReceiveV1) error { + return handlers.msgReceivedHandler(ctx, event) +} + +func ReadHandler(ctx context.Context, event *larkim.P2MessageReadV1) error { + _ = event.Event.Reader.ReaderId.OpenId + //fmt.Printf("msg is read by : %v \n", *readerId) + return nil +} + +func CardHandler() func(ctx context.Context, + cardAction *larkcard.CardAction) (interface{}, error) { + return func(ctx context.Context, cardAction *larkcard.CardAction) (interface{}, error) { + //handlerType := judgeCardType(cardAction) + return handlers.cardHandler(ctx, cardAction) + } +} + +func judgeCardType(cardAction *larkcard.CardAction) HandlerType { + actionValue := cardAction.Action.Value + chatType := actionValue["chatType"] + //fmt.Printf("chatType: %v", chatType) + if chatType == "group" { + return GroupHandler + } + if chatType == "personal" { + return UserHandler + } + return "otherChat" +} + +func judgeChatType(event *larkim.P2MessageReceiveV1) HandlerType { + chatType := event.Event.Message.ChatType + if *chatType == "group" { + return GroupHandler + } + if *chatType == "p2p" { + return UserHandler + } + return "otherChat" +} diff --git a/code/handlers/msg.go b/code/handlers/msg.go new file mode 100644 index 0000000..cc73842 --- /dev/null +++ b/code/handlers/msg.go @@ -0,0 +1,780 @@ +package handlers + +import ( + "bytes" + "context" + "encoding/base64" + "errors" + "fmt" + + "start-feishubot/initialization" + "start-feishubot/services" + "start-feishubot/services/openai" + + "github.com/google/uuid" + larkcard "github.com/larksuite/oapi-sdk-go/v3/card" + larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1" +) + +type CardKind string +type CardChatType string + +var ( + ClearCardKind = CardKind("clear") // 清空上下文 + PicModeChangeKind = CardKind("pic_mode_change") // 切换图片创作模式 + PicResolutionKind = CardKind("pic_resolution") // 图片分辨率调整 + PicTextMoreKind = CardKind("pic_text_more") // 重新根据文本生成图片 + PicVarMoreKind = CardKind("pic_var_more") // 变量图片 + RoleTagsChooseKind = CardKind("role_tags_choose") // 内置角色所属标签选择 + RoleChooseKind = CardKind("role_choose") // 内置角色选择 + AIModeChooseKind = CardKind("ai_mode_choose") // AI模式选择 +) + +var ( + GroupChatType = CardChatType("group") + UserChatType = CardChatType("personal") +) + +type CardMsg struct { + Kind CardKind + ChatType CardChatType + Value interface{} + SessionId string + MsgId string +} + +type MenuOption struct { + value string + label string +} + +func replyCard(ctx context.Context, + msgId *string, + cardContent string, +) error { + client := initialization.GetLarkClient() + resp, err := client.Im.Message.Reply(ctx, larkim.NewReplyMessageReqBuilder(). + MessageId(*msgId). + Body(larkim.NewReplyMessageReqBodyBuilder(). + MsgType(larkim.MsgTypeInteractive). + Uuid(uuid.New().String()). + Content(cardContent). + Build()). + Build()) + + // 处理错误 + if err != nil { + fmt.Println(err) + return err + } + + // 服务端错误处理 + if !resp.Success() { + fmt.Println(resp.Code, resp.Msg, resp.RequestId()) + return errors.New(resp.Msg) + } + return nil +} + +func newSendCard( + header *larkcard.MessageCardHeader, + elements ...larkcard.MessageCardElement) (string, + error) { + config := larkcard.NewMessageCardConfig(). + WideScreenMode(false). + EnableForward(true). + UpdateMulti(false). + Build() + var aElementPool []larkcard.MessageCardElement + for _, element := range elements { + aElementPool = append(aElementPool, element) + } + // 卡片消息体 + cardContent, err := larkcard.NewMessageCard(). + Config(config). + Header(header). + Elements( + aElementPool, + ). + String() + return cardContent, err +} + +func newSimpleSendCard( + elements ...larkcard.MessageCardElement) (string, + error) { + config := larkcard.NewMessageCardConfig(). + WideScreenMode(false). + EnableForward(true). + UpdateMulti(false). + Build() + var aElementPool []larkcard.MessageCardElement + for _, element := range elements { + aElementPool = append(aElementPool, element) + } + // 卡片消息体 + cardContent, err := larkcard.NewMessageCard(). + Config(config). + Elements( + aElementPool, + ). + String() + return cardContent, err +} + +// withSplitLine 用于生成分割线 +func withSplitLine() larkcard.MessageCardElement { + splitLine := larkcard.NewMessageCardHr(). + Build() + return splitLine +} + +// withHeader 用于生成消息头 +func withHeader(title string, color string) *larkcard. + MessageCardHeader { + if title == "" { + title = "🤖️机器人提醒" + } + header := larkcard.NewMessageCardHeader(). + Template(color). + Title(larkcard.NewMessageCardPlainText(). + Content(title). + Build()). + Build() + return header +} + +// withNote 用于生成纯文本脚注 +func withNote(note string) larkcard.MessageCardElement { + noteElement := larkcard.NewMessageCardNote(). + Elements([]larkcard.MessageCardNoteElement{larkcard.NewMessageCardPlainText(). + Content(note). + Build()}). + Build() + return noteElement +} + +// withMainMd 用于生成markdown消息体 +func withMainMd(msg string) larkcard.MessageCardElement { + msg, i := processMessage(msg) + msg = processNewLine(msg) + if i != nil { + return nil + } + mainElement := larkcard.NewMessageCardDiv(). + Fields([]*larkcard.MessageCardField{larkcard.NewMessageCardField(). + Text(larkcard.NewMessageCardLarkMd(). + Content(msg). + Build()). + IsShort(true). + Build()}). + Build() + return mainElement +} + +// withMainText 用于生成纯文本消息体 +func withMainText(msg string) larkcard.MessageCardElement { + msg, i := processMessage(msg) + msg = cleanTextBlock(msg) + if i != nil { + return nil + } + mainElement := larkcard.NewMessageCardDiv(). + Fields([]*larkcard.MessageCardField{larkcard.NewMessageCardField(). + Text(larkcard.NewMessageCardPlainText(). + Content(msg). + Build()). + IsShort(false). + Build()}). + Build() + return mainElement +} + +func withImageDiv(imageKey string) larkcard.MessageCardElement { + imageElement := larkcard.NewMessageCardImage(). + ImgKey(imageKey). + Alt(larkcard.NewMessageCardPlainText().Content(""). + Build()). + Preview(true). + Mode(larkcard.MessageCardImageModelCropCenter). + CompactWidth(true). + Build() + return imageElement +} + +// withMdAndExtraBtn 用于生成带有额外按钮的消息体 +func withMdAndExtraBtn(msg string, btn *larkcard. + MessageCardEmbedButton) larkcard.MessageCardElement { + msg, i := processMessage(msg) + msg = processNewLine(msg) + if i != nil { + return nil + } + mainElement := larkcard.NewMessageCardDiv(). + Fields( + []*larkcard.MessageCardField{ + larkcard.NewMessageCardField(). + Text(larkcard.NewMessageCardLarkMd(). + Content(msg). + Build()). + IsShort(true). + Build()}). + Extra(btn). + Build() + return mainElement +} + +func newBtn(content string, value map[string]interface{}, + typename larkcard.MessageCardButtonType) *larkcard. + MessageCardEmbedButton { + btn := larkcard.NewMessageCardEmbedButton(). + Type(typename). + Value(value). + Text(larkcard.NewMessageCardPlainText(). + Content(content). + Build()) + return btn +} + +func newMenu( + placeHolder string, + value map[string]interface{}, + options ...MenuOption, +) *larkcard. + MessageCardEmbedSelectMenuStatic { + var aOptionPool []*larkcard.MessageCardEmbedSelectOption + for _, option := range options { + aOption := larkcard.NewMessageCardEmbedSelectOption(). + Value(option.value). + Text(larkcard.NewMessageCardPlainText(). + Content(option.label). + Build()) + aOptionPool = append(aOptionPool, aOption) + + } + btn := larkcard.NewMessageCardEmbedSelectMenuStatic(). + MessageCardEmbedSelectMenuStatic(larkcard.NewMessageCardEmbedSelectMenuBase(). + Options(aOptionPool). + Placeholder(larkcard.NewMessageCardPlainText(). + Content(placeHolder). + Build()). + Value(value). + Build()). + Build() + return btn +} + +// 清除卡片按钮 +func withClearDoubleCheckBtn(sessionID *string) larkcard.MessageCardElement { + confirmBtn := newBtn("确认清除", map[string]interface{}{ + "value": "1", + "kind": ClearCardKind, + "chatType": UserChatType, + "sessionId": *sessionID, + }, larkcard.MessageCardButtonTypeDanger, + ) + cancelBtn := newBtn("我再想想", map[string]interface{}{ + "value": "0", + "kind": ClearCardKind, + "sessionId": *sessionID, + "chatType": UserChatType, + }, + larkcard.MessageCardButtonTypeDefault) + + actions := larkcard.NewMessageCardAction(). + Actions([]larkcard.MessageCardActionElement{confirmBtn, cancelBtn}). + Layout(larkcard.MessageCardActionLayoutBisected.Ptr()). + Build() + + return actions +} + +func withPicModeDoubleCheckBtn(sessionID *string) larkcard. + MessageCardElement { + confirmBtn := newBtn("切换模式", map[string]interface{}{ + "value": "1", + "kind": PicModeChangeKind, + "chatType": UserChatType, + "sessionId": *sessionID, + }, larkcard.MessageCardButtonTypeDanger, + ) + cancelBtn := newBtn("我再想想", map[string]interface{}{ + "value": "0", + "kind": PicModeChangeKind, + "sessionId": *sessionID, + "chatType": UserChatType, + }, + larkcard.MessageCardButtonTypeDefault) + + actions := larkcard.NewMessageCardAction(). + Actions([]larkcard.MessageCardActionElement{confirmBtn, cancelBtn}). + Layout(larkcard.MessageCardActionLayoutBisected.Ptr()). + Build() + + return actions +} + +func withOneBtn(btn *larkcard.MessageCardEmbedButton) larkcard. + MessageCardElement { + actions := larkcard.NewMessageCardAction(). + Actions([]larkcard.MessageCardActionElement{btn}). + Layout(larkcard.MessageCardActionLayoutFlow.Ptr()). + Build() + return actions +} + +//新建对话按钮 + +func withPicResolutionBtn(sessionID *string) larkcard. + MessageCardElement { + cancelMenu := newMenu("默认分辨率", + map[string]interface{}{ + "value": "0", + "kind": PicResolutionKind, + "sessionId": *sessionID, + "msgId": *sessionID, + }, + MenuOption{ + label: "256x256", + value: string(services.Resolution256), + }, + MenuOption{ + label: "512x512", + value: string(services.Resolution512), + }, + MenuOption{ + label: "1024x1024", + value: string(services.Resolution1024), + }, + ) + + actions := larkcard.NewMessageCardAction(). + Actions([]larkcard.MessageCardActionElement{cancelMenu}). + Layout(larkcard.MessageCardActionLayoutFlow.Ptr()). + Build() + return actions +} + +func withRoleTagsBtn(sessionID *string, tags ...string) larkcard. + MessageCardElement { + var menuOptions []MenuOption + + for _, tag := range tags { + menuOptions = append(menuOptions, MenuOption{ + label: tag, + value: tag, + }) + } + cancelMenu := newMenu("选择角色分类", + map[string]interface{}{ + "value": "0", + "kind": RoleTagsChooseKind, + "sessionId": *sessionID, + "msgId": *sessionID, + }, + menuOptions..., + ) + + actions := larkcard.NewMessageCardAction(). + Actions([]larkcard.MessageCardActionElement{cancelMenu}). + Layout(larkcard.MessageCardActionLayoutFlow.Ptr()). + Build() + return actions +} + +func withRoleBtn(sessionID *string, titles ...string) larkcard. + MessageCardElement { + var menuOptions []MenuOption + + for _, tag := range titles { + menuOptions = append(menuOptions, MenuOption{ + label: tag, + value: tag, + }) + } + cancelMenu := newMenu("查看内置角色", + map[string]interface{}{ + "value": "0", + "kind": RoleChooseKind, + "sessionId": *sessionID, + "msgId": *sessionID, + }, + menuOptions..., + ) + + actions := larkcard.NewMessageCardAction(). + Actions([]larkcard.MessageCardActionElement{cancelMenu}). + Layout(larkcard.MessageCardActionLayoutFlow.Ptr()). + Build() + return actions +} + +func withAIModeBtn(sessionID *string, aiModeStrs []string) larkcard.MessageCardElement { + var menuOptions []MenuOption + for _, label := range aiModeStrs { + menuOptions = append(menuOptions, MenuOption{ + label: label, + value: label, + }) + } + + cancelMenu := newMenu("选择模式", + map[string]interface{}{ + "value": "0", + "kind": AIModeChooseKind, + "sessionId": *sessionID, + "msgId": *sessionID, + }, + menuOptions..., + ) + + actions := larkcard.NewMessageCardAction(). + Actions([]larkcard.MessageCardActionElement{cancelMenu}). + Layout(larkcard.MessageCardActionLayoutFlow.Ptr()). + Build() + return actions +} + +func replyMsg(ctx context.Context, msg string, msgId *string) error { + msg, i := processMessage(msg) + if i != nil { + return i + } + client := initialization.GetLarkClient() + content := larkim.NewTextMsgBuilder(). + Text(msg). + Build() + + resp, err := client.Im.Message.Reply(ctx, larkim.NewReplyMessageReqBuilder(). + MessageId(*msgId). + Body(larkim.NewReplyMessageReqBodyBuilder(). + MsgType(larkim.MsgTypeText). + Uuid(uuid.New().String()). + Content(content). + Build()). + Build()) + + // 处理错误 + if err != nil { + fmt.Println(err) + return err + } + + // 服务端错误处理 + if !resp.Success() { + fmt.Println(resp.Code, resp.Msg, resp.RequestId()) + return errors.New(resp.Msg) + } + return nil +} + +func uploadImage(base64Str string) (*string, error) { + imageBytes, err := base64.StdEncoding.DecodeString(base64Str) + if err != nil { + fmt.Println(err) + return nil, err + } + client := initialization.GetLarkClient() + resp, err := client.Im.Image.Create(context.Background(), + larkim.NewCreateImageReqBuilder(). + Body(larkim.NewCreateImageReqBodyBuilder(). + ImageType(larkim.ImageTypeMessage). + Image(bytes.NewReader(imageBytes)). + Build()). + Build()) + + // 处理错误 + if err != nil { + fmt.Println(err) + return nil, err + } + + // 服务端错误处理 + if !resp.Success() { + fmt.Println(resp.Code, resp.Msg, resp.RequestId()) + return nil, errors.New(resp.Msg) + } + return resp.Data.ImageKey, nil +} + +func replyImage(ctx context.Context, ImageKey *string, + msgId *string) error { + //fmt.Println("sendMsg", ImageKey, msgId) + + msgImage := larkim.MessageImage{ImageKey: *ImageKey} + content, err := msgImage.String() + if err != nil { + fmt.Println(err) + return err + } + client := initialization.GetLarkClient() + + resp, err := client.Im.Message.Reply(ctx, larkim.NewReplyMessageReqBuilder(). + MessageId(*msgId). + Body(larkim.NewReplyMessageReqBodyBuilder(). + MsgType(larkim.MsgTypeImage). + Uuid(uuid.New().String()). + Content(content). + Build()). + Build()) + + // 处理错误 + if err != nil { + fmt.Println(err) + return err + } + + // 服务端错误处理 + if !resp.Success() { + fmt.Println(resp.Code, resp.Msg, resp.RequestId()) + return errors.New(resp.Msg) + } + return nil +} + +func replayImageCardByBase64(ctx context.Context, base64Str string, + msgId *string, sessionId *string, question string) error { + imageKey, err := uploadImage(base64Str) + if err != nil { + return err + } + //example := "img_v2_041b28e3-5680-48c2-9af2-497ace79333g" + //imageKey := &example + //fmt.Println("imageKey", *imageKey) + err = sendImageCard(ctx, *imageKey, msgId, sessionId, question) + if err != nil { + return err + } + return nil +} + +func replayImagePlainByBase64(ctx context.Context, base64Str string, + msgId *string) error { + imageKey, err := uploadImage(base64Str) + if err != nil { + return err + } + //example := "img_v2_041b28e3-5680-48c2-9af2-497ace79333g" + //imageKey := &example + //fmt.Println("imageKey", *imageKey) + err = replyImage(ctx, imageKey, msgId) + if err != nil { + return err + } + return nil +} + +func replayVariantImageByBase64(ctx context.Context, base64Str string, + msgId *string, sessionId *string) error { + imageKey, err := uploadImage(base64Str) + if err != nil { + return err + } + //example := "img_v2_041b28e3-5680-48c2-9af2-497ace79333g" + //imageKey := &example + //fmt.Println("imageKey", *imageKey) + err = sendVarImageCard(ctx, *imageKey, msgId, sessionId) + if err != nil { + return err + } + return nil +} + +func sendMsg(ctx context.Context, msg string, chatId *string) error { + //fmt.Println("sendMsg", msg, chatId) + msg, i := processMessage(msg) + if i != nil { + return i + } + client := initialization.GetLarkClient() + content := larkim.NewTextMsgBuilder(). + Text(msg). + Build() + + //fmt.Println("content", content) + + resp, err := client.Im.Message.Create(ctx, larkim.NewCreateMessageReqBuilder(). + ReceiveIdType(larkim.ReceiveIdTypeChatId). + Body(larkim.NewCreateMessageReqBodyBuilder(). + MsgType(larkim.MsgTypeText). + ReceiveId(*chatId). + Content(content). + Build()). + Build()) + + // 处理错误 + if err != nil { + fmt.Println(err) + return err + } + + // 服务端错误处理 + if !resp.Success() { + fmt.Println(resp.Code, resp.Msg, resp.RequestId()) + return errors.New(resp.Msg) + } + return nil +} + +func sendClearCacheCheckCard(ctx context.Context, + sessionId *string, msgId *string) { + newCard, _ := newSendCard( + withHeader("🆑 机器人提醒", larkcard.TemplateBlue), + withMainMd("您确定要清除对话上下文吗?"), + withNote("请注意,这将开始一个全新的对话,您将无法利用之前话题的历史信息"), + withClearDoubleCheckBtn(sessionId)) + replyCard(ctx, msgId, newCard) +} + +func sendSystemInstructionCard(ctx context.Context, + sessionId *string, msgId *string, content string) { + newCard, _ := newSendCard( + withHeader("🥷 已进入角色扮演模式", larkcard.TemplateIndigo), + withMainText(content), + withNote("请注意,这将开始一个全新的对话,您将无法利用之前话题的历史信息")) + replyCard(ctx, msgId, newCard) +} + +func sendPicCreateInstructionCard(ctx context.Context, + sessionId *string, msgId *string) { + newCard, _ := newSendCard( + withHeader("🖼️ 已进入图片创作模式", larkcard.TemplateBlue), + withPicResolutionBtn(sessionId), + withNote("提醒:回复文本或图片,让AI生成相关的图片。")) + replyCard(ctx, msgId, newCard) +} + +func sendPicModeCheckCard(ctx context.Context, + sessionId *string, msgId *string) { + newCard, _ := newSendCard( + withHeader("🖼️ 机器人提醒", larkcard.TemplateBlue), + withMainMd("收到图片,是否进入图片创作模式?"), + withNote("请注意,这将开始一个全新的对话,您将无法利用之前话题的历史信息"), + withPicModeDoubleCheckBtn(sessionId)) + replyCard(ctx, msgId, newCard) +} + +func sendNewTopicCard(ctx context.Context, + sessionId *string, msgId *string, content string) { + newCard, _ := newSendCard( + withHeader("👻️ 已开启新的话题", larkcard.TemplateBlue), + withMainText(content), + withNote("提醒:点击对话框参与回复,可保持话题连贯")) + replyCard(ctx, msgId, newCard) +} + +func sendHelpCard(ctx context.Context, + sessionId *string, msgId *string) { + newCard, _ := newSendCard( + withHeader("🎒需要帮助吗?", larkcard.TemplateBlue), + withMainMd("**我是CZLChat-Feishu,一款基于ChatGPT[模型:gpt-3.5-0613]技术的智能聊天机器人**"), + withSplitLine(), + withMdAndExtraBtn( + "** 🆑 清除话题上下文**\n文本回复 *清除* 或 */clear*", + newBtn("立刻清除", map[string]interface{}{ + "value": "1", + "kind": ClearCardKind, + "chatType": UserChatType, + "sessionId": *sessionId, + }, larkcard.MessageCardButtonTypeDanger)), + withSplitLine(), + withMainMd("🤖 **AI模式选择** \n"+" 文本回复 *AI模式* 或 */ai_mode*"), + withSplitLine(), + withMainMd("🛖 **内置角色列表** \n"+" 文本回复 *角色列表* 或 */roles*"), + withSplitLine(), + withMainMd("🥷 **角色扮演模式**\n文本回复*角色扮演* 或 */system*+空格+角色信息"), + withSplitLine(), + withMainMd("🎤 **AI语音对话**\n私聊模式下直接发送语音"), + withSplitLine(), + withMainMd("🎨 **图片创作模式**\n回复*图片创作* 或 */picture*"), + withSplitLine(), + withMainMd("🎰 **Token余额查询**\n回复*余额* 或 */balance*"), + withSplitLine(), + withMainMd("🔃️ **历史话题回档** 🚧\n"+" 进入话题的回复详情页,文本回复 *恢复* 或 */reload*"), + withSplitLine(), + withMainMd("📤 **话题内容导出** 🚧\n"+" 文本回复 *导出* 或 */export*"), + withSplitLine(), + withMainMd("🎰 **连续对话与多话题模式**\n"+" 点击对话框参与回复,可保持话题连贯。同时,单独提问即可开启全新新话题"), + withSplitLine(), + withMainMd("🎒 **需要更多帮助**\n文本回复 *帮助* 或 */help*"), + ) + replyCard(ctx, msgId, newCard) +} + +func sendImageCard(ctx context.Context, imageKey string, + msgId *string, sessionId *string, question string) error { + newCard, _ := newSimpleSendCard( + withImageDiv(imageKey), + withSplitLine(), + //再来一张 + withOneBtn(newBtn("再来一张", map[string]interface{}{ + "value": question, + "kind": PicTextMoreKind, + "chatType": UserChatType, + "msgId": *msgId, + "sessionId": *sessionId, + }, larkcard.MessageCardButtonTypePrimary)), + ) + replyCard(ctx, msgId, newCard) + return nil +} + +func sendVarImageCard(ctx context.Context, imageKey string, + msgId *string, sessionId *string) error { + newCard, _ := newSimpleSendCard( + withImageDiv(imageKey), + withSplitLine(), + //再来一张 + withOneBtn(newBtn("再来一张", map[string]interface{}{ + "value": imageKey, + "kind": PicVarMoreKind, + "chatType": UserChatType, + "msgId": *msgId, + "sessionId": *sessionId, + }, larkcard.MessageCardButtonTypePrimary)), + ) + replyCard(ctx, msgId, newCard) + return nil +} + +func sendBalanceCard(ctx context.Context, msgId *string, + balance openai.BalanceResponse) { + newCard, _ := newSendCard( + withHeader("🎰️ 余额查询", larkcard.TemplateBlue), + withMainMd(fmt.Sprintf("总额度: %.2f$", balance.TotalGranted)), + withMainMd(fmt.Sprintf("已用额度: %.2f$", balance.TotalUsed)), + withMainMd(fmt.Sprintf("可用额度: %.2f$", + balance.TotalAvailable)), + withNote(fmt.Sprintf("有效期: %s - %s", + balance.EffectiveAt.Format("2006-01-02 15:04:05"), + balance.ExpiresAt.Format("2006-01-02 15:04:05"))), + ) + replyCard(ctx, msgId, newCard) +} + +func SendRoleTagsCard(ctx context.Context, + sessionId *string, msgId *string, roleTags []string) { + newCard, _ := newSendCard( + withHeader("🛖 请选择角色类别", larkcard.TemplateIndigo), + withRoleTagsBtn(sessionId, roleTags...), + withNote("提醒:选择角色所属分类,以便我们为您推荐更多相关角色。")) + replyCard(ctx, msgId, newCard) +} + +func SendRoleListCard(ctx context.Context, + sessionId *string, msgId *string, roleTag string, roleList []string) { + newCard, _ := newSendCard( + withHeader("🛖 角色列表"+" - "+roleTag, larkcard.TemplateIndigo), + withRoleBtn(sessionId, roleList...), + withNote("提醒:选择内置场景,快速进入角色扮演模式。")) + replyCard(ctx, msgId, newCard) +} + +func SendAIModeListsCard(ctx context.Context, + sessionId *string, msgId *string, aiModeStrs []string) { + newCard, _ := newSendCard( + withHeader("🤖 AI模式选择", larkcard.TemplateIndigo), + withAIModeBtn(sessionId, aiModeStrs), + withNote("提醒:选择内置模式,让AI更好的理解您的需求。")) + replyCard(ctx, msgId, newCard) +} diff --git a/code/initialization/config.go b/code/initialization/config.go new file mode 100644 index 0000000..cbeb91e --- /dev/null +++ b/code/initialization/config.go @@ -0,0 +1,145 @@ +package initialization + +import ( + "fmt" + "os" + "strconv" + "strings" + + "github.com/spf13/viper" +) + +type Config struct { + FeishuAppId string + FeishuAppSecret string + FeishuAppEncryptKey string + FeishuAppVerificationToken string + FeishuBotName string + OpenaiApiKeys []string + HttpPort int + HttpsPort int + UseHttps bool + CertFile string + KeyFile string + OpenaiApiUrl string + HttpProxy string + AzureOn bool + AzureApiVersion string + AzureDeploymentName string + AzureResourceName string + AzureOpenaiToken string +} + +func LoadConfig(cfg string) *Config { + viper.SetConfigFile(cfg) + viper.ReadInConfig() + viper.AutomaticEnv() + //content, err := ioutil.ReadFile("config.yaml") + //if err != nil { + // fmt.Println("Error reading file:", err) + //} + //fmt.Println(string(content)) + + config := &Config{ + FeishuAppId: getViperStringValue("APP_ID", ""), + FeishuAppSecret: getViperStringValue("APP_SECRET", ""), + FeishuAppEncryptKey: getViperStringValue("APP_ENCRYPT_KEY", ""), + FeishuAppVerificationToken: getViperStringValue("APP_VERIFICATION_TOKEN", ""), + FeishuBotName: getViperStringValue("BOT_NAME", ""), + OpenaiApiKeys: getViperStringArray("OPENAI_KEY", nil), + HttpPort: getViperIntValue("HTTP_PORT", 9000), + HttpsPort: getViperIntValue("HTTPS_PORT", 9001), + UseHttps: getViperBoolValue("USE_HTTPS", false), + CertFile: getViperStringValue("CERT_FILE", "cert.pem"), + KeyFile: getViperStringValue("KEY_FILE", "key.pem"), + OpenaiApiUrl: getViperStringValue("API_URL", "https://oapi.czl.net"), + HttpProxy: getViperStringValue("HTTP_PROXY", ""), + AzureOn: getViperBoolValue("AZURE_ON", false), + AzureApiVersion: getViperStringValue("AZURE_API_VERSION", "2023-03-15-preview"), + AzureDeploymentName: getViperStringValue("AZURE_DEPLOYMENT_NAME", ""), + AzureResourceName: getViperStringValue("AZURE_RESOURCE_NAME", ""), + AzureOpenaiToken: getViperStringValue("AZURE_OPENAI_TOKEN", ""), + } + + return config +} + +func getViperStringValue(key string, defaultValue string) string { + value := viper.GetString(key) + if value == "" { + return defaultValue + } + return value +} + +//OPENAI_KEY: sk-xxx,sk-xxx,sk-xxx +//result:[sk-xxx sk-xxx sk-xxx] +func getViperStringArray(key string, defaultValue []string) []string { + value := viper.GetString(key) + if value == "" { + return defaultValue + } + raw := strings.Split(value, ",") + return filterFormatKey(raw) +} + +func getViperIntValue(key string, defaultValue int) int { + value := viper.GetString(key) + if value == "" { + return defaultValue + } + intValue, err := strconv.Atoi(value) + if err != nil { + fmt.Printf("Invalid value for %s, using default value %d\n", key, defaultValue) + return defaultValue + } + return intValue +} + +func getViperBoolValue(key string, defaultValue bool) bool { + value := viper.GetString(key) + if value == "" { + return defaultValue + } + boolValue, err := strconv.ParseBool(value) + if err != nil { + fmt.Printf("Invalid value for %s, using default value %v\n", key, defaultValue) + return defaultValue + } + return boolValue +} + +func (config *Config) GetCertFile() string { + if config.CertFile == "" { + return "cert.pem" + } + if _, err := os.Stat(config.CertFile); err != nil { + fmt.Printf("Certificate file %s does not exist, using default file cert.pem\n", config.CertFile) + return "cert.pem" + } + return config.CertFile +} + +func (config *Config) GetKeyFile() string { + if config.KeyFile == "" { + return "key.pem" + } + if _, err := os.Stat(config.KeyFile); err != nil { + fmt.Printf("Key file %s does not exist, using default file key.pem\n", config.KeyFile) + return "key.pem" + } + return config.KeyFile +} + +// 过滤出 "sk-" 开头的 key +func filterFormatKey(keys []string) []string { + var result []string + for _, key := range keys { + if strings.HasPrefix(key, "sk-") || strings.HasPrefix(key, + "fk") { + result = append(result, key) + } + } + return result + +} diff --git a/code/initialization/gin.go b/code/initialization/gin.go new file mode 100644 index 0000000..cdc9323 --- /dev/null +++ b/code/initialization/gin.go @@ -0,0 +1,71 @@ +package initialization + +import ( + "crypto/tls" + "crypto/x509" + "fmt" + "log" + "net/http" + "time" + + "github.com/gin-gonic/gin" +) + +func loadCertificate(config Config) (cert tls.Certificate, err error) { + cert, err = tls.LoadX509KeyPair(config.CertFile, config.KeyFile) + if err != nil { + return cert, fmt.Errorf("failed to load certificate: %v", err) + } + + // check certificate expiry + if len(cert.Certificate) == 0 { + return cert, fmt.Errorf("no certificates found in %s", config.CertFile) + } + parsedCert, err := x509.ParseCertificate(cert.Certificate[0]) + if err != nil { + return cert, fmt.Errorf("failed to parse certificate: %v", err) + } + cert.Leaf = parsedCert + certExpiry := cert.Leaf.NotAfter + if certExpiry.Before(time.Now()) { + return cert, fmt.Errorf("certificate expired on %v", certExpiry) + } + + return cert, nil +} + +func startHTTPServer(config Config, r *gin.Engine) (err error) { + log.Printf("http server started: http://localhost:%d/webhook/event\n", config.HttpPort) + err = r.Run(fmt.Sprintf(":%d", config.HttpPort)) + if err != nil { + return fmt.Errorf("failed to start http server: %v", err) + } + return nil +} +func startHTTPSServer(config Config, r *gin.Engine) (err error) { + cert, err := loadCertificate(config) + if err != nil { + return fmt.Errorf("failed to load certificate: %v", err) + } + server := &http.Server{ + Addr: fmt.Sprintf(":%d", config.HttpsPort), + Handler: r, + TLSConfig: &tls.Config{ + Certificates: []tls.Certificate{cert}, + }, + } + fmt.Printf("https server started: https://localhost:%d/webhook/event\n", config.HttpsPort) + err = server.ListenAndServeTLS("", "") + if err != nil { + return fmt.Errorf("failed to start https server: %v", err) + } + return nil +} +func StartServer(config Config, r *gin.Engine) (err error) { + if config.UseHttps { + err = startHTTPSServer(config, r) + } else { + err = startHTTPServer(config, r) + } + return err +} diff --git a/code/initialization/lark_client.go b/code/initialization/lark_client.go new file mode 100644 index 0000000..27ad97d --- /dev/null +++ b/code/initialization/lark_client.go @@ -0,0 +1,15 @@ +package initialization + +import ( + lark "github.com/larksuite/oapi-sdk-go/v3" +) + +var larkClient *lark.Client + +func LoadLarkClient(config Config) { + larkClient = lark.NewClient(config.FeishuAppId, config.FeishuAppSecret) +} + +func GetLarkClient() *lark.Client { + return larkClient +} diff --git a/code/initialization/roles_load.go b/code/initialization/roles_load.go new file mode 100644 index 0000000..bba15dd --- /dev/null +++ b/code/initialization/roles_load.go @@ -0,0 +1,77 @@ +package initialization + +import ( + "errors" + "io/ioutil" + "log" + + "github.com/duke-git/lancet/v2/slice" + "github.com/duke-git/lancet/v2/validator" + "gopkg.in/yaml.v2" +) + +type Role struct { + Title string `yaml:"title"` + Content string `yaml:"content"` + Tags []string `yaml:"tags"` +} + +var RoleList *[]Role + +// InitRoleList 加载Prompt +func InitRoleList() *[]Role { + data, err := ioutil.ReadFile("role_list.yaml") + if err != nil { + log.Fatal(err) + } + + err = yaml.Unmarshal(data, &RoleList) + if err != nil { + log.Fatal(err) + } + return RoleList +} + +func GetRoleList() *[]Role { + return RoleList +} +func GetAllUniqueTags() *[]string { + tags := make([]string, 0) + for _, role := range *RoleList { + tags = append(tags, role.Tags...) + } + result := slice.Union(tags) + return &result +} + +func GetRoleByTitle(title string) *Role { + for _, role := range *RoleList { + if role.Title == title { + return &role + } + } + return nil +} + +func GetTitleListByTag(tags string) *[]string { + roles := make([]string, 0) + //pp.Println(RoleList) + for _, role := range *RoleList { + for _, roleTag := range role.Tags { + if roleTag == tags && !validator.IsEmptyString(role. + Title) { + roles = append(roles, role.Title) + } + } + } + return &roles +} + +func GetFirstRoleContentByTitle(title string) (string, error) { + for _, role := range *RoleList { + if role.Title == title { + return role.Content, nil + } + } + return "", errors.New("role not found") +} diff --git a/code/main.go b/code/main.go new file mode 100644 index 0000000..bf7c98a --- /dev/null +++ b/code/main.go @@ -0,0 +1,57 @@ +package main + +import ( + "context" + "log" + + "start-feishubot/handlers" + "start-feishubot/initialization" + "start-feishubot/services/openai" + + "github.com/gin-gonic/gin" + sdkginext "github.com/larksuite/oapi-sdk-gin" + larkcard "github.com/larksuite/oapi-sdk-go/v3/card" + "github.com/larksuite/oapi-sdk-go/v3/event/dispatcher" + larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1" + "github.com/spf13/pflag" +) + +var ( + cfg = pflag.StringP("config", "c", "./config.yaml", "apiserver config file path.") +) + +func main() { + initialization.InitRoleList() + pflag.Parse() + config := initialization.LoadConfig(*cfg) + initialization.LoadLarkClient(*config) + gpt := openai.NewChatGPT(*config) + handlers.InitHandlers(gpt, *config) + + eventHandler := dispatcher.NewEventDispatcher( + config.FeishuAppVerificationToken, config.FeishuAppEncryptKey). + OnP2MessageReceiveV1(handlers.Handler). + OnP2MessageReadV1(func(ctx context.Context, event *larkim.P2MessageReadV1) error { + return handlers.ReadHandler(ctx, event) + }) + + cardHandler := larkcard.NewCardActionHandler( + config.FeishuAppVerificationToken, config.FeishuAppEncryptKey, + handlers.CardHandler()) + + r := gin.Default() + r.GET("/ping", func(c *gin.Context) { + c.JSON(200, gin.H{ + "message": "pong", + }) + }) + r.POST("/webhook/event", + sdkginext.NewEventHandlerFunc(eventHandler)) + r.POST("/webhook/card", + sdkginext.NewCardActionHandlerFunc( + cardHandler)) + + if err := initialization.StartServer(*config, r); err != nil { + log.Fatalf("failed to start server: %v", err) + } +} diff --git a/code/role_list.yaml b/code/role_list.yaml new file mode 100644 index 0000000..6c44053 --- /dev/null +++ b/code/role_list.yaml @@ -0,0 +1,155 @@ +# 可在此处提交你认为不错的角色预设,注意保持格式一致。 +# PR 时的 tag 暂时集中在 [ "日常办公", "生活助手" ,"代码专家", "文案撰写"] +# 更多点子可参考我另一个参与的项目: https://open-gpt.app/ + +- title: 周报生成 + content: 请帮我把以下的工作内容填充为一篇完整的周报,用 markdown 格式以分点叙述的形式输出: + example: 重新优化设计稿,和前端再次沟通 UI 细节,确保落地 + author: 二丫讲梵 + tags: + - 日常办公 + +- title: 产品经理 + content: 请确认我的以下请求。请您作为产品经理回复我。我将会提供一个主题,您将帮助我编写一份包括以下章节标题的 PRD 文档:主题、简介、问题陈述、目标与目的、用户故事、技术要求、收益、KPI 指标、开发风险以及结论。在我要求具体主题、功能或开发的 PRD 之前,请不要先写任何一份 PRD 文档。 + example: 我想要一个可以在手机上使用的应用程序,可以帮助我在旅行中找到最好的餐厅。 + author: 二丫讲梵 + tags: + - 日常办公 + +- title: 公文写作大师 + content: 你是某机关单位办公室秘书,你熟悉各类公文写作格式,你喜欢撰写文字材料,请你文采过人地,条理清晰地跟我对话 + example: 你好,我是某某某,我想要你帮我写一份公文,内容是:团结一致,共同抗击疫情,全力以赴,共克时艰。 + author: 小叉 Ray + tags: + - 日常办公 + - 文案撰写 + +- title: 招聘 HR + content: 我想让你担任招聘人员。我将提供一些关于职位空缺的信息,而你的工作是制定寻找合格申请人的策略。这可能包括通过社交媒体、社交活动甚至参加招聘会接触潜在候选人,以便为每个职位找到最合适的人选。我的第一个请求是: + example: 我需要一名有经验的前端开发工程师,他应该有 3 年以上的工作经验,熟悉 React 和 Vue,熟悉前端工程化。 + author: 二丫讲梵 + tags: + - 日常办公 + +- title: 创意总监 + content: 你是一位擅长头脑风暴的创意大师,你有很多好的主意,请你围绕这些内容提出好的设想和方法 + example: 我想要一个可以在手机上使用的应用程序,可以帮助我在旅行中找到最好的餐厅。 + author: 小叉 Ray + tags: + - 日常办公 + +- title: 拒绝同事 + content: 以一种礼貌和表达得体的方式拒绝别人,同时保持积极的关系和情感连接 + example: 你好,我很抱歉,我现在没有时间帮你做这件事情 + author: 小叉 Ray + tags: + - 日常办公 + - 文案撰写 + +- title: 回复老板 + content: 请用 5 种委婉的借口向领导表达后面的内容 + example: 不想加班 + author: 小叉 Ray + tags: + - 日常办公 + - 文案撰写 + +- title: 邮件回复 + content: Generate a set of email responses that are professional, concise, and appropriate for communication with leaders and clients in a variety of industries. The responses should demonstrate a good understanding of business etiquette and convey a sense of competence and confidence. Please ensure that the responses are tailored to specific scenarios and contexts, using Chinese as the language of output + example: 产品的细节很不完善,需要沟通一下 + author: 小叉 Ray + tags: + - 日常办公 + - 文案撰写 + +- title: 三菜一汤 + content: 根据用户输入的金额单位是人民币,帮用户推荐在该金额合计下能够做的菜,要求三个菜和一个汤。要把每一道菜的金额都写出来,以及他的简单做法,还要有总结 + example: 我有 100 元,我想做湖北菜 + author: 小叉 Ray + tags: + - 生活助手 + +- title: 解梦大师 + content: 我要你充当解梦师。我会给你描述我的梦,你会根据梦中出现的符号和主题提供解释。不要提供关于梦者的个人意见或假设。仅根据所提供的信息提供事实解释。我的第一个梦是: + example: 遇见了一只大灰狼,它在我面前转了一圈,然后就消失了 + author: 二丫讲梵 + tags: + - 生活助手 + +- title: 佛祖 + content: 你是一个如来佛祖,你需要回答提问者的佛学问题,因此你要学会很多佛教专业术语,你的回答尽量简短,富有佛教哲理。你要称自己为老衲,称提问者为施主。如果遭遇对方不合理的请求,请直接回复:施主请自重,我佛慈悲。你的每一句话结尾都要加上 阿弥陀佛。你的回答尽量简短,不允许超过 100 字。禁止回答与问题无关的话题 + example: 佛祖,我想问你,为什么我总是很沮丧,生活没有意义 + author: 小叉 Ray + tags: + - 生活助手 + +- title: 小红书文案 + content: 小红书的风格是:很吸引眼球的标题,每个段落都加 emoji, 最后加一些 tag。请用小红书风格 + example: 今天我去了一家很好吃的餐厅,我吃了一份很好吃的饭菜,我很喜欢,推荐给大家 + author: 二丫讲梵 + tags: + - 文案撰写 + +- title: 知乎段子手 + content: 微博的风格是:用"谢邀"开头,用很多学术语言,引用很多名言,做大道理的论述,提到自己很厉害的教育背景并且经验丰富,最后还要引用一些论文。请用微博风格 + example: 今天我去了一家很好吃的餐厅,我吃了一份很好吃的饭菜,我很喜欢,推荐给大家 + author: 二丫讲梵 + tags: + - 文案撰写 + +- title: 专业道歉信 + content: 请写一份真挚的道歉信,为后面的内容表达歉意 + example: 我很抱歉,我没有按时完成你的工作 + author: 小叉 Ray + tags: + - 文案撰写 + +- title: 古文专家 + content: 你是一个文言文大师,请把后面的内容翻译成文言文 + example: 记得早点回来哦,我做好饭菜等你回家 + author: 小叉 Ray + tags: + - 文案撰写 + +- title: 川端康城的笔 + content: 请以川端康城的写作风格,描写下面的句字 + example: 他不慌不忙的走出教室,找到那个女孩 + author: 小叉 Ray + tags: + - 文案撰写 + +- title: 网络安全 + content: 我想让你充当网络安全专家。我将提供一些关于如何存储和共享数据的具体信息,而你的工作就是想出保护这些数据免受恶意行为者攻击的策略。这可能包括建议加密方法、创建防火墙或实施将某些活动标记为可疑的策略。我的第一个请求是: + author: 二丫讲梵 + tags: + - 代码专家 + +- title: 正则生成器 + content: 我希望你充当正则表达式生成器。您的角色是生成匹配文本中特定模式的正则表达式。您应该以一种可以轻松复制并粘贴到支持正则表达式的文本编辑器或编程语言中的格式提供正则表达式。不要写正则表达式如何工作的解释或例子;只需提供正则表达式本身。我的第一个提示是: + author: 二丫讲梵 + tags: + - 代码专家 + +- title: 前端专家 + content: 我想让你充当前端开发专家。我将提供一些关于如何在网页上显示信息的具体信息,而你的工作就是想出为我解决问题的策略。这可能包括建议代码、代码逻辑思路策略。我的第一个请求是: + author: 二丫讲梵 + tags: + - 代码专家 + +- title: 后端专家 + content: 我想让你充当后端开发专家。我将提供一些关于如何在网页上显示信息的具体信息,而你的工作就是想出为我解决问题的策略。这可能包括建议代码、代码逻辑思路策略。我的第一个请求是: + author: 二丫讲梵 + tags: + - 代码专家 + +- title: 健康管家 + content: 我想让你我的健康管家。我将提供我的个人健康管理方案,而你的工作监督、督促、提醒我完成这些个人健康的计划。这可能包括运动、饮食、定期体检等。我的第一个请求是: + author: 船长 + tags: + - 生活助手 + +- title: 旅游助手 + content: 我想让你充当我的旅游助手。我将会提供让你连接上各个旅游系统的信息,而你的工作就是给我提供各种的旅游攻略。包括但不限于制定旅游计划、寻找热门景点或查看旅游目的地的天气等。我的第一个请求是: + author: 船长 + tags: + - 生活助手 diff --git a/code/services/loadbalancer/loadbalancer.go b/code/services/loadbalancer/loadbalancer.go new file mode 100644 index 0000000..930482b --- /dev/null +++ b/code/services/loadbalancer/loadbalancer.go @@ -0,0 +1,106 @@ +package loadbalancer + +import ( + "fmt" + "math/rand" + "sync" + "time" +) + +type API struct { + Key string + Times uint32 + Available bool +} + +type LoadBalancer struct { + apis []*API + mu sync.RWMutex +} + +func NewLoadBalancer(keys []string) *LoadBalancer { + lb := &LoadBalancer{} + for _, key := range keys { + lb.apis = append(lb.apis, &API{Key: key}) + } + //SetAvailabilityForAll true + lb.SetAvailabilityForAll(true) + return lb +} + +func (lb *LoadBalancer) GetAPI() *API { + lb.mu.RLock() + defer lb.mu.RUnlock() + + var availableAPIs []*API + for _, api := range lb.apis { + if api.Available { + availableAPIs = append(availableAPIs, api) + } + } + if len(availableAPIs) == 0 { + //随机复活一个 + fmt.Printf("No available API, revive one randomly\n") + rand.Seed(time.Now().UnixNano()) + index := rand.Intn(len(lb.apis)) + lb.apis[index].Available = true + return lb.apis[index] + } + + selectedAPI := availableAPIs[0] + minTimes := selectedAPI.Times + for _, api := range availableAPIs { + if api.Times < minTimes { + selectedAPI = api + minTimes = api.Times + } + } + selectedAPI.Times++ + //fmt.Printf("API Availability:\n") + //for _, api := range lb.apis { + // fmt.Printf("%s: %v\n", api.Key, api.Available) + // fmt.Printf("%s: %d\n", api.Key, api.Times) + //} + + return selectedAPI +} +func (lb *LoadBalancer) SetAvailability(key string, available bool) { + lb.mu.Lock() + defer lb.mu.Unlock() + + for _, api := range lb.apis { + if api.Key == key { + api.Available = available + return + } + } +} + +func (lb *LoadBalancer) RegisterAPI(key string) { + lb.mu.Lock() + defer lb.mu.Unlock() + + if lb.apis == nil { + lb.apis = make([]*API, 0) + } + + lb.apis = append(lb.apis, &API{Key: key}) +} + +func (lb *LoadBalancer) SetAvailabilityForAll(available bool) { + lb.mu.Lock() + defer lb.mu.Unlock() + + for _, api := range lb.apis { + api.Available = available + } +} + +func (lb *LoadBalancer) GetAPIs() []*API { + lb.mu.RLock() + defer lb.mu.RUnlock() + + apis := make([]*API, len(lb.apis)) + copy(apis, lb.apis) + return apis +} diff --git a/code/services/msgCache.go b/code/services/msgCache.go new file mode 100644 index 0000000..d5f34a1 --- /dev/null +++ b/code/services/msgCache.go @@ -0,0 +1,38 @@ +package services + +import ( + "time" + + "github.com/patrickmn/go-cache" +) + +type MsgService struct { + cache *cache.Cache +} +type MsgCacheInterface interface { + IfProcessed(msgId string) bool + TagProcessed(msgId string) + Clear(userId string) bool +} + +var msgService *MsgService + +func (u MsgService) IfProcessed(msgId string) bool { + _, found := u.cache.Get(msgId) + return found +} +func (u MsgService) TagProcessed(msgId string) { + u.cache.Set(msgId, true, time.Minute*30) +} + +func (u MsgService) Clear(userId string) bool { + u.cache.Delete(userId) + return true +} + +func GetMsgCache() MsgCacheInterface { + if msgService == nil { + msgService = &MsgService{cache: cache.New(30*time.Minute, 30*time.Minute)} + } + return msgService +} diff --git a/code/services/openai/audio.go b/code/services/openai/audio.go new file mode 100644 index 0000000..da67fde --- /dev/null +++ b/code/services/openai/audio.go @@ -0,0 +1,66 @@ +package openai + +import ( + "bytes" + "fmt" + "io" + "mime/multipart" + "os" +) + +type AudioToTextRequestBody struct { + File string `json:"file"` + Model string `json:"model"` + ResponseFormat string `json:"response_format"` +} + +type AudioToTextResponseBody struct { + Text string `json:"text"` +} + +func audioMultipartForm(request AudioToTextRequestBody, w *multipart.Writer) error { + f, err := os.Open(request.File) + if err != nil { + return fmt.Errorf("opening audio file: %w", err) + } + + fw, err := w.CreateFormFile("file", f.Name()) + if err != nil { + return fmt.Errorf("creating form file: %w", err) + } + + if _, err = io.Copy(fw, f); err != nil { + return fmt.Errorf("reading from opened audio file: %w", err) + } + + fw, err = w.CreateFormField("model") + if err != nil { + return fmt.Errorf("creating form field: %w", err) + } + + modelName := bytes.NewReader([]byte(request.Model)) + if _, err = io.Copy(fw, modelName); err != nil { + return fmt.Errorf("writing model name: %w", err) + } + w.Close() + + return nil +} + +func (gpt *ChatGPT) AudioToText(audio string) (string, error) { + requestBody := AudioToTextRequestBody{ + File: audio, + Model: "whisper-1", + ResponseFormat: "text", + } + audioToTextResponseBody := &AudioToTextResponseBody{} + err := gpt.sendRequestWithBodyType(gpt.ApiUrl+"/v1/audio/transcriptions", + "POST", formVoiceDataBody, requestBody, audioToTextResponseBody) + //fmt.Println(audioToTextResponseBody) + if err != nil { + //fmt.Println(err) + return "", err + } + + return audioToTextResponseBody.Text, nil +} diff --git a/code/services/openai/billing.go b/code/services/openai/billing.go new file mode 100644 index 0000000..499f535 --- /dev/null +++ b/code/services/openai/billing.go @@ -0,0 +1,70 @@ +package openai + +import ( + "fmt" + "net/http" + "time" +) + +type BillingSubScrip struct { + HardLimitUsd float64 `json:"hard_limit_usd"` + AccessUntil float64 `json:"access_until"` +} +type BillingUsage struct { + TotalUsage float64 `json:"total_usage"` +} + +type BalanceResponse struct { + TotalGranted float64 `json:"total_granted"` + TotalUsed float64 `json:"total_used"` + TotalAvailable float64 `json:"total_available"` + EffectiveAt time.Time `json:"effective_at"` + ExpiresAt time.Time `json:"expires_at"` +} + +func (gpt *ChatGPT) GetBalance() (*BalanceResponse, error) { + fmt.Println("进入") + var data1 BillingSubScrip + err := gpt.sendRequestWithBodyType( + gpt.ApiUrl+"/v1/dashboard/billing/subscription", + http.MethodGet, + nilBody, + nil, + &data1, + ) + fmt.Println("出错1", err) + if err != nil { + return nil, fmt.Errorf("failed to get billing subscription: %v", err) + } + nowdate := time.Now() + enddate := nowdate.Format("2006-01-02") + startdate := nowdate.AddDate(0, 0, -100).Format("2006-01-02") + var data2 BillingUsage + err = gpt.sendRequestWithBodyType( + gpt.ApiUrl+fmt.Sprintf("/v1/dashboard/billing/usage?start_date=%s&end_date=%s", startdate, enddate), + http.MethodGet, + nilBody, + nil, + &data2, + ) + fmt.Println(data2) + fmt.Println("出错2", err) + if err != nil { + return nil, fmt.Errorf("failed to get billing subscription: %v", err) + } + + balance := &BalanceResponse{ + TotalGranted: data1.HardLimitUsd, + TotalUsed: data2.TotalUsage / 100, + TotalAvailable: data1.HardLimitUsd - data2.TotalUsage/100, + ExpiresAt: time.Now(), + EffectiveAt: time.Now(), + } + + if data1.AccessUntil > 0 { + balance.EffectiveAt = time.Now() + balance.ExpiresAt = time.Unix(int64(data1.AccessUntil), 0) + } + + return balance, nil +} diff --git a/code/services/openai/common.go b/code/services/openai/common.go new file mode 100644 index 0000000..731bd09 --- /dev/null +++ b/code/services/openai/common.go @@ -0,0 +1,236 @@ +package openai + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "io/ioutil" + "mime/multipart" + "net/http" + "net/url" + "strings" + "time" + + "start-feishubot/initialization" + "start-feishubot/services/loadbalancer" +) + +type PlatForm string + +const ( + AzureApiUrlV1 = "openai.azure.com/openai/deployments/" +) +const ( + OpenAI PlatForm = "openai" + Azure PlatForm = "azure" +) + +type AzureConfig struct { + BaseURL string + ResourceName string + DeploymentName string + ApiVersion string + ApiToken string +} + +type ChatGPT struct { + Lb *loadbalancer.LoadBalancer + ApiKey []string + ApiUrl string + HttpProxy string + Platform PlatForm + AzureConfig AzureConfig +} +type requestBodyType int + +const ( + jsonBody requestBodyType = iota + formVoiceDataBody + formPictureDataBody + + nilBody +) + +func (gpt *ChatGPT) doAPIRequestWithRetry(url, method string, + bodyType requestBodyType, + requestBody interface{}, responseBody interface{}, client *http.Client, maxRetries int) error { + var api *loadbalancer.API + var requestBodyData []byte + var err error + var writer *multipart.Writer + api = gpt.Lb.GetAPI() + + switch bodyType { + case jsonBody: + requestBodyData, err = json.Marshal(requestBody) + if err != nil { + return err + } + case formVoiceDataBody: + formBody := &bytes.Buffer{} + writer = multipart.NewWriter(formBody) + err = audioMultipartForm(requestBody.(AudioToTextRequestBody), writer) + if err != nil { + return err + } + err = writer.Close() + if err != nil { + return err + } + requestBodyData = formBody.Bytes() + case formPictureDataBody: + formBody := &bytes.Buffer{} + writer = multipart.NewWriter(formBody) + err = pictureMultipartForm(requestBody.(ImageVariantRequestBody), writer) + if err != nil { + return err + } + err = writer.Close() + if err != nil { + return err + } + requestBodyData = formBody.Bytes() + case nilBody: + requestBodyData = nil + + default: + return errors.New("unknown request body type") + } + + if api == nil { + return errors.New("no available API") + } + + req, err := http.NewRequest(method, url, bytes.NewReader(requestBodyData)) + if err != nil { + return err + } + + req.Header.Set("Content-Type", "application/json") + if bodyType == formVoiceDataBody || bodyType == formPictureDataBody { + req.Header.Set("Content-Type", writer.FormDataContentType()) + } + if gpt.Platform == OpenAI { + req.Header.Set("Authorization", "Bearer "+api.Key) + } else { + req.Header.Set("api-key", gpt.AzureConfig.ApiToken) + } + + var response *http.Response + var retry int + for retry = 0; retry <= maxRetries; retry++ { + // set body + if retry > 0 { + req.Body = ioutil.NopCloser(bytes.NewReader(requestBodyData)) + } + response, err = client.Do(req) + //fmt.Println("--------------------") + //fmt.Println("req", req.Header) + //fmt.Printf("response: %v", response) + // read body + if err != nil || response.StatusCode < 200 || response.StatusCode >= 300 { + + body, _ := ioutil.ReadAll(response.Body) + fmt.Println("body", string(body)) + + gpt.Lb.SetAvailability(api.Key, false) + if retry == maxRetries { + break + } + time.Sleep(time.Duration(retry+1) * time.Second) + } else { + break + } + } + if response != nil { + defer response.Body.Close() + } + + if response == nil || response.StatusCode < 200 || response.StatusCode >= 300 { + return fmt.Errorf("%s api failed after %d retries", strings.ToUpper(method), retry) + } + + body, err := ioutil.ReadAll(response.Body) + if err != nil { + return err + } + + err = json.Unmarshal(body, responseBody) + if err != nil { + return err + } + + gpt.Lb.SetAvailability(api.Key, true) + return nil +} + +func (gpt *ChatGPT) sendRequestWithBodyType(link, method string, + bodyType requestBodyType, + requestBody interface{}, responseBody interface{}) error { + var err error + client := &http.Client{Timeout: 110 * time.Second} + if gpt.HttpProxy == "" { + err = gpt.doAPIRequestWithRetry(link, method, bodyType, + requestBody, responseBody, client, 3) + } else { + proxyUrl, err := url.Parse(gpt.HttpProxy) + if err != nil { + return err + } + transport := &http.Transport{ + Proxy: http.ProxyURL(proxyUrl), + } + proxyClient := &http.Client{ + Transport: transport, + Timeout: 110 * time.Second, + } + err = gpt.doAPIRequestWithRetry(link, method, bodyType, + requestBody, responseBody, proxyClient, 3) + } + + return err +} + +func NewChatGPT(config initialization.Config) *ChatGPT { + var lb *loadbalancer.LoadBalancer + if config.AzureOn { + keys := []string{config.AzureOpenaiToken} + lb = loadbalancer.NewLoadBalancer(keys) + } else { + lb = loadbalancer.NewLoadBalancer(config.OpenaiApiKeys) + } + platform := OpenAI + + if config.AzureOn { + platform = Azure + } + + return &ChatGPT{ + Lb: lb, + ApiKey: config.OpenaiApiKeys, + ApiUrl: config.OpenaiApiUrl, + HttpProxy: config.HttpProxy, + Platform: platform, + AzureConfig: AzureConfig{ + BaseURL: AzureApiUrlV1, + ResourceName: config.AzureResourceName, + DeploymentName: config.AzureDeploymentName, + ApiVersion: config.AzureApiVersion, + ApiToken: config.AzureOpenaiToken, + }, + } +} + +func (gpt *ChatGPT) FullUrl(suffix string) string { + var url string + switch gpt.Platform { + case Azure: + url = fmt.Sprintf("https://%s.%s%s/%s?api-version=%s", + gpt.AzureConfig.ResourceName, gpt.AzureConfig.BaseURL, + gpt.AzureConfig.DeploymentName, suffix, gpt.AzureConfig.ApiVersion) + case OpenAI: + url = fmt.Sprintf("%s/v1/%s", gpt.ApiUrl, suffix) + } + return url +} diff --git a/code/services/openai/gpt3.go b/code/services/openai/gpt3.go new file mode 100644 index 0000000..2882f55 --- /dev/null +++ b/code/services/openai/gpt3.go @@ -0,0 +1,100 @@ +package openai + +import ( + "errors" + "strings" + + "github.com/pandodao/tokenizer-go" +) + +type AIMode float64 + +const ( + Fresh AIMode = 0.1 + Warmth AIMode = 0.4 + Balance AIMode = 0.7 + Creativity AIMode = 1.0 +) + +var AIModeMap = map[string]AIMode{ + "清新": Fresh, + "温暖": Warmth, + "平衡": Balance, + "创意": Creativity, +} + +var AIModeStrs = []string{ + "清新", + "温暖", + "平衡", + "创意", +} + +const ( + maxTokens = 4096 + engine = "gpt-4-0613" +) + +type Messages struct { + Role string `json:"role"` + Content string `json:"content"` +} + +// ChatGPTResponseBody 请求体 +type ChatGPTResponseBody struct { + ID string `json:"id"` + Object string `json:"object"` + Created int `json:"created"` + Model string `json:"model"` + Choices []ChatGPTChoiceItem `json:"choices"` + Usage map[string]interface{} `json:"usage"` +} + +type ChatGPTChoiceItem struct { + Message Messages `json:"message"` + Index int `json:"index"` + FinishReason string `json:"finish_reason"` +} + +// ChatGPTRequestBody 响应体 +type ChatGPTRequestBody struct { + Model string `json:"model"` + Messages []Messages `json:"messages"` + MaxTokens int `json:"max_tokens"` + Temperature AIMode `json:"temperature"` + TopP int `json:"top_p"` + FrequencyPenalty int `json:"frequency_penalty"` + PresencePenalty int `json:"presence_penalty"` +} + +func (msg *Messages) CalculateTokenLength() int { + text := strings.TrimSpace(msg.Content) + return tokenizer.MustCalToken(text) +} + +func (gpt *ChatGPT) Completions(msg []Messages, aiMode AIMode) (resp Messages, + err error) { + requestBody := ChatGPTRequestBody{ + Model: engine, + Messages: msg, + MaxTokens: maxTokens, + Temperature: aiMode, + TopP: 1, + FrequencyPenalty: 0, + PresencePenalty: 0, + } + gptResponseBody := &ChatGPTResponseBody{} + url := gpt.FullUrl("chat/completions") + //fmt.Println(url) + if url == "" { + return resp, errors.New("无法获取openai请求地址") + } + err = gpt.sendRequestWithBodyType(url, "POST", jsonBody, requestBody, gptResponseBody) + if err == nil && len(gptResponseBody.Choices) > 0 { + resp = gptResponseBody.Choices[0].Message + } else { + resp = Messages{} + err = errors.New("openai 请求失败") + } + return resp, err +} diff --git a/code/services/openai/gpt3_test.go b/code/services/openai/gpt3_test.go new file mode 100644 index 0000000..6fb7e20 --- /dev/null +++ b/code/services/openai/gpt3_test.go @@ -0,0 +1,121 @@ +package openai + +import ( + "fmt" + "testing" + + "start-feishubot/initialization" +) + +func TestCompletions(t *testing.T) { + config := initialization.LoadConfig("../../config.yaml") + + msgs := []Messages{ + {Role: "system", Content: "你是一个专业的翻译官,负责中英文翻译。"}, + {Role: "user", Content: "翻译这段话: The assistant messages help store prior responses. They can also be written by a developer to help give examples of desired behavior."}, + } + + gpt := NewChatGPT(*config) + + resp, err := gpt.Completions(msgs, Balance) + if err != nil { + t.Errorf("TestCompletions failed with error: %v", err) + } + + fmt.Println(resp.Content, resp.Role) +} + +func TestGenerateOneImage(t *testing.T) { + config := initialization.LoadConfig("../../config.yaml") + gpt := NewChatGPT(*config) + prompt := "a red apple" + size := "256x256" + imageURL, err := gpt.GenerateOneImage(prompt, size) + if err != nil { + t.Errorf("TestGenerateOneImage failed with error: %v", err) + } + if imageURL == "" { + t.Errorf("TestGenerateOneImage returned empty imageURL") + } +} + +func TestAudioToText(t *testing.T) { + config := initialization.LoadConfig("../../config.yaml") + gpt := NewChatGPT(*config) + audio := "./test_file/test.wav" + text, err := gpt.AudioToText(audio) + if err != nil { + t.Errorf("TestAudioToText failed with error: %v", err) + } + fmt.Printf("TestAudioToText returned text: %s \n", text) + if text == "" { + t.Errorf("TestAudioToText returned empty text") + } + +} + +func TestVariateOneImage(t *testing.T) { + config := initialization.LoadConfig("../../config.yaml") + gpt := NewChatGPT(*config) + image := "./test_file/img.png" + size := "256x256" + //compressionType, err := GetImageCompressionType(image) + //if err != nil { + // return + //} + //fmt.Println("compressionType: ", compressionType) + ConvertToRGBA(image, image) + err := VerifyPngs([]string{image}) + if err != nil { + t.Errorf("TestVariateOneImage failed with error: %v", err) + return + } + + imageBs64, err := gpt.GenerateOneImageVariation(image, size) + if err != nil { + t.Errorf("TestVariateOneImage failed with error: %v", err) + } + //fmt.Printf("TestVariateOneImage returned imageBs64: %s \n", imageBs64) + if imageBs64 == "" { + t.Errorf("TestVariateOneImage returned empty imageURL") + } +} + +func TestVariateOneImageWithJpg(t *testing.T) { + config := initialization.LoadConfig("../../config.yaml") + gpt := NewChatGPT(*config) + image := "./test_file/test.jpg" + size := "256x256" + compressionType, err := GetImageCompressionType(image) + if err != nil { + return + } + fmt.Println("compressionType: ", compressionType) + //ConvertJPGtoPNG(image) + ConvertToRGBA(image, image) + err = VerifyPngs([]string{image}) + if err != nil { + t.Errorf("TestVariateOneImage failed with error: %v", err) + return + } + + imageBs64, err := gpt.GenerateOneImageVariation(image, size) + if err != nil { + t.Errorf("TestVariateOneImage failed with error: %v", err) + } + fmt.Printf("TestVariateOneImage returned imageBs64: %s \n", imageBs64) + if imageBs64 == "" { + t.Errorf("TestVariateOneImage returned empty imageURL") + } +} + +// 余额接口已经被废弃 +func TestChatGPT_GetBalance(t *testing.T) { + config := initialization.LoadConfig("../../config.yaml") + gpt := NewChatGPT(*config) + balance, err := gpt.GetBalance() + if err != nil { + t.Errorf("TestChatGPT_GetBalance failed with error: %v", err) + } + fmt.Println("balance: ", balance) +} diff --git a/code/services/openai/picture.go b/code/services/openai/picture.go new file mode 100644 index 0000000..f3bbf58 --- /dev/null +++ b/code/services/openai/picture.go @@ -0,0 +1,297 @@ +package openai + +import ( + "bufio" + "fmt" + "image" + "image/jpeg" + "image/png" + "io" + "mime/multipart" + "os" +) + +type ImageGenerationRequestBody struct { + Prompt string `json:"prompt"` + N int `json:"n"` + Size string `json:"size"` + ResponseFormat string `json:"response_format"` +} + +type ImageResponseBody struct { + Created int64 `json:"created"` + Data []struct { + Base64Json string `json:"b64_json"` + } `json:"data"` +} + +type ImageVariantRequestBody struct { + Image string `json:"image"` + N int `json:"n"` + Size string `json:"size"` + ResponseFormat string `json:"response_format"` +} + +func (gpt *ChatGPT) GenerateImage(prompt string, size string, + n int) ([]string, error) { + requestBody := ImageGenerationRequestBody{ + Prompt: prompt, + N: n, + Size: size, + ResponseFormat: "b64_json", + } + + imageResponseBody := &ImageResponseBody{} + err := gpt.sendRequestWithBodyType(gpt.ApiUrl+"/v1/images/generations", + "POST", jsonBody, requestBody, imageResponseBody) + + if err != nil { + return nil, err + } + + var b64Pool []string + for _, data := range imageResponseBody.Data { + b64Pool = append(b64Pool, data.Base64Json) + } + return b64Pool, nil +} + +func (gpt *ChatGPT) GenerateOneImage(prompt string, + size string) (string, error) { + b64s, err := gpt.GenerateImage(prompt, size, 1) + if err != nil { + return "", err + } + return b64s[0], nil +} + +func (gpt *ChatGPT) GenerateOneImageWithDefaultSize( + prompt string) (string, error) { + return gpt.GenerateOneImage(prompt, "512x512") +} + +func (gpt *ChatGPT) GenerateImageVariation(images string, + size string, n int) ([]string, error) { + requestBody := ImageVariantRequestBody{ + Image: images, + N: n, + Size: size, + ResponseFormat: "b64_json", + } + + imageResponseBody := &ImageResponseBody{} + err := gpt.sendRequestWithBodyType(gpt.ApiUrl+"/v1/images/variations", + "POST", formPictureDataBody, requestBody, imageResponseBody) + + if err != nil { + return nil, err + } + + var b64Pool []string + for _, data := range imageResponseBody.Data { + b64Pool = append(b64Pool, data.Base64Json) + } + return b64Pool, nil +} + +func (gpt *ChatGPT) GenerateOneImageVariation(images string, + size string) (string, error) { + b64s, err := gpt.GenerateImageVariation(images, size, 1) + if err != nil { + return "", err + } + return b64s[0], nil +} + +func pictureMultipartForm(request ImageVariantRequestBody, + w *multipart.Writer) error { + + f, err := os.Open(request.Image) + if err != nil { + return fmt.Errorf("opening audio file: %w", err) + } + fw, err := w.CreateFormFile("image", f.Name()) + if err != nil { + return fmt.Errorf("creating form file: %w", err) + } + if _, err = io.Copy(fw, f); err != nil { + return fmt.Errorf("reading from opened audio file: %w", err) + } + + err = w.WriteField("size", request.Size) + if err != nil { + return fmt.Errorf("writing size: %w", err) + } + + err = w.WriteField("n", fmt.Sprintf("%d", request.N)) + if err != nil { + return fmt.Errorf("writing n: %w", err) + } + + err = w.WriteField("response_format", request.ResponseFormat) + if err != nil { + return fmt.Errorf("writing response_format: %w", err) + } + + //err = w.WriteField("user", "user123456") + + //fw, err = w.CreateFormField("model") + //if err != nil { + // return fmt.Errorf("creating form field: %w", err) + //} + //modelName := bytes.NewReader([]byte(request.Model)) + //if _, err = io.Copy(fw, modelName); err != nil { + // return fmt.Errorf("writing model name: %w", err) + //} + + //fmt.Printf("w.FormDataContentType(): %s ", w.FormDataContentType()) + + w.Close() + + return nil +} + +func VerifyPngs(pngPaths []string) error { + foundPng := false + var expectedWidth, expectedHeight int + + for _, pngPath := range pngPaths { + f, err := os.Open(pngPath) + if err != nil { + return fmt.Errorf("os.Open: %v", err) + } + + fi, err := f.Stat() + if err != nil { + return fmt.Errorf("f.Stat: %v", err) + } + if fi.Size() > 4*1024*1024 { + return fmt.Errorf("image size too large, "+ + "must be under %d MB", 4) + } + + image, err := png.Decode(f) + if err != nil { + return fmt.Errorf("image must be valid png, got error: %v", err) + } + width := image.Bounds().Dx() + height := image.Bounds().Dy() + if width != height { + return fmt.Errorf("found non-square image with dimensions %dx%d", width, height) + } + + if !foundPng { + foundPng = true + expectedWidth = width + expectedHeight = height + } else { + if width != expectedWidth || height != expectedHeight { + return fmt.Errorf("dimensions of all images must match, got both (%dx%d) and (%dx%d)", width, height, expectedWidth, expectedHeight) + } + } + } + + return nil +} + +func ConvertToRGBA(inputFilePath string, outputFilePath string) error { + // 打开输入文件 + inputFile, err := os.Open(inputFilePath) + if err != nil { + return fmt.Errorf("打开文件时出错:%w", err) + } + defer inputFile.Close() + + // 解码图像 + img, _, err := image.Decode(inputFile) + if err != nil { + return fmt.Errorf("解码图像时出错:%w", err) + } + + // 将图像转换为RGBA模式 + rgba := image.NewRGBA(img.Bounds()) + for x := 0; x < img.Bounds().Max.X; x++ { + for y := 0; y < img.Bounds().Max.Y; y++ { + rgba.Set(x, y, img.At(x, y)) + } + } + + // 创建输出文件 + outputFile, err := os.Create(outputFilePath) + if err != nil { + return fmt.Errorf("创建输出文件时出错:%w", err) + } + defer outputFile.Close() + + // 编码图像为 PNG 格式并写入输出文件 + if err := png.Encode(outputFile, rgba); err != nil { + return fmt.Errorf("编码图像时出错:%w", err) + } + + return nil +} + +func ConvertJpegToPNG(jpgPath string) error { + // Open the JPEG file for reading + f, err := os.Open(jpgPath) + if err != nil { + return err + } + defer f.Close() + + // Check if the file is a JPEG image + _, err = jpeg.Decode(f) + if err != nil { + // The file is not a JPEG image, no need to convert it + return fmt.Errorf("file %s is not a JPEG image", jpgPath) + } + + // Reset the file pointer to the beginning of the file + _, err = f.Seek(0, 0) + if err != nil { + return err + } + + // Create a new PNG file for writing + pngPath := jpgPath[:len(jpgPath)-4] + ".png" // replace .jpg extension with .png + out, err := os.Create(pngPath) + if err != nil { + return err + } + defer out.Close() + + // Decode the JPEG image and encode it as PNG + img, err := jpeg.Decode(f) + if err != nil { + return err + } + err = png.Encode(out, img) + if err != nil { + return err + } + + return nil +} + +func GetImageCompressionType(path string) (string, error) { + // 打开文件 + file, err := os.Open(path) + if err != nil { + return "", err + } + defer file.Close() + + // 创建 bufio.Reader + reader := bufio.NewReader(file) + + // 解码图像 + _, format, err := image.DecodeConfig(reader) + if err != nil { + fmt.Println("err: ", err) + return "", err + } + + fmt.Println("format: ", format) + // 返回压缩类型 + return format, nil +} diff --git a/code/services/openai/test_file/img.png b/code/services/openai/test_file/img.png new file mode 100644 index 0000000..3071bd7 Binary files /dev/null and b/code/services/openai/test_file/img.png differ diff --git a/code/services/openai/test_file/test.jpg b/code/services/openai/test_file/test.jpg new file mode 100644 index 0000000..8a862b1 Binary files /dev/null and b/code/services/openai/test_file/test.jpg differ diff --git a/code/services/openai/test_file/test.wav b/code/services/openai/test_file/test.wav new file mode 100644 index 0000000..ea490d9 Binary files /dev/null and b/code/services/openai/test_file/test.wav differ diff --git a/code/services/sessionCache.go b/code/services/sessionCache.go new file mode 100644 index 0000000..a5d1124 --- /dev/null +++ b/code/services/sessionCache.go @@ -0,0 +1,195 @@ +package services + +import ( + "start-feishubot/services/openai" + "time" + + "github.com/patrickmn/go-cache" +) + +type SessionMode string +type SessionService struct { + cache *cache.Cache +} +type PicSetting struct { + resolution Resolution +} +type Resolution string + +type SessionMeta struct { + Mode SessionMode `json:"mode"` + Msg []openai.Messages `json:"msg,omitempty"` + PicSetting PicSetting `json:"pic_setting,omitempty"` + AIMode openai.AIMode `json:"ai_mode,omitempty"` +} + +const ( + Resolution256 Resolution = "256x256" + Resolution512 Resolution = "512x512" + Resolution1024 Resolution = "1024x1024" +) +const ( + ModePicCreate SessionMode = "pic_create" + ModePicVary SessionMode = "pic_vary" + ModeGPT SessionMode = "gpt" +) + +type SessionServiceCacheInterface interface { + Get(sessionId string) *SessionMeta + Set(sessionId string, sessionMeta *SessionMeta) + GetMsg(sessionId string) []openai.Messages + SetMsg(sessionId string, msg []openai.Messages) + SetMode(sessionId string, mode SessionMode) + GetMode(sessionId string) SessionMode + GetAIMode(sessionId string) openai.AIMode + SetAIMode(sessionId string, aiMode openai.AIMode) + SetPicResolution(sessionId string, resolution Resolution) + GetPicResolution(sessionId string) string + Clear(sessionId string) +} + +var sessionServices *SessionService + +// implement Get interface +func (s *SessionService) Get(sessionId string) *SessionMeta { + sessionContext, ok := s.cache.Get(sessionId) + if !ok { + return nil + } + sessionMeta := sessionContext.(*SessionMeta) + return sessionMeta +} + +// implement Set interface +func (s *SessionService) Set(sessionId string, sessionMeta *SessionMeta) { + maxCacheTime := time.Hour * 12 + s.cache.Set(sessionId, sessionMeta, maxCacheTime) +} + +func (s *SessionService) GetMode(sessionId string) SessionMode { + // Get the session mode from the cache. + sessionContext, ok := s.cache.Get(sessionId) + if !ok { + return ModeGPT + } + sessionMeta := sessionContext.(*SessionMeta) + return sessionMeta.Mode +} + +func (s *SessionService) SetMode(sessionId string, mode SessionMode) { + maxCacheTime := time.Hour * 12 + sessionContext, ok := s.cache.Get(sessionId) + if !ok { + sessionMeta := &SessionMeta{Mode: mode} + s.cache.Set(sessionId, sessionMeta, maxCacheTime) + return + } + sessionMeta := sessionContext.(*SessionMeta) + sessionMeta.Mode = mode + s.cache.Set(sessionId, sessionMeta, maxCacheTime) +} + +func (s *SessionService) GetAIMode(sessionId string) openai.AIMode { + sessionContext, ok := s.cache.Get(sessionId) + if !ok { + return openai.Balance + } + sessionMeta := sessionContext.(*SessionMeta) + return sessionMeta.AIMode +} + +// SetAIMode set the ai mode for the session. +func (s *SessionService) SetAIMode(sessionId string, aiMode openai.AIMode) { + maxCacheTime := time.Hour * 12 + sessionContext, ok := s.cache.Get(sessionId) + if !ok { + sessionMeta := &SessionMeta{AIMode: aiMode} + s.cache.Set(sessionId, sessionMeta, maxCacheTime) + return + } + sessionMeta := sessionContext.(*SessionMeta) + sessionMeta.AIMode = aiMode + s.cache.Set(sessionId, sessionMeta, maxCacheTime) +} + +func (s *SessionService) GetMsg(sessionId string) (msg []openai.Messages) { + sessionContext, ok := s.cache.Get(sessionId) + if !ok { + return nil + } + sessionMeta := sessionContext.(*SessionMeta) + return sessionMeta.Msg +} + +func (s *SessionService) SetMsg(sessionId string, msg []openai.Messages) { + maxLength := 4096 + maxCacheTime := time.Hour * 12 + + //限制对话上下文长度 + for getStrPoolTotalLength(msg) > maxLength { + msg = append(msg[:1], msg[2:]...) + } + + sessionContext, ok := s.cache.Get(sessionId) + if !ok { + sessionMeta := &SessionMeta{Msg: msg} + s.cache.Set(sessionId, sessionMeta, maxCacheTime) + return + } + sessionMeta := sessionContext.(*SessionMeta) + sessionMeta.Msg = msg + s.cache.Set(sessionId, sessionMeta, maxCacheTime) +} + +func (s *SessionService) SetPicResolution(sessionId string, + resolution Resolution) { + maxCacheTime := time.Hour * 12 + + //if not in [Resolution256, Resolution512, Resolution1024] then set + //to Resolution256 + switch resolution { + case Resolution256, Resolution512, Resolution1024: + default: + resolution = Resolution256 + } + + sessionContext, ok := s.cache.Get(sessionId) + if !ok { + sessionMeta := &SessionMeta{PicSetting: PicSetting{resolution: resolution}} + s.cache.Set(sessionId, sessionMeta, maxCacheTime) + return + } + sessionMeta := sessionContext.(*SessionMeta) + sessionMeta.PicSetting.resolution = resolution + s.cache.Set(sessionId, sessionMeta, maxCacheTime) +} + +func (s *SessionService) GetPicResolution(sessionId string) string { + sessionContext, ok := s.cache.Get(sessionId) + if !ok { + return string(Resolution256) + } + sessionMeta := sessionContext.(*SessionMeta) + return string(sessionMeta.PicSetting.resolution) + +} + +func (s *SessionService) Clear(sessionId string) { + // Delete the session context from the cache. + s.cache.Delete(sessionId) +} + +func GetSessionCache() SessionServiceCacheInterface { + if sessionServices == nil { + sessionServices = &SessionService{cache: cache.New(time.Hour*12, time.Hour*1)} + } + return sessionServices +} + +func getStrPoolTotalLength(strPool []openai.Messages) int { + var total int + for _, v := range strPool { + total += v.CalculateTokenLength() + } + return total +} diff --git a/code/utils/audio/ogg.go b/code/utils/audio/ogg.go new file mode 100644 index 0000000..fe65db5 --- /dev/null +++ b/code/utils/audio/ogg.go @@ -0,0 +1,61 @@ +package audio + +import ( + "bytes" + "errors" + "io" + "os" + + "github.com/pion/opus" + "github.com/pion/opus/pkg/oggreader" +) + +func OggToWavByPath(ogg string, wav string) error { + input, err := os.Open(ogg) + if err != nil { + return err + } + defer input.Close() + + output, err := os.Create(wav) + if err != nil { + return err + } + + defer output.Close() + return OggToWav(input, output) +} + +func OggToWav(input io.Reader, output io.WriteSeeker) error { + ogg, _, err := oggreader.NewWith(input) + if err != nil { + return err + } + + out := make([]byte, 1920) + + decoder := opus.NewDecoder() + encoder := NewEncoder(output, 44100, 16) + + for { + segments, _, err := ogg.ParseNextPage() + if errors.Is(err, io.EOF) { + break + } else if bytes.HasPrefix(segments[0], []byte("OpusTags")) { + continue + } + + if err != nil { + panic(err) + } + + for i := range segments { + if _, _, err = decoder.Decode(segments[i], out); err != nil { + panic(err) + } + encoder.Write(out) + } + } + encoder.Close() + return nil +} diff --git a/code/utils/audio/wav.go b/code/utils/audio/wav.go new file mode 100644 index 0000000..4308f60 --- /dev/null +++ b/code/utils/audio/wav.go @@ -0,0 +1,107 @@ +package audio + +import ( + "encoding/binary" + "io" +) + +type Encoder struct { + Output io.WriteSeeker + SampleRate int + BitDepth int + totalBytes uint32 + isHeaderWritten bool +} + +func (e *Encoder) WriteHeader() error { + if err := writeLe(e.Output, []byte("RIFF")); err != nil { + return err + } + + if err := writeLe(e.Output, uint32(0)); err != nil { // Placeholder for file size + return err + } + + if err := writeLe(e.Output, []byte("WAVE")); err != nil { + return err + } + + if err := writeLe(e.Output, []byte("fmt ")); err != nil { + return err + } + if err := writeLe(e.Output, uint32(16)); err != nil { + return err + } + + if err := writeLe(e.Output, uint16(1)); err != nil { // Audio format: PCM + return err + } + if err := writeLe(e.Output, uint16(1)); err != nil { // Number of channels: 1 (mono) + return err + } + if err := writeLe(e.Output, uint32(e.SampleRate)); err != nil { + return err + } + + if err := writeLe(e.Output, uint32(e.SampleRate*e.BitDepth/8)); err != nil { + return err + } + + if err := writeLe(e.Output, uint16(e.BitDepth/8)); err != nil { + return err + } + if err := writeLe(e.Output, uint16(e.BitDepth)); err != nil { + return err + } + + if err := writeLe(e.Output, []byte("data")); err != nil { + return err + } + + if err := writeLe(e.Output, uint32(0)); err != nil { //Placeholder for data size + return err + } + e.isHeaderWritten = true + return nil +} + +func writeLe[T []byte | uint32 | uint16 | uint8](w io.Writer, data T) error { + return binary.Write(w, binary.LittleEndian, data) +} + +func (e *Encoder) Write(data []byte) error { + if !e.isHeaderWritten { + e.WriteHeader() + } + n, err := e.Output.Write(data) + if err != nil { + return err + } + e.totalBytes += uint32(n) + return nil +} + +func (e *Encoder) Close() error { + if _, err := e.Output.Seek(4, io.SeekStart); err != nil { + return err + } + if err := binary.Write(e.Output, binary.LittleEndian, uint32(36+e.totalBytes)); err != nil { + return err + } + if _, err := e.Output.Seek(40, io.SeekStart); err != nil { + return err + } + if err := binary.Write(e.Output, binary.LittleEndian, e.totalBytes); err != nil { + return err + } + return nil +} + +func NewEncoder(w io.WriteSeeker, sampleRate int, bitDepth int) *Encoder { + return &Encoder{ + SampleRate: sampleRate, + Output: w, + BitDepth: bitDepth, + isHeaderWritten: false, + } +} diff --git a/code/utils/strings.go b/code/utils/strings.go new file mode 100644 index 0000000..bd623ee --- /dev/null +++ b/code/utils/strings.go @@ -0,0 +1,38 @@ +package utils + +import "strings" + +func CutPrefix(s, prefix string) (string, bool) { + if strings.HasPrefix(s, prefix) { + return strings.TrimPrefix(s, prefix), true + } + return s, false +} + +func EitherCutPrefix(s string, prefix ...string) (string, bool) { + // 任一前缀匹配则返回剩余部分 + for _, p := range prefix { + if strings.HasPrefix(s, p) { + return strings.TrimPrefix(s, p), true + } + } + return s, false +} + +// trim space and equal +func TrimEqual(s, prefix string) (string, bool) { + if strings.TrimSpace(s) == prefix { + return "", true + } + return s, false +} + +func EitherTrimEqual(s string, prefix ...string) (string, bool) { + // 任一前缀匹配则返回剩余部分 + for _, p := range prefix { + if strings.TrimSpace(s) == p { + return "", true + } + } + return s, false +} diff --git a/code/utils/strings_test.go b/code/utils/strings_test.go new file mode 100644 index 0000000..757b16c --- /dev/null +++ b/code/utils/strings_test.go @@ -0,0 +1,109 @@ +package utils + +import "testing" + +func TestEitherCutPrefix(t *testing.T) { + type args struct { + s string + prefix []string + } + tests := []struct { + name string + args args + want string + want1 bool + }{ + { + name: "Prefix match", + args: args{ + s: "/system bar", + prefix: []string{"/system "}, + }, + want: "bar", + want1: true, + }, + + { + name: "Prefix match", + args: args{ + s: "扮演 bar", + prefix: []string{"扮演 "}, + }, + want: "bar", + want1: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, got1 := EitherCutPrefix(tt.args.s, tt.args.prefix...) + if got != tt.want { + t.Errorf("EitherCutPrefix() got = %v, want %v", got, tt.want) + } + if got1 != tt.want1 { + t.Errorf("EitherCutPrefix() got1 = %v, want %v", got1, tt.want1) + } + }) + } +} + +func TestEitherTrimEqual(t *testing.T) { + type args struct { + s string + prefix []string + } + tests := []struct { + name string + args args + want string + want1 bool + }{ + { + name: "Prefix match", + args: args{ + s: "清除", + prefix: []string{"清除"}, + }, + want: "", + want1: true, + }, + { + name: "Prefix match", + args: args{ + s: " /clear ", + prefix: []string{"清除", "/clear"}, + }, + want: "", + want1: true, + }, + { + name: "Prefix match", + args: args{ + s: " 清除 ", + prefix: []string{"清除", "/clear"}, + }, + want: "", + want1: true, + }, + { + name: "Prefix match", + args: args{ + s: " clear ", + prefix: []string{"清除", "/clear"}, + }, + want: " clear ", + want1: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, got1 := EitherTrimEqual(tt.args.s, tt.args.prefix...) + if got != tt.want { + t.Errorf("EitherTrimEqual() got = %v, want %v", got, tt.want) + } + if got1 != tt.want1 { + t.Errorf("EitherTrimEqual() got1 = %v, want %v", got1, tt.want1) + } + }) + } +} diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..d2e794b --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,30 @@ +version: '3.3' +services: + feishu-chatgpt: + container_name: feishu-chatgpt + build: + context: . + dockerfile: Dockerfile + ports: + - "9000:9000/tcp" + # volumes: + # - ./code/config.yaml:/app/config.yaml:ro + environment: + - APP_ID=cli_axxx + - APP_SECRET=xxx + - APP_ENCRYPT_KEY=xxx + - APP_VERIFICATION_TOKEN=xxx + # 请确保和飞书应用管理平台中的设置一致 + - BOT_NAME=chatGpt + # OpenAI API Key 支持负载均衡, 可以填写多个 Key 用逗号分隔 + - OPENAI_KEY=sk-xxx,sk-xxx,sk-xxx + # 服务器配置 + - HTTP_PORT=9000 + - HTTPS_PORT=9001 + - USE_HTTPS=false + - CERT_FILE=cert.pem + - KEY_FILE=key.pem + # OpenAI 地址, 一般不需要修改, 除非你有自己的反向代理 + - API_URL=https://oapi.czl.net + # 代理设置, 例如 - HTTP_PROXY=http://127.0.0.1:7890, 默认代表不使用代理 + - HTTP_PROXY diff --git a/docs/help.png b/docs/help.png new file mode 100644 index 0000000..5a714b5 Binary files /dev/null and b/docs/help.png differ diff --git a/docs/img.png b/docs/img.png new file mode 100644 index 0000000..24c2d39 Binary files /dev/null and b/docs/img.png differ diff --git a/docs/img3.png b/docs/img3.png new file mode 100644 index 0000000..3d21469 Binary files /dev/null and b/docs/img3.png differ diff --git a/docs/talk.png b/docs/talk.png new file mode 100644 index 0000000..9d18f54 Binary files /dev/null and b/docs/talk.png differ diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e69de29 diff --git a/s.yaml b/s.yaml new file mode 100644 index 0000000..74efb19 --- /dev/null +++ b/s.yaml @@ -0,0 +1,58 @@ +edition: 1.0.0 +name: feishuBot-chatGpt +access: "aliyun" # 秘钥别名 + +vars: # 全局变量 + region: "ap-southeast-1" + +services: + helloworld: + component: fc + actions: + pre-deploy: + - run: go mod tidy + path: ./code + - run: GO111MODULE=on GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o + target/main main.go + path: ./code + # post-deploy: + # - run: rm -rf target + # path: ./code + # 配置参考https://docs.serverless-devs.com/fc/yaml/readme + props: # 组件的属性值 + region: ${vars.region} # 关于变量的使用方法,可以参考:https://www.serverless-devs.com/serverless-devs/yaml#变量赋值 + service: + name: "feishubot" + description: "Serverless Devs Website Service" + function: + name: "feishu-chatgpt" + description: 'a simple feishubot by serverless devs' + codeUri: './code' + caPort: 9000 + customRuntimeConfig: + command: + - ./target/main + environmentVariables: {} + handler: index.handler + instanceConcurrency: 20 + instanceType: e1 + memorySize: 128 + runtime: custom + timeout: 120 + internetAccess: true + triggers: + - name: httpTrigger + type: http + config: + authType: anonymous + methods: + - GET + - POST + customDomains: + - domainName: auto + protocol: HTTP + routeConfigs: + - path: /* + methods: + - GET + - POST