From 9fde6e5a892b228c2d64af05b02380847573c832 Mon Sep 17 00:00:00 2001 From: Andinus Date: Sun, 22 Mar 2020 13:43:54 +0530 Subject: Add initial version --- summarize/wikipedia.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 summarize/wikipedia.go (limited to 'summarize') 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 +} -- cgit 1.4.1-2-gfad0