10.1.6. Class cerebro.aclasses.NewAttachment¶
-
class
cerebro.aclasses.
NewAttachment
(event_id, message_id, attach_id)[source]¶ Bases:
cerebro.aclasses.AbstractAttachment
New attachment class.
Methods
add_hashtags()
remove_hashtags()
set_comment()
set_name()
methods of the cerebro.aclasses.AbstractAttachment
basic class.
The objects of the class are used in the
cerebro.events.BeforeEventMessage
event in thenew_attachments()
method.def before_event(event): evtype = event.event_type() if evtype == event.EVENT_CREATION_OF_MESSAGE or evtype == event.EVENT_CHANGING_OF_MESSAGE: new_attachs = event.new_attachments() for attach in new_attachs: print(attach.name())
Parameters: hashtags (string, set(string, ) or list(string, )) – hashtag or array of hashtags (every hashtag should be written in one word without spaces). Adds hashtags to the attachment.
See also
Parameters: hashtags (string, set(string, ) or list(string, )) – hashtag or array of hashtags (every hashtag should be written in one word without spaces). Remove hashtags from the attachment.
See also
-
set_comment
(comment)[source]¶ Parameters: comment (string) – a comment to the attachment. Changes a text comment to the new attachment.
new_attachs = event.new_attachments() for attach in new_attachs: if attach.is_link() == True: # if the new attachment is a link attach.set_comment(i.comment() + '. It's a link') # adding a comment