Class: MTProto::TL::ChannelsEditBanned

Inherits:
Object
  • Object
show all
Includes:
Binary
Defined in:
lib/mtproto/tl/objects/channels_edit_banned.rb

Overview

channels.editBanned — restrict, ban, or (with no rights) lift restrictions on a participant in a supergroup. Returns Updates.

Constant Summary collapse

CONSTRUCTOR =
0x96e6cd81
CHAT_BANNED_RIGHTS =
0x9f120418
BANNED_RIGHT_BITS =

Flag bit per chatBannedRights right (the schema leaves bits 9, 11-14 and 16 unused). view_messages is a full ban (can't even read); the rest restrict specific actions.

{
  view_messages: 0, send_messages: 1, send_media: 2, send_stickers: 3,
  send_gifs: 4, send_games: 5, send_inline: 6, embed_links: 7, send_polls: 8,
  change_info: 10, invite_users: 15, pin_messages: 17, manage_topics: 18,
  send_photos: 19, send_videos: 20, send_roundvideos: 21, send_audios: 22,
  send_voices: 23, send_docs: 24, send_plain: 25, edit_rank: 26, send_reactions: 27
}.freeze

Instance Method Summary collapse

Methods included from Binary

#b_u32, #b_u64, #u32_b, #u64_b

Constructor Details

#initialize(channel:, participant:, until_date: 0, **rights) ⇒ ChannelsEditBanned

channel is { id:, access_hash: }; participant is { type:, id:, access_hash: }. Pass any BANNED_RIGHT_BITS key as true to apply that restriction (e.g. view_messages: true bans, send_messages: true mutes); none/all-false with until_date 0 lifts. until_date is the unix expiry (0 = until lifted).

Raises:

  • (ArgumentError)


28
29
30
31
32
33
34
35
36
# File 'lib/mtproto/tl/objects/channels_edit_banned.rb', line 28

def initialize(channel:, participant:, until_date: 0, **rights)
  unknown = rights.keys - BANNED_RIGHT_BITS.keys
  raise ArgumentError, "unknown banned right(s): #{unknown.join(', ')}" unless unknown.empty?

  @channel = channel
  @participant = participant
  @until_date = until_date
  @rights = rights
end

Instance Method Details

#serializeObject



38
39
40
41
42
43
44
# File 'lib/mtproto/tl/objects/channels_edit_banned.rb', line 38

def serialize
  result = u32_b(CONSTRUCTOR)
  result += serialize_input_channel
  result += serialize_input_peer(@participant)
  result += serialize_banned_rights
  result
end