|
16 | 16 | # You should have received a copy of the GNU Lesser General Public License
|
17 | 17 | # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
18 | 18 |
|
19 |
| -from pyrogram import raw |
| 19 | +from datetime import datetime |
| 20 | +from pyrogram import raw, utils |
20 | 21 | from ..object import Object
|
21 | 22 |
|
22 | 23 |
|
@@ -186,3 +187,35 @@ def _parse(denied_permissions: "raw.base.ChatBannedRights") -> "ChatPermissions"
|
186 | 187 | can_manage_topics=can_manage_topics,
|
187 | 188 | can_send_media_messages=can_send_media_messages
|
188 | 189 | )
|
| 190 | + |
| 191 | + def write( |
| 192 | + permissions: "ChatPermissions", |
| 193 | + use_independent_chat_permissions: bool, |
| 194 | + until_date: datetime = utils.zero_datetime() |
| 195 | + ) -> "raw.base.ChatBannedRights": |
| 196 | + return raw.types.ChatBannedRights( |
| 197 | + until_date=utils.datetime_to_timestamp(until_date), |
| 198 | + send_messages=not permissions.can_send_messages, |
| 199 | + send_media=not permissions.can_send_media_messages, |
| 200 | + send_stickers=not permissions.can_send_other_messages, |
| 201 | + send_gifs=not permissions.can_send_other_messages, |
| 202 | + send_games=not permissions.can_send_other_messages, |
| 203 | + send_inline=not permissions.can_send_other_messages, |
| 204 | + embed_links=not permissions.can_add_web_page_previews, |
| 205 | + send_polls=not permissions.can_send_polls, |
| 206 | + change_info=not permissions.can_change_info, |
| 207 | + invite_users=not permissions.can_invite_users, |
| 208 | + pin_messages=not permissions.can_pin_messages, |
| 209 | + manage_topics=( |
| 210 | + permissions.can_manage_topics and |
| 211 | + not permissions.can_manage_topics |
| 212 | + ) or not permissions.can_pin_messages, |
| 213 | + # view_messages=# TODO |
| 214 | + send_audios=not permissions.can_send_audios,# TODO |
| 215 | + send_docs=not permissions.can_send_documents,# TODO |
| 216 | + send_photos=not permissions.can_send_photos,# TODO |
| 217 | + send_videos=not permissions.can_send_videos,# TODO |
| 218 | + send_roundvideos=not permissions.can_send_video_notes,# TODO |
| 219 | + send_voices=not permissions.can_send_voice_notes,# TODO |
| 220 | + # send_plain=# TODO |
| 221 | + ) |
0 commit comments