Skip to content

Commit

Permalink
Make resending pads work
Browse files Browse the repository at this point in the history
  • Loading branch information
missytake committed Jul 26, 2024
1 parent af87efe commit a24f193
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions invitebot.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ func onBotInit(cli *botcli.BotCli, bot *deltachat.Bot, cmd *cobra.Command, args
if err != nil {
cli.Logger.Error(err)
}
err = bot.Rpc.SetConfig(accId, "delete_device_after", option.Some("1800"))
if err != nil {
cli.Logger.Error(err)
}
}
}
}
Expand All @@ -56,6 +52,10 @@ func onNewMsg(bot *deltachat.Bot, accId deltachat.AccountId, msgId deltachat.Msg
return
}

if msg.SystemMessageType == deltachat.SysmsgMemberAddedToGroup {
resendPads(bot.Rpc, accId, msg.ChatId)
}

if !msg.IsBot && !msg.IsInfo && msg.FromId > deltachat.ContactLastSpecial {
chat, err := bot.Rpc.GetBasicChatInfo(accId, msg.ChatId)
if err != nil {
Expand All @@ -68,9 +68,6 @@ func onNewMsg(bot *deltachat.Bot, accId deltachat.AccountId, msgId deltachat.Msg
logger.Error(err)
}
}
if msg.SystemMessageType == deltachat.SysmsgMemberAddedToGroup {
resendPads(bot.Rpc, accId, msg.ChatId)
}

args := strings.Split(msg.Text, " ")
switch args[0] {
Expand Down Expand Up @@ -114,9 +111,9 @@ func sendPad(rpc *deltachat.Rpc, accId deltachat.AccountId, chatId deltachat.Cha

func resendPads(rpc *deltachat.Rpc, accId deltachat.AccountId, chatId deltachat.ChatId) {
var toResend []deltachat.MsgId
selfAddr, err := rpc.GetConfig(accId, "configured_addr")
if err != nil {
msgIds, _ := rpc.GetMessageIds(accId, chatId, true, false)
selfAddr, err := rpc.GetConfig(accId, "addr")
if err == nil {
msgIds, _ := rpc.GetMessageIds(accId, chatId, false, false)
for _, id := range msgIds {
msg, _ := rpc.GetMessage(accId, id)
senderaddress := msg.Sender.Address
Expand Down

0 comments on commit a24f193

Please sign in to comment.