more basic gm api

This commit is contained in:
Karmanyaah Malhotra 2021-04-20 22:52:03 -04:00
parent 9f006b26e2
commit 8346b308c8

50
user.go
View File

@ -254,7 +254,7 @@ func (user *User) Connect() bool {
// user.Conn = whatsappExt.ExtendConn(conn) // user.Conn = whatsappExt.ExtendConn(conn)
// _ = user.Conn.SetClientName(user.bridge.Config.WhatsApp.OSName, user.bridge.Config.WhatsApp.BrowserName, WAVersion) // _ = user.Conn.SetClientName(user.bridge.Config.WhatsApp.OSName, user.bridge.Config.WhatsApp.BrowserName, WAVersion)
// user.log.Debugln("WhatsApp connection successful") // user.log.Debugln("WhatsApp connection successful")
user.Conn.AddHandler(user) user.Conn.AddFullHandler(user)
//TODO: typing notification? //TODO: typing notification?
return user.RestoreSession() return user.RestoreSession()
@ -889,6 +889,54 @@ func (user *User) HandleJoin(id groupme.ID) {
//TODO: efficient //TODO: efficient
} }
func (user *User) HandleGroupName(group groupme.ID, newName string) {
//p := user.GetPortalByJID(group.String())
//if p != nil {
// p.UpdateName(newName, "", false)
// get more info abt actual user TODO
//}
//bugs atm with above?
user.HandleChatList()
}
func (user *User) HandleGroupTopic(_ groupme.ID, _ string) {
user.HandleChatList()
}
func (user *User) HandleGroupMembership(_ groupme.ID, _ string) {
user.HandleChatList()
//TODO
}
func (user *User) HandleGroupAvatar(_ groupme.ID, _ string) {
user.HandleChatList()
}
func (user *User) HandleLikeIcon(_ groupme.ID, _, _ int, _ string) {
//TODO
}
func (user *User) HandleNewNickname(groupID, userID groupme.ID, name string) {
puppet := user.bridge.GetPuppetByJID(userID.String())
if puppet != nil {
puppet.UpdateName(user, user.GetPortalByJID(groupID.String()).MXID, groupme.Member{
Nickname: name,
UserID: userID,
})
}
}
func (user *User) HandleNewAvatarInGroup(groupID, userID groupme.ID, url string) {
puppet := user.bridge.GetPuppetByJID(userID.String())
if puppet != nil {
puppet.UpdateAvatar(user, user.GetPortalByJID(groupID.String()).MXID, url)
}
}
func (user *User) HandleMembers(_ groupme.ID, _ []groupme.Member, _ bool) {
user.HandleChatList()
}
//func (user *User) HandleImageMessage(message whatsapp.ImageMessage) { //func (user *User) HandleImageMessage(message whatsapp.ImageMessage) {
// user.messageInput <- PortalMessage{message.Info.RemoteJid, user, message, message.Info.Timestamp} // user.messageInput <- PortalMessage{message.Info.RemoteJid, user, message, message.Info.Timestamp}
//} //}