This repository has been archived by the owner on Mar 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
56 lines (53 loc) · 1.57 KB
/
main.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"fmt"
ui "github.com/gorilych/fn/news/ui/telegram"
// httpSrc "github.com/gorilych/fn/news/source/http"
// rssSrc "github.com/gorilych/fn/news/source/rss"
aRepo "github.com/gorilych/fn/news/articlerepo/sqlite"
//"time"
"os"
)
func main() {
//var a = news.Article{Title: "Lorem Ipsum", Link: "https:/example.com" }
token := os.Getenv("TGBOTTOKEN")
repo, err := aRepo.NewSqliteArticleRepo("./articles.db")
if err != nil {
fmt.Println(err)
}
ui.Run(repo, token)
// rs, err := rssSrc.NewRssNewsSource("http://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml")
// if err != nil {
// fmt.Println(err)
// }
// as, _ := rs.FetchAllArticles()
// fmt.Println("============ Articles in RSS")
// fmt.Println(len(as))
// hs, err := httpSrc.NewHttpNewsSource("https://lenta.ru/parts/news")
// if err != nil {
// fmt.Println(err)
// }
// hs.SetParser(map[string]string{
// "item": ".item.news",
// "link": ".titles a",
// "title": ".titles a",
// })
// as, err = hs.FetchAllArticles()
// if err != nil {
// fmt.Println(err)
// }
// fmt.Println("============ Articles in HTML")
// fmt.Println(len(as))
// newsSrv := news.NewsService(repo, 2*time.Second)
// fmt.Println("============ Started service")
// newsSrv.AddSource(rs)
// fmt.Println("============ Added RSS, now wait")
// time.Sleep(3 * time.Second)
// as, _ = repo.GetArticlesBy("")
// fmt.Println(len(as))
// newsSrv.AddSource(hs)
// fmt.Println("============ Added HTTP, now wait")
// time.Sleep(3 * time.Second)
// as, _ = repo.GetArticlesBy("")
// fmt.Println(len(as))
}