Py学习  »  Git

自动github问题机器人?

staticvoidliam7 • 3 年前 • 1131 次点击  

我想制作一个discord机器人,根据discord的用户输入创建一个问题。知道我该怎么做吗?我正在使用JavaScript,并希望将其集成到现有的机器人中。谢谢

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/131514
 
1131 次点击  
文章 [ 2 ]  |  最新文章 3 年前
skara9
Reply   •   1 楼
skara9    3 年前

有关详细信息,请参阅GitHub API文档 Creating Issues

你可能需要为它创建一个应用程序。

VonC
Reply   •   2 楼
VonC    3 年前

你可以从中汲取灵感 LeagueSandbox/IssueBot (Typescript),这确实会产生问题。

它确实有用 npmjs.com/package/github-api 从…起 github-tools/github

export class IssueCommand extends Command {
  execute() {
    if(!this.args) {
      return
    }
    let issueBody = ISSUE_TEMPLATE
      .replace("{PLACEHOLDER}", this.args[2] || "_No content_")
      .replace("{CHANNEL}", this.message.channel.name)
      .replace("{USER}", this.message.author.username)
    Bot.gitHub.api.issues.create({
        owner: config.githubName,
        repo: this.args[0],
        title: this.args[1],
        body: <any>issueBody // Typings for the `github` package are incorrect, so we have to cast to any here.
      },
      (error, response) => this.handleGithubResponse(error, response)
    )
  }

  handleGithubResponse(error, response) {
    if(error) {
      let formattedError = JSON.stringify(error, null, 4)
      let reply = ERROR_TEMPLATE.replace('{PLACEHOLDER}', formattedError)
      this.message.reply(reply)
      return
    }
    let reply = SUCCESS_TEMPLATE.replace('{PLACEHOLDER}', response.html_url)
    this.message.reply(reply)
  }
}

你必须 set up that bot in your Discord application .