Class: ChatMember

Inherits:
Object
  • Object
show all
Defined in:
lib/objects/chat_member.rb

Overview

Monday, August 24 2020 EAT

This object contains information about one member of a chat.

Instance Method Summary collapse

Constructor Details

#initialize(mem) ⇒ ChatMember

:nodoc:



10
11
12
# File 'lib/objects/chat_member.rb', line 10

def initialize(mem) # :nodoc:
  @memb = mem
end

Instance Method Details

#admin?Boolean

Returns true if user is admin

Returns:

  • (Boolean)


139
140
141
# File 'lib/objects/chat_member.rb', line 139

def admin?
  (status.eql? 'creator') or (status.eql? 'administrator')
end

#can_add_web_page_previews?Boolean

Optional. Restricted only. True, if the user is allowed to add web page previews to their messages.

Returns:

  • (Boolean)


128
129
130
# File 'lib/objects/chat_member.rb', line 128

def can_add_web_page_previews?
  @memb.can_add_web_page_previews
end

#can_be_edited?Boolean

Optional. Administrators only. True, if the bot is allowed to edit administrator privileges of that user.

Returns:

  • (Boolean)


43
44
45
# File 'lib/objects/chat_member.rb', line 43

def can_be_edited?
  @memb.can_be_edited
end

#can_change_info?Boolean

Optional. Administrators and restricted only. True, if the user is allowed to change the chat title, photo and other settings.

Returns:

  • (Boolean)


81
82
83
# File 'lib/objects/chat_member.rb', line 81

def can_change_info?
  @memb.can_change_info
end

#can_delete_messages?Boolean

Optional. Administrators only. True, if the administrator can delete messages of other users.

Returns:

  • (Boolean)


61
62
63
# File 'lib/objects/chat_member.rb', line 61

def can_delete_messages?
  @memb.can_delete_messages
end

#can_edit_messages?Boolean

Optional. Administrators only. True, if the administrator can edit messages of other users and can pin messages; channels only.

Returns:

  • (Boolean)


55
56
57
# File 'lib/objects/chat_member.rb', line 55

def can_edit_messages?
  @memb.can_edit_messages
end

#can_invite_users?Boolean

Optional. Administrators and restricted only. True, if the user is allowed to invite new users to the chat.

Returns:

  • (Boolean)


87
88
89
# File 'lib/objects/chat_member.rb', line 87

def can_invite_users?
  @memb.can_invite_users
end

#can_pin_messages?Boolean

Optional. Administrators and restricted only. True, if the user is allowed to pin messages; groups and supergroups only.

Returns:

  • (Boolean)


93
94
95
# File 'lib/objects/chat_member.rb', line 93

def can_pin_messages?
  @memb.can_pin_messages
end

#can_post_messages?Boolean

Optional. Administrators only. True, if the administrator can post in the channel; channels only.

Returns:

  • (Boolean)


49
50
51
# File 'lib/objects/chat_member.rb', line 49

def can_post_messages?
  @memb.can_post_messages
end

#can_promote_members?Boolean

Optional. Administrators only. True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user)

Returns:

  • (Boolean)


75
76
77
# File 'lib/objects/chat_member.rb', line 75

def can_promote_members?
  @memb.can_promote_members
end

#can_restrict_members?Boolean

Optional. Administrators only. True, if the administrator can restrict, #ban_chat_member or #unban_chat_member s.

Returns:

  • (Boolean)


67
68
69
# File 'lib/objects/chat_member.rb', line 67

def can_restrict_members?
  @memb.can_restrict_members
end

#can_send_media_messages?Boolean

Optional. Restricted only. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes.

Returns:

  • (Boolean)


111
112
113
# File 'lib/objects/chat_member.rb', line 111

def can_send_media_messages?
  @memb.can_send_media_messages
end

#can_send_messages?Boolean

Optional. Restricted only. True, if the user is allowed to send text messages, contacts, locations and venues.

Returns:

  • (Boolean)


105
106
107
# File 'lib/objects/chat_member.rb', line 105

def can_send_messages?
  @memb.can_send_messages
end

#can_send_other_messages?Boolean

Optional. Restricted only. True, if the user is allowed to send animations, games, stickers and use inline bots.

Returns:

  • (Boolean)


122
123
124
# File 'lib/objects/chat_member.rb', line 122

def can_send_other_messages?
  @memb.can_send_other_messages
end

#can_send_polls?Boolean

Optional. Restricted only. True, if the user is allowed to send polls

Returns:

  • (Boolean)


116
117
118
# File 'lib/objects/chat_member.rb', line 116

def can_send_polls?
  @memb.can_send_polls
end

#custom_titleObject

Optional. Owner and administrators only. Custom title for this user. check if user is admin using #admin? before going to use this method, unless nil is returned.



29
30
31
# File 'lib/objects/chat_member.rb', line 29

def custom_title
  @memb.custom_title
end

#left?Boolean

Returns true if user if left the chat. NB: That does not mean it checks if user is a part of chat. Kicked != left

Returns:

  • (Boolean)


134
135
136
# File 'lib/objects/chat_member.rb', line 134

def left?
  status.eql? 'left'
end

#member?Boolean

Optional. Restricted only. True, if the user is a member of the chat at the moment of the reques.

Returns:

  • (Boolean)


99
100
101
# File 'lib/objects/chat_member.rb', line 99

def member?
  @memb.is_member
end

#statusObject

The member’s status in the chat. Can be creator, administrator, member, restricted, left or kicked.



22
23
24
# File 'lib/objects/chat_member.rb', line 22

def status
  @memb.status
end

#until_dateObject

Optional. Restricted and kicked only. Date when restrictions will be lifted for this user; unix time. Check if user is restricted or kicked using #member? before going to use this method else if user is not kicked or restricted then nil is returned.



37
38
39
# File 'lib/objects/chat_member.rb', line 37

def until_date
  @memb.until_date
end

#userObject

Information about the user. Return User object.



16
17
18
# File 'lib/objects/chat_member.rb', line 16

def user
  User.new(@memb.user)
end