forked from EverythingSuckz/github-telegram-notify
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbase.go
37 lines (34 loc) · 966 Bytes
/
base.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package types
import (
"encoding/json"
)
type Metadata struct {
Sha string `json:"sha"`
RepositoryName string `json:"repository"`
RawEvent *json.RawMessage `json:"event"`
Ref_name string `json:"ref_name"`
ServerUrl string `json:"server_url"`
EventName string `json:"event_name"`
}
func (e *Metadata) ParseEvent() (event_type interface{}, err error) {
switch e.EventName {
case "fork":
event_type = &ForkEvent{}
case "issue_comment":
event_type = &IssueCommentEvent{}
case "issues":
event_type = &IssuesEvent{}
case "pull_request":
event_type = &PullRequestEvent{}
case "pull_request_review_comment":
event_type = &PullRequestReviewCommentEvent{}
case "push":
event_type = &PushEvent{}
case "release":
event_type = &ReleaseEvent{}
case "watch":
event_type = &WatchEvent{}
}
err = json.Unmarshal(*e.RawEvent, &event_type)
return event_type, err
}