1
0
mirror of https://github.com/pinpox/gitea-matrix-bot synced 2024-11-26 08:43:47 +01:00

fix some html templates

This commit is contained in:
Pablo Ovelleiro Corral 2019-04-23 17:57:32 +02:00
parent bb79e34417
commit 8c50a35e37
No known key found for this signature in database
GPG Key ID: F7C1D57C8464E825
3 changed files with 29 additions and 27 deletions

@ -18,7 +18,7 @@ type GiteaBot struct {
} }
//NewGiteaBot creates a new bot form user credentials //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") bot, err := matrixbot.NewMatrixBot(user, pass, "gitea")

@ -101,39 +101,39 @@ func generateHTMLMessage(data GiteaPostData, eventHeader string) (string, error)
mesgTemplates := map[string]string{ mesgTemplates := map[string]string{
"push": "pushed " + strconv.Itoa(len(data.Commits)) + " commit(s) to {{.Repository.Name}}", "push": "pushed " + strconv.Itoa(len(data.Commits)) + " commit(s) to {{.Repository.Name}}",
"issues.assigned": "assigned issue <b>#{{Issue.Number}}</b> <i>{{.Issue.Title}}</i> to {{}}", "issues.assigned": "assigned issue <b>#{{.Issue.Number}}</b> <i>{{.Issue.Title}}</i> to {{}}",
"issues.closed": "closed issue <b>#{{Issue.Number}}</b> <i>{{.Issue.Title}}</i>", "issues.closed": "closed issue <b>#{{.Issue.Number}}</b> <i>{{.Issue.Title}}</i>",
"issues.demilestoned": "removed milestone TODO from issue <b>#{{Issue.Number}}</b> <i>{{.Issue.Title}}</i>", "issues.demilestoned": "removed milestone TODO from issue <b>#{{.Issue.Number}}</b> <i>{{.Issue.Title}}</i>",
"issues.edited": "edited issue <b>#{{Issue.Number}}</b> <i>{{.Issue.Title}}</i>", "issues.edited": "edited issue <b>#{{.Issue.Number}}</b> <i>{{.Issue.Title}}</i>",
"issues.label_cleared": "cleared labels from issue <b>#{{Issue.Number}}</b> <i>{{.Issue.Title}}</i>", "issues.label_cleared": "cleared labels from issue <b>#{{.Issue.Number}}</b> <i>{{.Issue.Title}}</i>",
"issues.label_updated": "updated labels of issue <b>#{{Issue.Number}}</b> <i>{{.Issue.Title}}</i>", "issues.label_updated": "updated labels of issue <b>#{{.Issue.Number}}</b> <i>{{.Issue.Title}}</i>",
"issues.milestoned": "added issue <b>#{{Issue.Number}}</b> <i>{{.Issue.Title}}</i> to milestone TODO", "issues.milestoned": "added issue <b>#{{.Issue.Number}}</b> <i>{{.Issue.Title}}</i> to milestone TODO",
"issues.opened": "opened issue <b>#{{Issue.Number}}</b> <i>{{.Issue.Title}}</i>", "issues.opened": "opened issue <b>#{{.Issue.Number}}</b> <i>{{.Issue.Title}}</i>",
"issues.reopened": "re-opened issue <b>#{{Issue.Number}}</b> <i>{{.Issue.Title}}</i>", "issues.reopened": "re-opened issue <b>#{{.Issue.Number}}</b> <i>{{.Issue.Title}}</i>",
"issues.synchronized": "synchronized issue <b>#{{Issue.Number}}</b> <i>{{.Issue.Title}}</i>", "issues.synchronized": "synchronized issue <b>#{{.Issue.Number}}</b> <i>{{.Issue.Title}}</i>",
"issues.unassigned": "removed assignee from issue <b>#{{Issue.Number}}</b> <i>{{.Issue.Title}}</i>", "issues.unassigned": "removed assignee from issue <b>#{{.Issue.Number}}</b> <i>{{.Issue.Title}}</i>",
"fork": "forked repository {{.Repository.Parent.FullName}} to {{.Repository.FullName}}", "fork": "forked repository {{.Repository.Parent.FullName}} to {{.Repository.FullName}}",
"pull_request.assigned": "assigned pull-request <b>#{{PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i> to {{.PullRequest.Assignee.FullName}}", "pull_request.assigned": "assigned pull-request <b>#.PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i> to {{.PullRequest.Assignee.FullName}}",
"pull_request.closed": "closed pull-request <b>#{{PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>", "pull_request.closed": "closed pull-request <b>#.PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>",
"pull_request.demilestoned": "removed milestone TODO from pull-request <b>#{{PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>", "pull_request.demilestoned": "removed milestone TODO from pull-request <b>#.PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>",
"pull_request.edited": "edited pull-request <b>#{{PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>", "pull_request.edited": "edited pull-request <b>#.PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>",
"pull_request.label_cleared": "removed labels from pull-request <b>#{{PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>", "pull_request.label_cleared": "removed labels from pull-request <b>#.PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>",
"pull_request.label_updated": "updated labels from pull-request <b>#{{PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>", "pull_request.label_updated": "updated labels from pull-request <b>#.PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>",
"pull_request.milestoned": "added pull-request <b>#{{PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i> to milestone TODO", "pull_request.milestoned": "added pull-request <b>#.PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i> to milestone TODO",
"pull_request.opened": "opened pull-request <b>#{{PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>", "pull_request.opened": "opened pull-request <b>#.PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>",
"pull_request.reopened": "re-opened pull-request <b>#{{PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>", "pull_request.reopened": "re-opened pull-request <b>#.PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>",
"pull_request.synchronized": "synchronized pull-request <b>#{{PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>", "pull_request.synchronized": "synchronized pull-request <b>#.PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>",
"pull_request.unassigned": "removed assinee from pull-request <b>#{{PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>", "pull_request.unassigned": "removed assinee from pull-request <b>#.PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>",
"issue_comment.created": "commented on issue <b>#{{.Issue.Number}}</b> <i>{{.Issue.Title}}</i>:<br> <pre><code class='language-markdown'>{{.Comment.Body}}</code></pre>", "issue_comment.created": "commented on issue <b>#{{.Issue.Number}}</b> <i>{{.Issue.Title}}</i>:<br> <pre><code class='language-markdown'>{{.Comment.Body}}</code></pre>",
"issue_comment.deleted": "deleted commented on <b>#{{Issue.Number}}</b> <i>{{.Issue.Title}}</i>", "issue_comment.deleted": "deleted commented on <b>#{{.Issue.Number}}</b> <i>{{.Issue.Title}}</i>",
"repository.created": "created repository {{}}", "repository.created": "created repository {{}}",
"repository.deleted": "deleted repository {{}}", "repository.deleted": "deleted repository {{}}",
"release.published": "published release {{}}", "release.published": "published release {{}}",
"release.updated": "updated release {{}}", "release.updated": "updated release {{}}",
"release.deleted": "deleted release {{}}", "release.deleted": "deleted release {{}}",
"pull_request_aproved": "approved pull request <b>#{{PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>", "pull_request_aproved": "approved pull request <b>#.PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>",
"pull_request_rejected": "rejected pull request <b>#{{PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>", "pull_request_rejected": "rejected pull request <b>#.PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>",
"pull_request_comment": "commented on pull request <b>#{{PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>: <pre><code class='language-markdown'>{{.Comment.Body}}</code><pre>", "pull_request_comment": "commented on pull request <b>#.PullRequest.Number}}</b> <i>#{{PullRequest.Title}}</i>: <pre><code class='language-markdown'>{{.Comment.Body}}</code><pre>",
} }
switch eventHeader { switch eventHeader {

@ -51,6 +51,8 @@ func init() {
dbPath := cfg.Section("bot").Key("db_path").String() dbPath := cfg.Section("bot").Key("db_path").String()
//Set up the bot //Set up the bot
// func NewGiteaBot(user, pass, host, string, DBPath string) *GiteaBot {
mygiteabot = NewGiteaBot(matrixUser, matrixPass, matrixHost, dbPath) mygiteabot = NewGiteaBot(matrixUser, matrixPass, matrixHost, dbPath)
if err != nil { if err != nil {