

+A new feedback form has been released today. Help us to find out which websites and magazines are popular in your country by filling out the new questionnaire. In our current poll we are curious about your occupation. |
diff --git a/src/TibiaNews.go b/src/TibiaNews.go
index 58c79d46..85e8112d 100644
--- a/src/TibiaNews.go
+++ b/src/TibiaNews.go
@@ -27,9 +27,7 @@ type NewsResponse struct {
Information Information `json:"information"`
}
-var (
- martelRegex = regexp.MustCompile(`
]+..)`)
-)
+var martelRegex = regexp.MustCompile(`
]+..)`)
func TibiaNewsImpl(NewsID int, rawUrl string, BoxContentHTML string) (NewsResponse, error) {
// Declaring vars for later use..
@@ -89,11 +87,20 @@ func TibiaNewsImpl(NewsID int, rawUrl string, BoxContentHTML string) (NewsRespon
// checking if its a ticker..
if NewsData.Type == "ticker" {
tmp1 = s.Find("p")
- NewsData.Content = tmp1.Text()
- NewsData.ContentHTML, err = tmp1.Html()
- if err != nil {
- insideError = fmt.Errorf("[error] TibiaNewsImpl failed at NewsData.ContentHTML, err = tmp1.Html(), err: %s", err)
- return false
+ if tmp1.Text() == "" {
+ NewsData.Content = s.Text()
+ NewsData.ContentHTML, err = s.Html()
+ if err != nil {
+ insideError = fmt.Errorf("[error] TibiaNewsImpl failed at NewsData.ContentHTML, err = s.Html(), err: %s", err)
+ return false
+ }
+ } else {
+ NewsData.Content = tmp1.Text()
+ NewsData.ContentHTML, err = tmp1.Html()
+ if err != nil {
+ insideError = fmt.Errorf("[error] TibiaNewsImpl failed at NewsData.ContentHTML, err = tmp1.Html(), err: %s", err)
+ return false
+ }
}
} else {
// getting html
diff --git a/src/TibiaNews_test.go b/src/TibiaNews_test.go
index 2260ec0f..62f9b152 100644
--- a/src/TibiaNews_test.go
+++ b/src/TibiaNews_test.go
@@ -66,6 +66,35 @@ func TestNews6512(t *testing.T) {
assert.Equal("TibiaData.com has some news to share! First of all, they invite you to participate in their Discord Server. Further, they are now present on GitHub. They are working on their v3, which is still in beta. If you are interested in such things, head on over there to see what is cooking.", newsArticleJson.News.ContentHTML)
}
+func TestNews504(t *testing.T) {
+ file, err := static.TestFiles.Open("testdata/news/archive/504.html")
+ if err != nil {
+ t.Fatalf("file opening error: %s", err)
+ }
+ defer file.Close()
+
+ data, err := io.ReadAll(file)
+ if err != nil {
+ t.Fatalf("File reading error: %s", err)
+ }
+
+ newsArticleJson, err := TibiaNewsImpl(504, "https://www.tibia.com/news/?subtopic=newsarchive&id=504", string(data))
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ assert := assert.New(t)
+
+ assert.Equal(504, newsArticleJson.News.ID)
+ assert.Equal("2007-04-27", newsArticleJson.News.Date)
+ assert.Empty(newsArticleJson.News.Title)
+ assert.Equal("community", newsArticleJson.News.Category)
+ assert.Equal("ticker", newsArticleJson.News.Type)
+ assert.Equal("https://www.tibia.com/news/?subtopic=newsarchive&id=504", newsArticleJson.News.TibiaURL)
+ assert.Equal("A new feedback form has been released today. Help us to find out which websites and magazines are popular in your country by filling out the new questionnaire. In our current poll we are curious about your occupation.", newsArticleJson.News.Content)
+ assert.Equal("
A new feedback form has been released today. Help us to find out which websites and magazines are popular in your country by filling out the new questionnaire. In our current poll we are curious about your occupation.", newsArticleJson.News.ContentHTML)
+}
+
func TestNews6481(t *testing.T) {
file, err := static.TestFiles.Open("testdata/news/archive/6481.html")
if err != nil {
diff --git a/src/static/testdata/news/archive/504.html b/src/static/testdata/news/archive/504.html
new file mode 100644
index 00000000..8ebc3f54
--- /dev/null
+++ b/src/static/testdata/news/archive/504.html
@@ -0,0 +1,778 @@
+
+
+
+


+A new feedback form has been released today. Help us to find out which websites and magazines are popular in your country by filling out the new questionnaire. In our current poll we are curious about your occupation. |
Access ALL Areas!
