aboutsummaryrefslogtreecommitdiff
path: root/telegram/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'telegram/utils.go')
-rw-r--r--telegram/utils.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/telegram/utils.go b/telegram/utils.go
index addeee8..a730113 100644
--- a/telegram/utils.go
+++ b/telegram/utils.go
@@ -478,6 +478,39 @@ func (c *Client) updateMUCsNickname(memberID int64, newNickname string) {
}
}
+// MUCHasResource checks if a MUC was joined from a given resource
+func (c *Client) MUCHasResource(chatID int64, resource string) bool {
+ c.locks.mucCacheLock.Lock()
+ defer c.locks.mucCacheLock.Unlock()
+
+ mucState, ok := c.mucCache[chatID]
+ if !ok || mucState == nil {
+ return false
+ }
+ _, ok = mucState.Resources[resource]
+ return ok
+}
+
+// GetMyMUCNickname obtains this account's nickname in a given MUC
+func (c *Client) GetMyMUCNickname(chatID int64) (string, bool) {
+ if c.me == nil {
+ return "", false
+ }
+
+ c.locks.mucCacheLock.Lock()
+ defer c.locks.mucCacheLock.Unlock()
+
+ mucState, ok := c.mucCache[chatID]
+ if !ok || mucState == nil {
+ return "", false
+ }
+ member, ok := mucState.Members[c.me.Id]
+ if !ok {
+ return "", false
+ }
+ return member.Nickname, true
+}
+
func (c *Client) formatContact(chatID int64) string {
if chatID == 0 {
return ""