Skip to content

Commit

Permalink
Archive payments instead of removing them
Browse files Browse the repository at this point in the history
  • Loading branch information
DearRude committed May 1, 2024
1 parent 396dd32 commit d929ef6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion handlers/handle_callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func varificationChatResponse(u in.UpdateCallback) error {
}

// Delete the message
if err := deleteMessage(u); err != nil {
if err := seenMessage(u); err != nil {
return err
}

Expand Down
23 changes: 19 additions & 4 deletions handlers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/gotd/td/telegram/message"
"github.com/gotd/td/telegram/message/markup"
"github.com/gotd/td/tg"

"github.com/DearRude/siahe/database"
Expand Down Expand Up @@ -46,6 +47,14 @@ func getSenderUser(peer tg.PeerClass, ent tg.Entities) (*tg.User, error) {
return user, nil
}

func getInputPeerChat(peer tg.PeerClass) (*tg.InputPeerChat, error) {
peerChat, ok := peer.(*tg.PeerChat)
if !ok {
return nil, fmt.Errorf("peerclass could not reflect to peer chat")
}
return peerChat.AsInput(), nil
}

func getTextFromContact(u in.UpdateMessage) (string, error) {
media, ok := u.Message.GetMedia()
if !ok {
Expand Down Expand Up @@ -244,10 +253,16 @@ func getUserEventIDFromVarification(u in.UpdateCallback) (*tg.InputPeerUser, uin
return peer, uint(eventID), nil
}

func deleteMessage(u in.UpdateCallback) error {
_, err := client.MessagesDeleteMessages(u.Ctx, &tg.MessagesDeleteMessagesRequest{
ID: []int{u.Ubc.MsgID},
Revoke: true,
func seenMessage(u in.UpdateCallback) error {
inputPeer, err := getInputPeerChat(u.Ubc.GetPeer())
if err != nil {
return err
}

_, err = client.MessagesEditMessage(u.Ctx, &tg.MessagesEditMessageRequest{
ID: u.Ubc.MsgID,
Peer: inputPeer,
ReplyMarkup: markup.InlineRow(markup.Callback("بررسی شد.", []byte("some_random_thing"))),
},
)

Expand Down

0 comments on commit d929ef6

Please sign in to comment.