Skip to content
Snippets Groups Projects
Verified Commit 4d4c95dc authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Fix target issues

parent b903415b
No related branches found
No related tags found
No related merge requests found
......@@ -94,6 +94,14 @@ func main() {
issueRegex := regexp.MustCompile("#\\d+\\b")
client.Handlers.Add(girc.PRIVMSG, func(client *girc.Client, event girc.Event) {
issues := issueRegex.FindAllString(event.Trailing, -1)
var target string
if len(event.Params) > 0 && girc.IsValidChannel(event.Params[0]) {
target = event.Params[0]
} else {
target = event.Source.Name
}
for _, idString := range issues {
id, err := strconv.Atoi(idString[1:])
if err != nil {
......@@ -104,9 +112,9 @@ func main() {
continue
}
if issue.ClosedAt != nil {
client.Cmd.Notice(event.Source.Name, fmt.Sprintf("#%d (closed): %s – %s", issue.IID, issue.Title, issue.WebURL))
client.Cmd.Notice(target, fmt.Sprintf("#%d (closed): %s – %s", issue.IID, issue.Title, issue.WebURL))
} else {
client.Cmd.Notice(event.Source.Name, fmt.Sprintf("#%d: %s – %s", issue.IID, issue.Title, issue.WebURL))
client.Cmd.Notice(target, fmt.Sprintf("#%d: %s – %s", issue.IID, issue.Title, issue.WebURL))
}
}
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment