Update message.py

Now, when doing
```py
for word in message:
    print(word)
```
it will print all the words of the message, which are separated by a space!
This commit is contained in:
Hunter2807 2021-08-29 16:39:00 +05:30 committed by GitHub
parent 9356e385d8
commit e04f3a1326
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -451,6 +451,10 @@ class Message(Hashable):
.. describe:: hash(x) .. describe:: hash(x)
Returns the message's hash. Returns the message's hash.
.. describe:: iter(x)
Returns an iterator of words of the message, separated by a space
Attributes Attributes
----------- -----------
@ -606,6 +610,9 @@ class Message(Hashable):
def __int__(self): def __int__(self):
return self.id return self.id
def __iter__(self):
yield from self.content.split()
def __repr__(self): def __repr__(self):
return '<Message id={0.id} channel={0.channel!r} type={0.type!r} author={0.author!r} flags={0.flags!r}>'.format(self) return '<Message id={0.id} channel={0.channel!r} type={0.type!r} author={0.author!r} flags={0.flags!r}>'.format(self)