Class: TelegramBot::ChatAdministratorRights

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

Overview

Represents the rights of an administrator in a chat.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ChatAdministratorRights

Initializes the object



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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
# File 'lib/telegram-bot/models/chat_administrator_rights.rb', line 119

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `TelegramBot::ChatAdministratorRights` 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::ChatAdministratorRights`. 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?(:'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
end

Instance Attribute Details

#can_change_infoObject

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



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

def can_change_info
  @can_change_info
end

#can_delete_messagesObject

True, if the administrator can delete messages of other users



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

def can_delete_messages
  @can_delete_messages
end

#can_delete_storiesObject

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



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

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



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

def can_edit_messages
  @can_edit_messages
end

#can_edit_storiesObject

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



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

def can_edit_stories
  @can_edit_stories
end

#can_invite_usersObject

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



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

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.



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

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



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

def can_manage_topics
  @can_manage_topics
end

#can_manage_video_chatsObject

True, if the administrator can manage video chats



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

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



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

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



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

def can_post_messages
  @can_post_messages
end

#can_post_storiesObject

True, if the administrator can post stories to the chat



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

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)



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

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



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

def can_restrict_members
  @can_restrict_members
end

#is_anonymousObject

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



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

def is_anonymous
  @is_anonymous
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type



346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/telegram-bot/models/chat_administrator_rights.rb', line 346

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



86
87
88
# File 'lib/telegram-bot/models/chat_administrator_rights.rb', line 86

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/telegram-bot/models/chat_administrator_rights.rb', line 65

def self.attribute_map
  {
    :'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'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash



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

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



112
113
114
115
# File 'lib/telegram-bot/models/chat_administrator_rights.rb', line 112

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

.openapi_typesObject

Attribute type mapping.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/telegram-bot/models/chat_administrator_rights.rb', line 91

def self.openapi_types
  {
    :'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'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/telegram-bot/models/chat_administrator_rights.rb', line 287

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      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
end

#_to_hash(value) ⇒ Hash

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



417
418
419
420
421
422
423
424
425
426
427
428
429
# File 'lib/telegram-bot/models/chat_administrator_rights.rb', line 417

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

See Also:

  • `==` method


309
310
311
# File 'lib/telegram-bot/models/chat_administrator_rights.rb', line 309

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.



315
316
317
# File 'lib/telegram-bot/models/chat_administrator_rights.rb', line 315

def hash
  [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].hash
end

#list_invalid_propertiesObject

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



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
256
257
258
259
260
261
262
263
264
265
# File 'lib/telegram-bot/models/chat_administrator_rights.rb', line 217

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  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)



393
394
395
# File 'lib/telegram-bot/models/chat_administrator_rights.rb', line 393

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash



399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/telegram-bot/models/chat_administrator_rights.rb', line 399

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



387
388
389
# File 'lib/telegram-bot/models/chat_administrator_rights.rb', line 387

def to_s
  to_hash.to_s
end

#valid?Boolean

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



269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/telegram-bot/models/chat_administrator_rights.rb', line 269

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  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