Class: MTProto::TL::ChannelsEditAdmin
- Inherits:
-
Object
- Object
- MTProto::TL::ChannelsEditAdmin
- Includes:
- Binary
- Defined in:
- lib/mtproto/tl/objects/channels_edit_admin.rb
Overview
channels.editAdmin — grant, change, or (with no rights) revoke a participant’s admin rights in a channel or supergroup. Returns Updates.
Constant Summary collapse
- CONSTRUCTOR =
0x9a98ad68- CHAT_ADMIN_RIGHTS =
0x5fb224d5- INPUT_USER =
0xf21158c6- ADMIN_RIGHT_BITS =
Flag bit per chatAdminRights right (the schema leaves bits 6 and 8 unused).
{ change_info: 0, post_messages: 1, edit_messages: 2, delete_messages: 3, ban_users: 4, invite_users: 5, pin_messages: 7, add_admins: 9, anonymous: 10, manage_call: 11, other: 12, manage_topics: 13, post_stories: 14, edit_stories: 15, delete_stories: 16, manage_direct_messages: 17, manage_ranks: 18 }.freeze
Instance Method Summary collapse
-
#initialize(channel:, user:, rank: '', **rights) ⇒ ChannelsEditAdmin
constructor
channel and user are { id:, access_hash: }.
- #serialize ⇒ Object
Methods included from Binary
#b_u32, #b_u64, #u32_b, #u64_b
Constructor Details
#initialize(channel:, user:, rank: '', **rights) ⇒ ChannelsEditAdmin
channel and user are { id:, access_hash: }. Pass any ADMIN_RIGHT_BITS key as true to grant that right (e.g. post_messages: true); none/all-false revokes the participant’s admin status. rank is the optional custom admin title.
25 26 27 28 29 30 31 32 33 |
# File 'lib/mtproto/tl/objects/channels_edit_admin.rb', line 25 def initialize(channel:, user:, rank: '', **rights) unknown = rights.keys - ADMIN_RIGHT_BITS.keys raise ArgumentError, "unknown admin right(s): #{unknown.join(', ')}" unless unknown.empty? @channel = channel @user = user @rank = rank @rights = rights end |
Instance Method Details
#serialize ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/mtproto/tl/objects/channels_edit_admin.rb', line 35 def serialize result = u32_b(CONSTRUCTOR) result += u32_b(rank_flag) result += serialize_input_channel result += serialize_input_user result += serialize_admin_rights result += serialize_tl_string(@rank) unless @rank.to_s.empty? result end |