Closed jeremia49 closed 3 years ago
Let me know what you think 😄
i really suggest something like that:
func (wac *Conn) BlockContact(jid string) (<-chan string, error) {
return wac.handleBlockContact("add", jid)
}
func (wac *Conn) UnblockContact(jid string) (<-chan string, error) {
return wac.handleBlockContact("remove", jid)
}
func (wac *Conn) handleBlockContact(action, jid string) (<-chan string, error) {
ts := time.Now().Unix()
tag := fmt.Sprintf("%d.--%d", ts, wac.msgCount)
netsplit := strings.Split(jid, "@")
cusjid := netsplit[0] + "@c.us"
n := binary.Node{
Description: "action",
Attributes: map[string]string{
"type": "set",
"epoch": strconv.Itoa(wac.msgCount),
},
Content: []interface{}{
binary.Node{
Description: "block",
Attributes: map[string]string{
"type": action,
},
Content: []binary.Node{
{
Description: "user",
Attributes: map[string]string{
"jid": cusjid,
},
Content: nil,
},
},
},
},
}
return wac.writeBinary(n, contact, ignore, tag)
}
Hi there, thanks for your suggestion , I will refactor my code.
Pada tanggal Jum, 18 Des 2020 pukul 00.53 Rafael Henrique < notifications@github.com> menulis:
i really suggest something like that:
func (wac *Conn) BlockContact(jid string) (<-chan string, error) { return wac.handleBlockContact("add", jid) }
func (wac *Conn) UnblockContact(jid string) (<-chan string, error) { return wac.handleBlockContact("remove", jid) }
func (wac *Conn) handleBlockContact(action, jid string) (<-chan string, error) { ts := time.Now().Unix() tag := fmt.Sprintf("%d.--%d", ts, wac.msgCount)
netsplit := strings.Split(jid, "@") cusjid := netsplit[0] + "@c.us"
n := binary.Node{ Description: "action", Attributes: map[string]string{ "type": "set", "epoch": strconv.Itoa(wac.msgCount), }, Content: []interface{}{ binary.Node{ Description: "block", Attributes: map[string]string{ "type": action, }, Content: []binary.Node{ { Description: "user", Attributes: map[string]string{ "jid": cusjid, }, Content: nil, }, }, }, }, }
return wac.writeBinary(n, contact, ignore, tag) }
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Rhymen/go-whatsapp/pull/497#issuecomment-747598099, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJQBE7KDQBEGW2IHY54OH23SVJAQNANCNFSM4UZFI2YA .
Done 😃
I like this PL, but we need to get more approval from the community, I don't have time to test it, but it seems fine for me. Let's wait and see who thumps up will be.
Happy Christmases
Ok, thanks 😊
Merry Christmas
On Sun, Dec 27, 2020, 12:12 AM beshoo notifications@github.com wrote:
I like this PL, but we need to get more approval from the community, I don't have time to test it, but it seems fine for me. Let's wait and see who thumps up will be.
Happy Christmases
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Rhymen/go-whatsapp/pull/497#issuecomment-751370426, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJQBE7KOF4HK4Q3K57VT23LSWYDQBANCNFSM4UZFI2YA .
I think this is great!
I still have no time to test this PL. @DonovanDiamond @Diden05 did you test it?
I have tested it several times and it's working fine
(sorry for my bad English)
as the title said