Skip to content

Commit 985809f

Browse files
committed
Various bug fixes and vendored libraries update
1 parent cfb3200 commit 985809f

File tree

1,227 files changed

+609724
-11176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,227 files changed

+609724
-11176
lines changed

endpoints/telegram/telegram_endpoint.go

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func InitializeTelegramEndpoint(token string, exitChan <-chan struct{}, database
156156
e.commands = map[string]handlerWithDescription{
157157
"/new": {
158158
f: e.handlerNew,
159-
description: "```/new repo filter\\_name filter_regexp``` \\-\\- creates new available subscription" + `
159+
description: "`/new repo filter\\_name filter_regexp` \\-\\- creates new available subscription" + `
160160
161161
Example:
162162
` + "`/new lomik/go\\-carbon all ^V`" + `
@@ -335,7 +335,10 @@ func (e *TelegramEndpoint) sendMessage(chatID int64, messageID int, message stri
335335
message,
336336
).WithParseMode(telego.ModeMarkdownV2)
337337
if messageID != 0 {
338-
msg = msg.WithReplyToMessageID(messageID)
338+
replyParams := &telego.ReplyParameters{
339+
MessageID: messageID,
340+
}
341+
msg = msg.WithReplyParameters(replyParams)
339342
}
340343

341344
_, err := e.api.SendMessage(msg)
@@ -354,7 +357,10 @@ func (e *TelegramEndpoint) sendRawMessage(chatID int64, messageID int, message s
354357
message,
355358
)
356359
if messageID != 0 {
357-
msg = msg.WithReplyToMessageID(messageID)
360+
replyParams := &telego.ReplyParameters{
361+
MessageID: messageID,
362+
}
363+
msg = msg.WithReplyParameters(replyParams)
358364
}
359365

360366
_, err := e.api.SendMessage(msg)
@@ -498,7 +504,7 @@ func (e *TelegramEndpoint) handlerNew(tokens []string, update *telego.Update) er
498504

499505
feeds.UpdateFeeds([]*feeds.Feed{feed})
500506

501-
return e.sendMessage(update.Message.Chat.ID, update.Message.MessageID, "done")
507+
return e.sendMessage(update.Message.Chat.ID, update.Message.MessageID, fmt.Sprintf("new filter has been created, to subscribe it use `/subscribe %s %s` command", repo, name))
502508
}
503509

504510
func (e *TelegramEndpoint) handlerForceProcess(tokens []string, update *telego.Update) error {
@@ -625,16 +631,35 @@ func (e *TelegramEndpoint) unsubscribe(logger *zap.Logger, chatID int64, url str
625631
}
626632

627633
func (e *TelegramEndpoint) handlerList(tokens []string, update *telego.Update) error {
628-
response := "Configured feeds:\n"
634+
responses := make([]string, 0, 4)
635+
response := ""
636+
feedsPerMessage := 50
637+
idx := 0
629638
configs.Config.RLock()
630639
for _, feed := range configs.Config.FeedsConfig {
631640
for _, feedFilter := range feed.Filters {
632641
response = response + "`" + feed.Repo + "`: `" + feedFilter.Name + "`\n"
642+
idx++
643+
if idx == feedsPerMessage {
644+
responses = append(responses, response)
645+
response = ""
646+
idx = 0
647+
}
633648
}
634649
}
650+
responses = append(responses, response)
635651
configs.Config.RUnlock()
636652

637-
return e.sendMessage(update.Message.Chat.ID, update.Message.MessageID, response)
653+
var err error
654+
for i, response := range responses {
655+
response = fmt.Sprintf("Configured feeds %v/%v:\n%s", i+1, len(responses), response)
656+
err2 := e.sendMessage(update.Message.Chat.ID, update.Message.MessageID, response)
657+
if err2 != nil {
658+
e.logger.Error("error sending list", zap.Error(err))
659+
err = err2
660+
}
661+
}
662+
return err
638663
}
639664

640665
func (e *TelegramEndpoint) handlerHelp(_ []string, update *telego.Update) error {
@@ -656,6 +681,7 @@ func (e *TelegramEndpoint) handlerHelp(_ []string, update *telego.Update) error
656681
func (e *TelegramEndpoint) checkUnrecoverableSendError(err error) bool {
657682
if strings.Contains(err.Error(), "chat not found") ||
658683
strings.Contains(err.Error(), "bot was kicked") ||
684+
strings.Contains(err.Error(), "the group chat was deleted") ||
659685
strings.Contains(err.Error(), "bot was blocked by the user") ||
660686
strings.Contains(err.Error(), "not enough rights to send text messages") {
661687
return false

feeds/process.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func (f *Feed) processSingleItem(cfg *configs.FeedsConfig, url string, item *gof
212212
}
213213
content = strings.Replace(content, "```", "", 1)
214214

215-
notification += "\nRelease notes:\n```\n" + content + "\n```"
215+
notification += "\nRelease notes:\n```\n" + content + "\n```\n"
216216
if contentTruncated {
217217
notification += "[More](" + item.Link + ")"
218218
}
@@ -375,13 +375,13 @@ func (f *Feed) ProcessFeed() {
375375
zap.Error(err),
376376
)
377377
if strings.Contains(err.Error(), "404 Not Found") {
378-
err = f.db.RemoveFeed(f.Name, f.Repo, f.Filter, f.MessagePattern)
379-
if err != nil {
380-
f.logger.Error("error removing feed", zap.Error(err))
381-
continue
382-
}
383-
f.logger.Info("feed removed")
384-
return
378+
// err = f.db.RemoveFeed(f.Name, f.Repo, f.Filter, f.MessagePattern)
379+
// if err != nil {
380+
// f.logger.Error("error removing feed", zap.Error(err))
381+
// continue
382+
// }
383+
f.logger.Info("feed should be removed")
384+
// return
385385
}
386386
continue
387387
}

go.mod

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,49 @@
11
module github.com/Civil/github2telegram
22

3-
go 1.21.2
3+
go 1.22.3
4+
5+
toolchain go1.22.5
46

57
require (
68
github.com/lomik/zapwriter v0.0.0-20210624082824-c1161d1eb463
79
github.com/lunny/html2md v0.0.0-20181018071239-7d234de44546
8-
github.com/mattn/go-sqlite3 v1.14.17
9-
github.com/mmcdole/gofeed v1.2.1
10-
github.com/mymmrac/telego v0.26.3
10+
github.com/mattn/go-sqlite3 v1.14.22
11+
github.com/mmcdole/gofeed v1.3.0
12+
github.com/mymmrac/telego v0.30.2
1113
github.com/pkg/errors v0.9.1
12-
github.com/stretchr/testify v1.8.4
13-
go.uber.org/zap v1.26.0
14+
github.com/stretchr/testify v1.9.0
15+
go.uber.org/zap v1.27.0
1416
gopkg.in/yaml.v2 v2.4.0
1517
)
1618

1719
require (
18-
github.com/PuerkitoBio/goquery v1.8.0 // indirect
19-
github.com/andybalholm/brotli v1.0.5 // indirect
20-
github.com/andybalholm/cascadia v1.3.1 // indirect
20+
github.com/PuerkitoBio/goquery v1.9.2 // indirect
21+
github.com/andybalholm/brotli v1.1.0 // indirect
22+
github.com/andybalholm/cascadia v1.3.2 // indirect
23+
github.com/bytedance/sonic v1.11.9 // indirect
24+
github.com/bytedance/sonic/loader v0.1.1 // indirect
25+
github.com/cloudwego/base64x v0.1.4 // indirect
26+
github.com/cloudwego/iasm v0.2.0 // indirect
2127
github.com/davecgh/go-spew v1.1.1 // indirect
22-
github.com/fasthttp/router v1.4.20 // indirect
23-
github.com/goccy/go-json v0.10.2 // indirect
28+
github.com/fasthttp/router v1.5.1 // indirect
29+
github.com/grbit/go-json v0.11.0 // indirect
2430
github.com/json-iterator/go v1.1.12 // indirect
25-
github.com/klauspost/compress v1.16.5 // indirect
26-
github.com/mmcdole/goxpp v1.1.0 // indirect
31+
github.com/klauspost/compress v1.17.9 // indirect
32+
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
33+
github.com/mmcdole/goxpp v1.1.1 // indirect
2734
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
2835
github.com/modern-go/reflect2 v1.0.2 // indirect
2936
github.com/pmezard/go-difflib v1.0.0 // indirect
3037
github.com/rogpeppe/go-internal v1.11.0 // indirect
31-
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
38+
github.com/savsgio/gotils v0.0.0-20240303185622-093b76447511 // indirect
39+
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
3240
github.com/valyala/bytebufferpool v1.0.0 // indirect
33-
github.com/valyala/fasthttp v1.50.0 // indirect
34-
go.uber.org/multierr v1.10.0 // indirect
35-
golang.org/x/net v0.8.0 // indirect
36-
golang.org/x/text v0.8.0 // indirect
41+
github.com/valyala/fasthttp v1.55.0 // indirect
42+
github.com/valyala/fastjson v1.6.4 // indirect
43+
go.uber.org/multierr v1.11.0 // indirect
44+
golang.org/x/arch v0.8.0 // indirect
45+
golang.org/x/net v0.26.0 // indirect
46+
golang.org/x/sys v0.21.0 // indirect
47+
golang.org/x/text v0.16.0 // indirect
3748
gopkg.in/yaml.v3 v3.0.1 // indirect
3849
)

0 commit comments

Comments
 (0)