/* Pont Mattermost Portail des assos Copyright (C) 2021 Romain de Laage This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ package main type Owner struct { Id string `json:"id"` Login string `json:"login"` Name string `json:"name"` Image string `json:"image"` Deleted_at *string `json:"deleted_at,omitempty"` In_cemetery_at *string `json:"in_cemetry_at,omitempty"` Model string `json:"model"` } type VisibilityT struct { Id string `json:"id"` Type string `json:"type"` Name string `json:"name"` } type Article struct { Id string `json:"id"` Title string `json:"title"` Description string `json:"description"` Content string `json:"content"` Image string `json:"image,omitempty"` Created_at string `json:"created_at"` Owned_by Owner `json:"owned_by"` Visibility VisibilityT `json:"visibility"` Event *string `json:"event,omitempty"` } type Message struct { Channel_id string `json:"channel_id"` Message_content string `json:"message"` } type Config struct { ChannelId string ApiToken string ApiEndpointMM string ApiEndpointAssos string DbPath string ForB64 string } func main() { config := getConfig() articles := getArticles(config.ApiEndpointAssos, config.ForB64) entries := openDb(config.DbPath) for _, article := range articles { if !isInDb(article.Id, entries) { sendMessage(article, config.ChannelId, config.ApiEndpointMM, config.ApiToken) addInDb(article.Id, config.DbPath) } } }