Class: TelegramBot::ChatMemberAdministrator

Inherits:
Object
  • Object
show all
Defined in:
lib/telegram-bot/models/chat_member_administrator.rb

Overview

Represents a chat member that has some additional privileges.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ChatMemberAdministrator

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 139

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `TelegramBot::ChatMemberAdministrator` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `TelegramBot::ChatMemberAdministrator`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'status')
    self.status = attributes[:'status']
  else
    self.status = nil
  end

  if attributes.key?(:'user')
    self.user = attributes[:'user']
  else
    self.user = nil
  end

  if attributes.key?(:'can_be_edited')
    self.can_be_edited = attributes[:'can_be_edited']
  else
    self.can_be_edited = nil
  end

  if attributes.key?(:'is_anonymous')
    self.is_anonymous = attributes[:'is_anonymous']
  else
    self.is_anonymous = nil
  end

  if attributes.key?(:'can_manage_chat')
    self.can_manage_chat = attributes[:'can_manage_chat']
  else
    self.can_manage_chat = nil
  end

  if attributes.key?(:'can_delete_messages')
    self.can_delete_messages = attributes[:'can_delete_messages']
  else
    self.can_delete_messages = nil
  end

  if attributes.key?(:'can_manage_video_chats')
    self.can_manage_video_chats = attributes[:'can_manage_video_chats']
  else
    self.can_manage_video_chats = nil
  end

  if attributes.key?(:'can_restrict_members')
    self.can_restrict_members = attributes[:'can_restrict_members']
  else
    self.can_restrict_members = nil
  end

  if attributes.key?(:'can_promote_members')
    self.can_promote_members = attributes[:'can_promote_members']
  else
    self.can_promote_members = nil
  end

  if attributes.key?(:'can_change_info')
    self.can_change_info = attributes[:'can_change_info']
  else
    self.can_change_info = nil
  end

  if attributes.key?(:'can_invite_users')
    self.can_invite_users = attributes[:'can_invite_users']
  else
    self.can_invite_users = nil
  end

  if attributes.key?(:'can_post_stories')
    self.can_post_stories = attributes[:'can_post_stories']
  else
    self.can_post_stories = nil
  end

  if attributes.key?(:'can_edit_stories')
    self.can_edit_stories = attributes[:'can_edit_stories']
  else
    self.can_edit_stories = nil
  end

  if attributes.key?(:'can_delete_stories')
    self.can_delete_stories = attributes[:'can_delete_stories']
  else
    self.can_delete_stories = nil
  end

  if attributes.key?(:'can_post_messages')
    self.can_post_messages = attributes[:'can_post_messages']
  end

  if attributes.key?(:'can_edit_messages')
    self.can_edit_messages = attributes[:'can_edit_messages']
  end

  if attributes.key?(:'can_pin_messages')
    self.can_pin_messages = attributes[:'can_pin_messages']
  end

  if attributes.key?(:'can_manage_topics')
    self.can_manage_topics = attributes[:'can_manage_topics']
  end

  if attributes.key?(:'custom_title')
    self.custom_title = attributes[:'custom_title']
  end
end

Instance Attribute Details

#can_be_editedObject

True, if the bot is allowed to edit administrator privileges of that user



26
27
28
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 26

def can_be_edited
  @can_be_edited
end

#can_change_infoObject

True, if the user is allowed to change the chat title, photo and other settings



47
48
49
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 47

def can_change_info
  @can_change_info
end

#can_delete_messagesObject

True, if the administrator can delete messages of other users



35
36
37
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 35

def can_delete_messages
  @can_delete_messages
end

#can_delete_storiesObject

True, if the administrator can delete stories posted by other users



59
60
61
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 59

def can_delete_stories
  @can_delete_stories
end

#can_edit_messagesObject

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



65
66
67
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 65

def can_edit_messages
  @can_edit_messages
end

#can_edit_storiesObject

True, if the administrator can edit stories posted by other users



56
57
58
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 56

def can_edit_stories
  @can_edit_stories
end

#can_invite_usersObject

True, if the user is allowed to invite new users to the chat



50
51
52
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 50

def can_invite_users
  @can_invite_users
end

#can_manage_chatObject

True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages and ignore slow mode. Implied by any other administrator privilege.



32
33
34
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 32

def can_manage_chat
  @can_manage_chat
end

#can_manage_topicsObject

Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only



71
72
73
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 71

def can_manage_topics
  @can_manage_topics
end

#can_manage_video_chatsObject

True, if the administrator can manage video chats



38
39
40
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 38

def can_manage_video_chats
  @can_manage_video_chats
end

#can_pin_messagesObject

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



68
69
70
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 68

def can_pin_messages
  @can_pin_messages
end

#can_post_messagesObject

Optional. True, if the administrator can post messages in the channel, or access channel statistics; for channels only



62
63
64
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 62

def can_post_messages
  @can_post_messages
end

#can_post_storiesObject

True, if the administrator can post stories to the chat



53
54
55
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 53

def can_post_stories
  @can_post_stories
end

#can_promote_membersObject

True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by the user)



44
45
46
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 44

def can_promote_members
  @can_promote_members
end

#can_restrict_membersObject

True, if the administrator can restrict, ban or unban chat members, or access supergroup statistics



41
42
43
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 41

def can_restrict_members
  @can_restrict_members
end

#custom_titleObject

Optional. Custom title for this user



74
75
76
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 74

def custom_title
  @custom_title
end

#is_anonymousObject

True, if the user’s presence in the chat is hidden



29
30
31
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 29

def is_anonymous
  @is_anonymous
end

#statusObject

The member’s status in the chat, always "administrator"



20
21
22
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 20

def status
  @status
end

#userObject

Information about the user



23
24
25
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 23

def user
  @user
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 407

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = TelegramBot.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



102
103
104
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 102

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 77

def self.attribute_map
  {
    :'status' => :'status',
    :'user' => :'user',
    :'can_be_edited' => :'can_be_edited',
    :'is_anonymous' => :'is_anonymous',
    :'can_manage_chat' => :'can_manage_chat',
    :'can_delete_messages' => :'can_delete_messages',
    :'can_manage_video_chats' => :'can_manage_video_chats',
    :'can_restrict_members' => :'can_restrict_members',
    :'can_promote_members' => :'can_promote_members',
    :'can_change_info' => :'can_change_info',
    :'can_invite_users' => :'can_invite_users',
    :'can_post_stories' => :'can_post_stories',
    :'can_edit_stories' => :'can_edit_stories',
    :'can_delete_stories' => :'can_delete_stories',
    :'can_post_messages' => :'can_post_messages',
    :'can_edit_messages' => :'can_edit_messages',
    :'can_pin_messages' => :'can_pin_messages',
    :'can_manage_topics' => :'can_manage_topics',
    :'custom_title' => :'custom_title'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 383

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



132
133
134
135
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 132

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 107

def self.openapi_types
  {
    :'status' => :'String',
    :'user' => :'User',
    :'can_be_edited' => :'Boolean',
    :'is_anonymous' => :'Boolean',
    :'can_manage_chat' => :'Boolean',
    :'can_delete_messages' => :'Boolean',
    :'can_manage_video_chats' => :'Boolean',
    :'can_restrict_members' => :'Boolean',
    :'can_promote_members' => :'Boolean',
    :'can_change_info' => :'Boolean',
    :'can_invite_users' => :'Boolean',
    :'can_post_stories' => :'Boolean',
    :'can_edit_stories' => :'Boolean',
    :'can_delete_stories' => :'Boolean',
    :'can_post_messages' => :'Boolean',
    :'can_edit_messages' => :'Boolean',
    :'can_pin_messages' => :'Boolean',
    :'can_manage_topics' => :'Boolean',
    :'custom_title' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 344

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      status == o.status &&
      user == o.user &&
      can_be_edited == o.can_be_edited &&
      is_anonymous == o.is_anonymous &&
      can_manage_chat == o.can_manage_chat &&
      can_delete_messages == o.can_delete_messages &&
      can_manage_video_chats == o.can_manage_video_chats &&
      can_restrict_members == o.can_restrict_members &&
      can_promote_members == o.can_promote_members &&
      can_change_info == o.can_change_info &&
      can_invite_users == o.can_invite_users &&
      can_post_stories == o.can_post_stories &&
      can_edit_stories == o.can_edit_stories &&
      can_delete_stories == o.can_delete_stories &&
      can_post_messages == o.can_post_messages &&
      can_edit_messages == o.can_edit_messages &&
      can_pin_messages == o.can_pin_messages &&
      can_manage_topics == o.can_manage_topics &&
      custom_title == o.custom_title
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



478
479
480
481
482
483
484
485
486
487
488
489
490
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 478

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


370
371
372
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 370

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



376
377
378
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 376

def hash
  [status, user, can_be_edited, is_anonymous, can_manage_chat, can_delete_messages, can_manage_video_chats, can_restrict_members, can_promote_members, can_change_info, can_invite_users, can_post_stories, can_edit_stories, can_delete_stories, can_post_messages, can_edit_messages, can_pin_messages, can_manage_topics, custom_title].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 259

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @status.nil?
    invalid_properties.push('invalid value for "status", status cannot be nil.')
  end

  if @user.nil?
    invalid_properties.push('invalid value for "user", user cannot be nil.')
  end

  if @can_be_edited.nil?
    invalid_properties.push('invalid value for "can_be_edited", can_be_edited cannot be nil.')
  end

  if @is_anonymous.nil?
    invalid_properties.push('invalid value for "is_anonymous", is_anonymous cannot be nil.')
  end

  if @can_manage_chat.nil?
    invalid_properties.push('invalid value for "can_manage_chat", can_manage_chat cannot be nil.')
  end

  if @can_delete_messages.nil?
    invalid_properties.push('invalid value for "can_delete_messages", can_delete_messages cannot be nil.')
  end

  if @can_manage_video_chats.nil?
    invalid_properties.push('invalid value for "can_manage_video_chats", can_manage_video_chats cannot be nil.')
  end

  if @can_restrict_members.nil?
    invalid_properties.push('invalid value for "can_restrict_members", can_restrict_members cannot be nil.')
  end

  if @can_promote_members.nil?
    invalid_properties.push('invalid value for "can_promote_members", can_promote_members cannot be nil.')
  end

  if @can_change_info.nil?
    invalid_properties.push('invalid value for "can_change_info", can_change_info cannot be nil.')
  end

  if @can_invite_users.nil?
    invalid_properties.push('invalid value for "can_invite_users", can_invite_users cannot be nil.')
  end

  if @can_post_stories.nil?
    invalid_properties.push('invalid value for "can_post_stories", can_post_stories cannot be nil.')
  end

  if @can_edit_stories.nil?
    invalid_properties.push('invalid value for "can_edit_stories", can_edit_stories cannot be nil.')
  end

  if @can_delete_stories.nil?
    invalid_properties.push('invalid value for "can_delete_stories", can_delete_stories cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



454
455
456
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 454

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



460
461
462
463
464
465
466
467
468
469
470
471
472
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 460

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



448
449
450
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 448

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# File 'lib/telegram-bot/models/chat_member_administrator.rb', line 323

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @status.nil?
  return false if @user.nil?
  return false if @can_be_edited.nil?
  return false if @is_anonymous.nil?
  return false if @can_manage_chat.nil?
  return false if @can_delete_messages.nil?
  return false if @can_manage_video_chats.nil?
  return false if @can_restrict_members.nil?
  return false if @can_promote_members.nil?
  return false if @can_change_info.nil?
  return false if @can_invite_users.nil?
  return false if @can_post_stories.nil?
  return false if @can_edit_stories.nil?
  return false if @can_delete_stories.nil?
  true
end