From 8c50a35e379ce987a076a4e54e3b6d6579d70cd6 Mon Sep 17 00:00:00 2001 From: Pablo Ovelleiro Corral Date: Tue, 23 Apr 2019 17:57:32 +0200 Subject: [PATCH] fix some html templates --- giteabot.go | 2 +- listener.go | 52 ++++++++++++++++++++++++++-------------------------- main.go | 2 ++ 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/giteabot.go b/giteabot.go index d9b1d98..7954d3e 100644 --- a/giteabot.go +++ b/giteabot.go @@ -18,7 +18,7 @@ type GiteaBot struct { } //NewGiteaBot creates a new bot form user credentials -func NewGiteaBot(user, pass, host, string, DBPath string) *GiteaBot { +func NewGiteaBot(user, pass, host string, DBPath string) *GiteaBot { bot, err := matrixbot.NewMatrixBot(user, pass, "gitea") diff --git a/listener.go b/listener.go index 7de4583..e154946 100644 --- a/listener.go +++ b/listener.go @@ -101,39 +101,39 @@ func generateHTMLMessage(data GiteaPostData, eventHeader string) (string, error) mesgTemplates := map[string]string{ "push": "pushed " + strconv.Itoa(len(data.Commits)) + " commit(s) to {{.Repository.Name}}", - "issues.assigned": "assigned issue #{{Issue.Number}} {{.Issue.Title}} to {{}}", - "issues.closed": "closed issue #{{Issue.Number}} {{.Issue.Title}}", - "issues.demilestoned": "removed milestone TODO from issue #{{Issue.Number}} {{.Issue.Title}}", - "issues.edited": "edited issue #{{Issue.Number}} {{.Issue.Title}}", - "issues.label_cleared": "cleared labels from issue #{{Issue.Number}} {{.Issue.Title}}", - "issues.label_updated": "updated labels of issue #{{Issue.Number}} {{.Issue.Title}}", - "issues.milestoned": "added issue #{{Issue.Number}} {{.Issue.Title}} to milestone TODO", - "issues.opened": "opened issue #{{Issue.Number}} {{.Issue.Title}}", - "issues.reopened": "re-opened issue #{{Issue.Number}} {{.Issue.Title}}", - "issues.synchronized": "synchronized issue #{{Issue.Number}} {{.Issue.Title}}", - "issues.unassigned": "removed assignee from issue #{{Issue.Number}} {{.Issue.Title}}", + "issues.assigned": "assigned issue #{{.Issue.Number}} {{.Issue.Title}} to {{}}", + "issues.closed": "closed issue #{{.Issue.Number}} {{.Issue.Title}}", + "issues.demilestoned": "removed milestone TODO from issue #{{.Issue.Number}} {{.Issue.Title}}", + "issues.edited": "edited issue #{{.Issue.Number}} {{.Issue.Title}}", + "issues.label_cleared": "cleared labels from issue #{{.Issue.Number}} {{.Issue.Title}}", + "issues.label_updated": "updated labels of issue #{{.Issue.Number}} {{.Issue.Title}}", + "issues.milestoned": "added issue #{{.Issue.Number}} {{.Issue.Title}} to milestone TODO", + "issues.opened": "opened issue #{{.Issue.Number}} {{.Issue.Title}}", + "issues.reopened": "re-opened issue #{{.Issue.Number}} {{.Issue.Title}}", + "issues.synchronized": "synchronized issue #{{.Issue.Number}} {{.Issue.Title}}", + "issues.unassigned": "removed assignee from issue #{{.Issue.Number}} {{.Issue.Title}}", "fork": "forked repository {{.Repository.Parent.FullName}} to {{.Repository.FullName}}", - "pull_request.assigned": "assigned pull-request #{{PullRequest.Number}} #{{PullRequest.Title}} to {{.PullRequest.Assignee.FullName}}", - "pull_request.closed": "closed pull-request #{{PullRequest.Number}} #{{PullRequest.Title}}", - "pull_request.demilestoned": "removed milestone TODO from pull-request #{{PullRequest.Number}} #{{PullRequest.Title}}", - "pull_request.edited": "edited pull-request #{{PullRequest.Number}} #{{PullRequest.Title}}", - "pull_request.label_cleared": "removed labels from pull-request #{{PullRequest.Number}} #{{PullRequest.Title}}", - "pull_request.label_updated": "updated labels from pull-request #{{PullRequest.Number}} #{{PullRequest.Title}}", - "pull_request.milestoned": "added pull-request #{{PullRequest.Number}} #{{PullRequest.Title}} to milestone TODO", - "pull_request.opened": "opened pull-request #{{PullRequest.Number}} #{{PullRequest.Title}}", - "pull_request.reopened": "re-opened pull-request #{{PullRequest.Number}} #{{PullRequest.Title}}", - "pull_request.synchronized": "synchronized pull-request #{{PullRequest.Number}} #{{PullRequest.Title}}", - "pull_request.unassigned": "removed assinee from pull-request #{{PullRequest.Number}} #{{PullRequest.Title}}", + "pull_request.assigned": "assigned pull-request #.PullRequest.Number}} #{{PullRequest.Title}} to {{.PullRequest.Assignee.FullName}}", + "pull_request.closed": "closed pull-request #.PullRequest.Number}} #{{PullRequest.Title}}", + "pull_request.demilestoned": "removed milestone TODO from pull-request #.PullRequest.Number}} #{{PullRequest.Title}}", + "pull_request.edited": "edited pull-request #.PullRequest.Number}} #{{PullRequest.Title}}", + "pull_request.label_cleared": "removed labels from pull-request #.PullRequest.Number}} #{{PullRequest.Title}}", + "pull_request.label_updated": "updated labels from pull-request #.PullRequest.Number}} #{{PullRequest.Title}}", + "pull_request.milestoned": "added pull-request #.PullRequest.Number}} #{{PullRequest.Title}} to milestone TODO", + "pull_request.opened": "opened pull-request #.PullRequest.Number}} #{{PullRequest.Title}}", + "pull_request.reopened": "re-opened pull-request #.PullRequest.Number}} #{{PullRequest.Title}}", + "pull_request.synchronized": "synchronized pull-request #.PullRequest.Number}} #{{PullRequest.Title}}", + "pull_request.unassigned": "removed assinee from pull-request #.PullRequest.Number}} #{{PullRequest.Title}}", "issue_comment.created": "commented on issue #{{.Issue.Number}} {{.Issue.Title}}:
{{.Comment.Body}}
", - "issue_comment.deleted": "deleted commented on #{{Issue.Number}} {{.Issue.Title}}", + "issue_comment.deleted": "deleted commented on #{{.Issue.Number}} {{.Issue.Title}}", "repository.created": "created repository {{}}", "repository.deleted": "deleted repository {{}}", "release.published": "published release {{}}", "release.updated": "updated release {{}}", "release.deleted": "deleted release {{}}", - "pull_request_aproved": "approved pull request #{{PullRequest.Number}} #{{PullRequest.Title}}", - "pull_request_rejected": "rejected pull request #{{PullRequest.Number}} #{{PullRequest.Title}}", - "pull_request_comment": "commented on pull request #{{PullRequest.Number}} #{{PullRequest.Title}}:
{{.Comment.Body}}
",
+		"pull_request_aproved":       "approved pull request #.PullRequest.Number}} #{{PullRequest.Title}}",
+		"pull_request_rejected":      "rejected pull request  #.PullRequest.Number}} #{{PullRequest.Title}}",
+		"pull_request_comment":       "commented on pull request #.PullRequest.Number}} #{{PullRequest.Title}}: 
{{.Comment.Body}}
",
 	}
 
 	switch eventHeader {
diff --git a/main.go b/main.go
index 4f3bf89..63129b8 100644
--- a/main.go
+++ b/main.go
@@ -51,6 +51,8 @@ func init() {
 	dbPath := cfg.Section("bot").Key("db_path").String()
 
 	//Set up the bot
+
+	// func NewGiteaBot(user, pass, host, string, DBPath string) *GiteaBot {
 	mygiteabot = NewGiteaBot(matrixUser, matrixPass, matrixHost, dbPath)
 
 	if err != nil {