tss/main.go

69 lines
1.2 KiB
Go
Raw Normal View History

2022-04-26 09:55:59 -04:00
package main
import (
"log"
"net/url"
"os"
)
func main() {
var err error
for _, feed := range c.Feeds {
log.Println("Processing feed", feed.Name)
data, err := download(feed.Url)
if err != nil {
log.Fatal(err)
}
links, err := parseFeed(data)
if err != nil {
log.Fatal(err)
}
for _, link := range links {
if alreadySent(link) {
continue
}
err := sendTelegram(link, feed.Channel, feed.Rhash)
if err != nil {
log.Fatal(err)
}
}
}
}
func download(url string) ([]byte, error) {
log.Println("url", url)
return os.ReadFile("ounapuu.xml")
}
func parseFeed(data []byte) ([]string, error) {
return []string{"https://blog.link"}, nil
}
func alreadySent(link string) bool {
return false
}
func sendTelegram(link string, channel string, rhash string) error {
log.Println("link", link, "channel", channel, "rhash", rhash)
rhash = "ae86262f2de32f"
log.Println("ivurl", genIVLink(link, rhash))
return nil
}
func genIVLink(link, rhash string) string {
query := url.Values{}
query.Set("url", link)
query.Set("rhash", rhash)
u := url.URL{
Scheme: "https",
Host: "t.me",
Path: "iv",
RawQuery: vs.Encode(),
}
return u.String()
}