Skip to content

Commit 7884991

Browse files
committed
fix title message
1 parent 8d38c3b commit 7884991

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

dvach/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ func (svc *API) GetThread(board string, threadID string, offset int) ([]Post, er
4848
return posts, nil
4949
}
5050

51-
func (svc *API) GetPost(board string, num int) ([]Post, error) {
51+
func (svc *API) GetPost(board string, num string) ([]Post, error) {
5252
endpoint := fmt.Sprintf(
53-
"%s/makaba/mobile.fcgi?task=get_post&board=%s&post=%d",
53+
"%s/makaba/mobile.fcgi?task=get_post&board=%s&post=%s",
5454
Endpoint, board, num)
5555

5656
posts := make([]Post, 0)

service/service.go

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func Start() {
5858
newOffset, err := onEvent(chat, board, threadID, offset)
5959
if err != nil {
6060
go onAlertAdministrators(chat,
61-
"An error has occured. Subscription suspended.\nChat: %s\nThread: %s\nError: %s",
61+
"#info\nAn error has occured. Subscription suspended.\nChat: %s\nThread: %s\nError: %s",
6262
chat.Key(), dv.FormatThreadURL(board, threadID), err.Error())
6363

6464
return 0, err
@@ -95,15 +95,37 @@ func Subscribe(chat telegram.ChatRef, board string, threadID string) {
9595
err := sub.newActiveThread(board, threadID)
9696
if err != nil {
9797
go onAlertAdministrators(chat,
98-
"Subscription failed.\nChat: %s\nThread: %s\nError: %s",
98+
"#info\nSubscription failed.\nChat: %s\nThread: %s\nError: %s",
9999
chat.Key(), dv.FormatThreadURL(board, threadID), err.Error())
100100

101101
return
102102
}
103103

104-
go onAlertAdministrators(chat,
105-
"Subscription OK.\nChat: %s\nThread: %s",
106-
chat.Key(), dv.FormatThreadURL(board, threadID))
104+
go func() {
105+
onAlertAdministrators(chat,
106+
"#info\nSubscription OK.\nChat: %s\nThread: %s",
107+
chat.Key(), dv.FormatThreadURL(board, threadID))
108+
109+
preview, err := _runtime.dvach.GetPost(board, threadID)
110+
if err != nil {
111+
return
112+
}
113+
114+
threadURL := dv.FormatThreadURL(board, threadID)
115+
text := ""
116+
if len(preview) > 0 {
117+
text = fmt.Sprintf(
118+
"#thread %s %s",
119+
preview[0].Subject, threadURL)
120+
} else {
121+
text = fmt.Sprintf("#thread %s", threadURL)
122+
}
123+
124+
_runtime.bot.SendMessage(telegram.SendMessageRequest{
125+
Chat: chat,
126+
Text: text,
127+
}, nil, true)
128+
}()
107129
}
108130

109131
// Unsubscribe chat from all threads

0 commit comments

Comments
 (0)