diff options
author | Andinus <andinus@nand.sh> | 2020-03-22 13:43:54 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-03-22 13:43:54 +0530 |
commit | 9fde6e5a892b228c2d64af05b02380847573c832 (patch) | |
tree | 0d8fb21a7825b0e9f678180f5b66d866c8b38afa /summarize | |
parent | c3ff3d068fdeacacec1f693bf9513742983814ad (diff) | |
download | indus-9fde6e5a892b228c2d64af05b02380847573c832.tar.gz |
Add initial version
Diffstat (limited to 'summarize')
-rw-r--r-- | summarize/wikipedia.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/summarize/wikipedia.go b/summarize/wikipedia.go new file mode 100644 index 0000000..c4a5050 --- /dev/null +++ b/summarize/wikipedia.go @@ -0,0 +1,27 @@ +package summarize + +import ( + "fmt" + + "framagit.org/andinus/indus/fetch" + "framagit.org/andinus/indus/notification" +) + +// Wikipedia returns struct notification.Notif with notification info +// from the wikipedia summary. +func Wikipedia(w fetch.Wiki) (notification.Notif, error) { + n := notification.Notif{} + var err error + + // Continue only if the page's type is standard. TODO: Work + // with other page types to get summary. + switch w.Type { + case "standard": + n.Title = fmt.Sprintf("%s - Wikipedia", w.Title) + n.Message = w.Description + default: + err = fmt.Errorf("Summarizing wikipedia response failed") + } + + return n, err +} |