@@ -31,7 +31,9 @@ import (
31
31
"go.mau.fi/whatsmeow"
32
32
"go.mau.fi/whatsmeow/appstate"
33
33
waBinary "go.mau.fi/whatsmeow/binary"
34
- waProto "go.mau.fi/whatsmeow/binary/proto"
34
+ "go.mau.fi/whatsmeow/proto/waCommon"
35
+ "go.mau.fi/whatsmeow/proto/waCompanionReg"
36
+ "go.mau.fi/whatsmeow/proto/waE2E"
35
37
"go.mau.fi/whatsmeow/store"
36
38
"go.mau.fi/whatsmeow/store/sqlstore"
37
39
"go.mau.fi/whatsmeow/types"
@@ -58,7 +60,7 @@ func main() {
58
60
}
59
61
if * requestFullSync {
60
62
store .DeviceProps .RequireFullSync = proto .Bool (true )
61
- store .DeviceProps .HistorySyncConfig = & waProto .DeviceProps_HistorySyncConfig {
63
+ store .DeviceProps .HistorySyncConfig = & waCompanionReg .DeviceProps_HistorySyncConfig {
62
64
FullSyncDaysLimit : proto .Uint32 (3650 ),
63
65
FullSyncSizeMbLimit : proto .Uint32 (102400 ),
64
66
StorageQuotaMb : proto .Uint32 (102400 ),
@@ -265,7 +267,7 @@ func handleCmd(cmd string, args []string) {
265
267
}
266
268
resp , err := cli .IsOnWhatsApp (args )
267
269
if err != nil {
268
- log .Errorf ("Failed to check if users are on WhatsApp:" , err )
270
+ log .Errorf ("Failed to check if users are on WhatsApp: %s " , err . Error () )
269
271
} else {
270
272
for _ , item := range resp {
271
273
if item .VerifiedName != nil {
@@ -346,6 +348,7 @@ func handleCmd(cmd string, args []string) {
346
348
}
347
349
case "mediaconn" :
348
350
conn , err := cli .DangerousInternals ().RefreshMediaConn (false )
351
+
349
352
if err != nil {
350
353
log .Errorf ("Failed to get media connection: %v" , err )
351
354
} else {
@@ -629,21 +632,26 @@ func handleCmd(cmd string, args []string) {
629
632
for _ , item := range resp {
630
633
if action == whatsmeow .ParticipantChangeAdd && item .Error == 403 && item .AddRequest != nil {
631
634
log .Infof ("Participant is private: %d %s %s %v" , item .Error , item .JID , item .AddRequest .Code , item .AddRequest .Expiration )
632
- cli .SendMessage (context .TODO (), item .JID , & waProto .Message {
633
- GroupInviteMessage : & waProto .GroupInviteMessage {
635
+ resp , err := cli .SendMessage (context .TODO (), item .JID , & waE2E .Message {
636
+ GroupInviteMessage : & waE2E .GroupInviteMessage {
634
637
InviteCode : proto .String (item .AddRequest .Code ),
635
638
InviteExpiration : proto .Int64 (item .AddRequest .Expiration .Unix ()),
636
639
GroupJID : proto .String (jid .String ()),
637
640
GroupName : proto .String ("Test group" ),
638
641
Caption : proto .String ("This is a test group" ),
639
642
},
640
643
})
644
+ if err != nil {
645
+ log .Errorf ("Error sending group invite: %v" , err )
646
+ } else {
647
+ log .Infof ("Group Invite sent (server timestamp: %s)" , resp .Timestamp )
648
+ }
641
649
} else if item .Error == 409 {
642
- log .Infof ("Participant already in group: %d %s %+v " , item .Error , item .JID )
650
+ log .Infof ("Participant already in group: %d %s" , item .Error , item .JID )
643
651
} else if item .Error == 0 {
644
- log .Infof ("Added participant: %d %s %+v " , item .Error , item .JID )
652
+ log .Infof ("Added participant: %d %s" , item .Error , item .JID )
645
653
} else {
646
- log .Infof ("Unknown status: %d %s %+v " , item .Error , item .JID )
654
+ log .Infof ("Unknown status: %d %s" , item .Error , item .JID )
647
655
}
648
656
}
649
657
case "getrequestparticipant" :
@@ -707,7 +715,7 @@ func handleCmd(cmd string, args []string) {
707
715
if ! ok {
708
716
return
709
717
}
710
- msg := & waProto .Message {Conversation : proto .String (strings .Join (args [1 :], " " ))}
718
+ msg := & waE2E .Message {Conversation : proto .String (strings .Join (args [1 :], " " ))}
711
719
resp , err := cli .SendMessage (context .Background (), recipient , msg )
712
720
if err != nil {
713
721
log .Errorf ("Error sending message: %v" , err )
@@ -760,9 +768,9 @@ func handleCmd(cmd string, args []string) {
760
768
if reaction == "remove" {
761
769
reaction = ""
762
770
}
763
- msg := & waProto .Message {
764
- ReactionMessage : & waProto .ReactionMessage {
765
- Key : & waProto .MessageKey {
771
+ msg := & waE2E .Message {
772
+ ReactionMessage : & waE2E .ReactionMessage {
773
+ Key : & waCommon .MessageKey {
766
774
RemoteJID : proto .String (recipient .String ()),
767
775
FromMe : proto .Bool (fromMe ),
768
776
ID : proto .String (messageID ),
@@ -817,7 +825,7 @@ func handleCmd(cmd string, args []string) {
817
825
log .Errorf ("Failed to upload file: %v" , err )
818
826
return
819
827
}
820
- msg := & waProto .Message {ImageMessage : & waProto .ImageMessage {
828
+ msg := & waE2E .Message {ImageMessage : & waE2E .ImageMessage {
821
829
Caption : proto .String (strings .Join (args [2 :], " " )),
822
830
URL : proto .String (uploaded .URL ),
823
831
DirectPath : proto .String (uploaded .DirectPath ),
0 commit comments