arizona-forum-api-async 1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ MAIN_URL = "https://forum.arizona-rp.com"
2
+
3
+ REACTIONS = {
4
+ 1: 'Мне нравится',
5
+ 2: 'Любовь',
6
+ 3: 'Ха-ха',
7
+ 4: 'Ух ты',
8
+ 5: 'Грустно',
9
+ 6: 'Гнев',
10
+ 7: 'Мне не нравится'
11
+ }
12
+
13
+ ROLE_COLOR = {
14
+ 'style71': 'green',
15
+ 'style73': '#6DB36D',
16
+ 'style72': '#efef12',
17
+ 'style74': 'blue',
18
+ 'style76': '#642CD0',
19
+ 'style84': '#ffc0cb',
20
+ 'style75': 'Skyblue',
21
+ 'style3': 'red',
22
+ 'style76': '#FF1493',
23
+ 'style80': '#ff5733'
24
+ }
@@ -0,0 +1,18 @@
1
+ class ArizonaException(Exception):
2
+ pass
3
+
4
+
5
+ class IncorrectLoginData(Exception):
6
+ def __init__(self, *args: object) -> None:
7
+ super().__init__(*args)
8
+
9
+ def __str__(self) -> str:
10
+ return "Вы ввели неверные cookie!"
11
+
12
+
13
+ class ThisIsYouError(ArizonaException):
14
+ def __init__(self, user_id):
15
+ self.user_id = user_id
16
+
17
+ def __str__(self) -> str:
18
+ return f"Вы не можете совершить данное действие самому себе\nID пользователя: {self.user_id}"
@@ -0,0 +1,4 @@
1
+ from .category_object import *
2
+ from .member_object import *
3
+ from .other import *
4
+ from .thread_object import *
@@ -0,0 +1,111 @@
1
+ import aiohttp
2
+ from typing import TYPE_CHECKING
3
+ from arizona_forum_async.consts import MAIN_URL
4
+
5
+ if TYPE_CHECKING:
6
+ from arizona_forum_async import ArizonaAPI
7
+
8
+
9
+ class Category:
10
+ def __init__(self, API: 'ArizonaAPI', id: int, title: str, pages_count: int) -> None:
11
+ self.API = API
12
+ self.id = id
13
+ """**ID категории**"""
14
+ self.title = title
15
+ """**Название категории**"""
16
+ self.pages_count = pages_count
17
+ """**Количество страниц в категории**"""
18
+ self.url = f"{MAIN_URL}/forums/{self.id}/"
19
+ """Ссылка на объект"""
20
+
21
+ async def create_thread(self, title: str, message_html: str, discussion_type: str = 'discussion', watch_thread: int = 1) -> aiohttp.ClientResponse:
22
+ """Создать тему в категории
23
+
24
+ Attributes:
25
+ title (str): Название темы
26
+ message_html (str): Содержание темы. Рекомендуется использование HTML
27
+ discussion_type (str): - Тип темы | Возможные варианты: 'discussion' - обсуждение (по умолчанию), 'article' - статья, 'poll' - опрос (необяз.)
28
+ watch_thread (str): - Отслеживать ли тему. По умолчанию True (необяз.)
29
+
30
+ Returns:
31
+ Объект Response модуля requests
32
+
33
+ Todo:
34
+ Cделать возврат ID новой темы
35
+ """
36
+
37
+ return await self.API.create_thread(self.id, title, message_html, discussion_type, watch_thread)
38
+
39
+
40
+ async def get_parent_category(self) -> 'Category':
41
+ """Получить родительский раздел
42
+
43
+ Attributes:
44
+ thread_id (int): ID темы
45
+
46
+ Returns:
47
+ Объект Catrgory, в котормо создана тема
48
+ """
49
+
50
+ return await self.API.get_parent_category_of_category(self.id)
51
+
52
+
53
+ async def set_read(self) -> aiohttp.ClientResponse:
54
+ """Отметить категорию как прочитанную
55
+
56
+ Returns:
57
+ Объект Response модуля requests
58
+ """
59
+
60
+ return await self.API.set_read_category(self.id)
61
+
62
+
63
+ async def watch(self, notify: str, send_alert: bool = True, send_email: bool = False, stop: bool = False) -> aiohttp.ClientResponse:
64
+ """Настроить отслеживание категории
65
+
66
+ Attributes:
67
+ notify (str): Объект отслеживания. Возможные варианты: "thread", "message", ""
68
+ send_alert (bool): - Отправлять ли уведомления на форуме. По умолчанию True (необяз.)
69
+ send_email (bool): - Отправлять ли уведомления на почту. По умолчанию False (необяз.)
70
+ stop (bool): - Принудительное завершение отслеживания. По умолчанию False (необяз.)
71
+
72
+ Returns:
73
+ Объект Response модуля requests
74
+ """
75
+
76
+ return await self.API.watch_category(self.id, notify, send_alert, send_email, stop)
77
+
78
+
79
+ async def get_threads(self, page: int = 1) -> dict:
80
+ """Получить темы из раздела
81
+
82
+ Attributes:
83
+ page (int): Cтраница для поиска. По умолчанию 1 (необяз.)
84
+
85
+ Returns:
86
+ Словарь (dict), состоящий из списков закрепленных ('pins') и незакрепленных ('unpins') тем
87
+ """
88
+
89
+ return await self.API.get_threads(self.id, page)
90
+
91
+ async def get_threads_extended(self, page: int = 1) -> dict:
92
+ """Получить темы из раздела с дополнительной информацией
93
+
94
+ Attributes:
95
+ page (int): Cтраница для поиска. По умолчанию 1 (необяз.)
96
+
97
+ Returns:
98
+ Словарь (dict), состоящий из списков закрепленных ('pins') и незакрепленных ('unpins') тем
99
+ """
100
+
101
+ return await self.API.get_threads_extended(self.id, page)
102
+
103
+
104
+ async def get_categories(self) -> list:
105
+ """Получить дочерние категории из раздела
106
+
107
+ Returns:
108
+ Список (list), состоящий из ID дочерних категорий раздела
109
+ """
110
+
111
+ return await self.API.get_categories(self.id)
@@ -0,0 +1,125 @@
1
+ from bs4 import BeautifulSoup
2
+ import aiohttp
3
+ from re import compile
4
+ from typing import TYPE_CHECKING
5
+
6
+ from arizona_forum_async.consts import MAIN_URL
7
+
8
+ if TYPE_CHECKING:
9
+ from arizona_forum_async.api import ArizonaAPI
10
+
11
+
12
+ class Member:
13
+ def __init__(self, API : 'ArizonaAPI', id: int, username: str, user_title: str, avatar: str, roles: list, messages_count: int, reactions_count: int, trophies_count: int, username_color: str) -> None:
14
+ self.API = API
15
+ self.id = id
16
+ """**ID пользователя**"""
17
+ self.username = username
18
+ """**Имя пользователя**"""
19
+ self.user_title = user_title
20
+ """**Звание пользователя**"""
21
+ self.avatar = avatar
22
+ """**Ссылка на аватарку пользователя**"""
23
+ self.roles = roles
24
+ """Роль пользователя на форуме ('покраска')"""
25
+
26
+ self.messages_count = messages_count
27
+ """**Количество сообщений в счетчике**"""
28
+ self.reactions_count = reactions_count
29
+ """**Количество реакций в счетчике**"""
30
+ self.trophies_count = trophies_count
31
+ """**Количество баллов в счетчике**"""
32
+
33
+ self.username_color = username_color
34
+
35
+ self.url = f"{MAIN_URL}/members/{self.id}/"
36
+ """Ссылка на объект"""
37
+
38
+
39
+ async def follow(self) -> aiohttp.ClientResponse:
40
+ """Изменить статус подписки на пользователя
41
+
42
+ Returns:
43
+ Объект Response модуля requests
44
+ """
45
+
46
+ return await self.API.follow_member(self.id)
47
+
48
+ async def ignore(self) -> aiohttp.ClientResponse:
49
+ """Изменить статус игнорирования пользователя
50
+
51
+ Returns:
52
+ Объект Response модуля requests
53
+ """
54
+
55
+ return await self.API.ignore_member(self.id)
56
+
57
+ async def add_message(self, message_html: str) -> aiohttp.ClientResponse:
58
+ """Отправить сообщение на стенку пользователя
59
+
60
+ Attributes:
61
+ message_html (str): Текст сообщения. Рекомендуется использование HTML
62
+
63
+ Returns:
64
+ Объект Response модуля requests
65
+ """
66
+
67
+ return await self.API.answer_thread(self.id, message_html)
68
+
69
+ async def get_profile_messages(self, page: int = 1) -> list:
70
+ """Возвращает ID всех сообщений со стенки пользователя на странице
71
+
72
+ Attributes:
73
+ page (int): Страница для поиска. По умолчанию 1 (необяз.)
74
+
75
+ Returns:
76
+ Cписок (list) с ID всех сообщений профиля
77
+ """
78
+
79
+ return await self.API.get_profile_messages(self.id, page)
80
+
81
+
82
+ class CurrentMember(Member):
83
+ follow = property(doc='Forbidden method for Current Member object')
84
+ ignore = property(doc='Forbidden method for Current Member object')
85
+
86
+ async def edit_avatar(self, upload_photo: str) -> aiohttp.ClientResponse:
87
+ """Изменить аватарку пользователя
88
+
89
+ Attributes:
90
+ upload_photo (str): Относительный или полный путь до изображения
91
+
92
+ Returns:
93
+ Объект Response модуля requests
94
+ """
95
+
96
+ with open(upload_photo, 'rb') as image:
97
+ file_dict = {'upload': (upload_photo, image.read())}
98
+
99
+ token = BeautifulSoup(self.API.session.get(f"{MAIN_URL}/help/terms/").content, 'lxml').find('html')['data-csrf']
100
+ data = {
101
+ "avatar_crop_x": 0,
102
+ "avatar_crop_y": 0,
103
+ "_xfToken": token,
104
+ "use_custom": 1,
105
+ }
106
+ return await self.API.session.post(f"{MAIN_URL}/account/avatar", files=file_dict, data=data)
107
+
108
+
109
+ async def delete_avatar(self) -> aiohttp.ClientResponse:
110
+ """Удалить автарку пользователя
111
+
112
+ Returns:
113
+ Объект Response модуля requests
114
+ """
115
+ token = BeautifulSoup(self.API.session.get(f"{MAIN_URL}/help/terms/").content, 'lxml').find('html')['data-csrf']
116
+ file_dict = {'upload': ("", "")}
117
+ data = {
118
+ "avatar_crop_x": 0,
119
+ "avatar_crop_y": 0,
120
+ "_xfToken": token,
121
+ "use_custom": 1,
122
+ "delete_avatar": 1
123
+ }
124
+
125
+ return await self.API.session.post(f"{MAIN_URL}/account/avatar", files=file_dict, data=data)
@@ -0,0 +1,14 @@
1
+ from typing import TYPE_CHECKING
2
+
3
+ if TYPE_CHECKING:
4
+ from arizona_forum_async import ArizonaAPI
5
+ from arizona_forum_async.models.member_object import Member
6
+
7
+
8
+ class Statistic:
9
+ def __init__(self, API: 'ArizonaAPI', threads_count: int, posts_count: int, users_count: int, last_register_member: 'Member') -> None:
10
+ self.API = API
11
+ self.threads_count = threads_count
12
+ self.posts_count = posts_count
13
+ self.users_count = users_count
14
+ self.last_register_member = last_register_member
@@ -0,0 +1,152 @@
1
+ import aiohttp
2
+ from typing import TYPE_CHECKING
3
+ from arizona_forum_async.consts import MAIN_URL
4
+
5
+ if TYPE_CHECKING:
6
+ from arizona_forum_async import ArizonaAPI
7
+ from arizona_forum_async.models import Member, Thread
8
+
9
+
10
+ class Post:
11
+ def __init__(self, API: 'ArizonaAPI', id: int, creator: 'Member', thread: 'Thread', create_date: int, html_content: str, text_content: str) -> None:
12
+ self.API = API
13
+ self.id = id
14
+ """**ID сообщения**"""
15
+ self.creator = creator
16
+ """**Объект Member отправителя сообщения**"""
17
+ self.thread = thread
18
+ """**Объект Thread темы, в которой оставлено сообщение**"""
19
+ self.create_date = create_date
20
+ """**Дата отправки сообщения в UNIX**"""
21
+ self.html_content = html_content
22
+ """**Сырое содержимое сообщения**"""
23
+ self.text_content = text_content
24
+ """**Текст из сообщения**"""
25
+ self.url = f"{MAIN_URL}/posts/{self.id}/"
26
+ """Ссылка на объект"""
27
+
28
+ async def bbcode_content(self) -> aiohttp.ClientResponse:
29
+ """Получить bbcode поста
30
+
31
+ Returns:
32
+ Str текст bbcode
33
+ """
34
+
35
+ return await self.API.get_post_bbcode(self.thread.id, self.id)
36
+
37
+ async def react(self, reaction_id: int = 1) -> aiohttp.ClientResponse:
38
+ """Поставить реакцию на сообщение
39
+
40
+ Attributes:
41
+ reaction_id (int): ID реакции. По умолчанию 1 (необяз.)
42
+
43
+ Returns:
44
+ Объект Response модуля requests
45
+ """
46
+
47
+ return await self.API.react_post(self.id, reaction_id)
48
+
49
+
50
+ async def edit(self, message_html: str) -> aiohttp.ClientResponse:
51
+ """Отредактировать сообщение
52
+
53
+ Attributes:
54
+ message_html (str): Новое содержание сообщения. Рекомендуется использование HTML
55
+
56
+ Returns:
57
+ Объект Response модуля requests
58
+ """
59
+
60
+ return await self.API.edit_post(self.id, message_html)
61
+
62
+
63
+ async def delete(self, reason: str, hard_delete: bool = False) -> aiohttp.ClientResponse:
64
+ """Удалить сообщение
65
+
66
+ Attributes:
67
+ reason (str): Причина для удаления
68
+ hard_delete (bool): Полное удаление сообщения. По умолчанию False (необяз.)
69
+
70
+ Returns:
71
+ Объект Response модуля requests
72
+ """
73
+
74
+ return await self.API.delete_post(self.id, reason, hard_delete)
75
+
76
+
77
+ async def bookmark(self) -> aiohttp.ClientResponse:
78
+ """Добавить сообщение в закладки
79
+
80
+ Returns:
81
+ Объект Response модуля requests"""
82
+ return await self.API.bookmark_post(self.id)
83
+
84
+ class ProfilePost:
85
+ def __init__(self, API: 'ArizonaAPI', id: int, creator: 'Member', profile: 'Member', create_date: int, html_content: str, text_content: str) -> None:
86
+ self.API = API
87
+ self.id = id
88
+ """**ID сообщения профиля**"""
89
+ self.creator = creator
90
+ """**Объект Member отправителя сообщения**"""
91
+ self.profile = profile
92
+ """**Объект Member профиля, в котором оставлено сообщение**"""
93
+ self.create_date = create_date
94
+ """**Дата отправки сообщения в UNIX**"""
95
+ self.html_content = html_content
96
+ """**Сырое содержимое сообщения**"""
97
+ self.text_content = text_content
98
+ """**Текст из сообщения**"""
99
+ self.url = f"{MAIN_URL}/profile-posts/{self.id}/"
100
+ """Ссылка на объект"""
101
+
102
+ async def react(self, reaction_id: int = 1) -> aiohttp.ClientResponse:
103
+ """Поставить реакцию на сообщение профиля
104
+
105
+ Attributes:
106
+ reaction_id (int): ID реакции. По умолчанию 1 (необяз.)
107
+
108
+ Returns:
109
+ Объект Response модуля requests
110
+ """
111
+
112
+ return await self.API.react_profile_post(self.id, reaction_id)
113
+
114
+
115
+ async def comment(self, message_html: str) -> aiohttp.ClientResponse:
116
+ """Прокомментировать сообщение профиля
117
+
118
+ Attributes:
119
+ message_html (str): Текст комментария. Рекомендуется использование HTML
120
+
121
+ Returns:
122
+ Объект Response модуля requests
123
+ """
124
+
125
+ return await self.API.comment_profile_post(self.id, message_html)
126
+
127
+
128
+ async def delete(self, reason: str, hard_delete: bool = False) -> aiohttp.ClientResponse:
129
+ """Удалить сообщение
130
+
131
+ Attributes:
132
+ reason (str): Причина для удаления
133
+ hard_delete (bool): Полное удаление сообщения. По умолчанию False (необяз.)
134
+
135
+ Returns:
136
+ Объект Response модуля requests
137
+ """
138
+
139
+ return await self.API.delete_profile_post(self.id, reason, hard_delete)
140
+
141
+
142
+ async def edit(self, message_html: str) -> aiohttp.ClientResponse:
143
+ """Отредактировать сообщение профиля
144
+
145
+ Attributes:
146
+ message_html (str): Новое содержание сообщения профиля. Рекомендуется использование HTML
147
+
148
+ Returns:
149
+ Объект Response модуля requests
150
+ """
151
+
152
+ return await self.API.edit_profile_post(self.id, message_html)
@@ -0,0 +1,140 @@
1
+ import aiohttp
2
+ from typing import TYPE_CHECKING
3
+ from arizona_forum_async.consts import MAIN_URL
4
+
5
+ if TYPE_CHECKING:
6
+ from arizona_forum_async.models.member_object import Member
7
+ from arizona_forum_async.models.category_object import Category
8
+ from arizona_forum_async import ArizonaAPI
9
+
10
+
11
+ class Thread:
12
+ def __init__(self, API: 'ArizonaAPI', id: int, creator: 'Member', create_date: int, title: str, prefix: str, text_content: str, html_content: str, pages_content: int, thread_post_id: int, is_closed: bool) -> None:
13
+ self.API = API
14
+ self.id = id
15
+ """**ID темы**"""
16
+ self.creator = creator
17
+ """**Объект Member создателя темы**"""
18
+ self.create_date = create_date
19
+ """**Дата создания темы в UNIX**"""
20
+ self.title = title
21
+ """**Заголовок темы**"""
22
+ self.prefix = prefix
23
+ """**Префикс темы**"""
24
+ self.text_content = text_content
25
+ """**Текст из темы**"""
26
+ self.html_content = html_content
27
+ """**Сырой контент темы**"""
28
+ self.pages_count = pages_content
29
+ """**Количество страниц с ответами в теме**"""
30
+ self.is_closed = is_closed
31
+ """**Закрыта ли тема**"""
32
+ self.thread_post_id = thread_post_id
33
+ """**ID сообщения темы (post_id)**"""
34
+ self.url = f"{MAIN_URL}/threads/{self.id}/"
35
+ """Ссылка на объект"""
36
+
37
+
38
+ async def answer(self, message_html: str) -> aiohttp.ClientResponse:
39
+ """Оставить сообщение в теме
40
+
41
+ Attributes:
42
+ message_html (str): Cодержание ответа. Рекомендуется использование HTML
43
+
44
+ Returns:
45
+ Объект Response модуля requests
46
+ """
47
+
48
+ return await self.API.answer_thread(self.id, message_html)
49
+
50
+
51
+ async def watch(self, email_subscribe: bool = False, stop: bool = False) -> aiohttp.ClientResponse:
52
+ """Изменить статус отслеживания темы
53
+
54
+ Attributes:
55
+ email_subscribe (bool): Отправлять ли уведомления на почту. По умолчанию False (необяз.)
56
+ stop (bool): - Принудительно прекратить отслеживание. По умолчанию False (необяз.)
57
+
58
+ Returns:
59
+ Объект Response модуля requests
60
+ """
61
+
62
+ return await self.API.watch_thread(self.id, email_subscribe, stop)
63
+
64
+
65
+ async def delete(self, reason: str, hard_delete: bool = False) -> aiohttp.ClientResponse:
66
+ """Удалить тему
67
+
68
+ Attributes:
69
+ reason (str): Причина для удаления
70
+ hard_delete (bool): Полное удаление сообщения. По умолчанию False (необяз.)
71
+
72
+ Returns:
73
+ Объект Response модуля requests
74
+ """
75
+
76
+ return await self.API.delete_thread(self.id, reason, hard_delete)
77
+
78
+
79
+ async def edit(self, message_html: str) -> aiohttp.ClientResponse:
80
+ """Отредактировать содержимое темы
81
+
82
+ Attributes:
83
+ message_html (str): Новое содержимое ответа. Рекомендуется использование HTML
84
+
85
+ Returns:
86
+ Объект Response модуля requests
87
+ """
88
+
89
+ return await self.API.edit_thread(self.id, message_html)
90
+
91
+ async def edit_info(self, title: str = None, prefix_id: int = None, sticky: bool = True, opened: bool = True) -> aiohttp.ClientResponse:
92
+ """Изменить заголовок и/или префикс темы
93
+
94
+ Attributes:
95
+ title (str): Новое название
96
+ prefix_id (int): Новый ID префикса
97
+ sticky (bool): Закрепить (True - закреп / False - не закреп)
98
+ opened (bool): Открыть/закрыть тему (True - открыть / False - закрыть)
99
+
100
+ Returns:
101
+ Объект Response модуля requests
102
+ """
103
+
104
+ return await self.API.edit_thread_info(self.id, title, prefix_id, sticky, opened)
105
+
106
+
107
+ async def get_posts(self, page: int = 1) -> list:
108
+ """Получить все ID сообщений из темы на странице
109
+
110
+ Attributes:
111
+ page (int): Cтраница для поиска. По умолчанию 1 (необяз.)
112
+
113
+ Returns:
114
+ Список (list), состоящий из ID всех сообщений на странице
115
+ """
116
+
117
+ return await self.API.get_thread_posts(self.id, page)
118
+
119
+
120
+ async def react(self, reaction_id: int = 1) -> aiohttp.ClientResponse:
121
+ """Поставить реакцию на тему
122
+
123
+ Attributes:
124
+ reaction_id (int): ID реакции. По умолчанию 1 (необяз.)
125
+
126
+ Returns:
127
+ Объект Response модуля requests
128
+ """
129
+
130
+ return await self.API.react_thread(self.id, reaction_id)
131
+
132
+
133
+ async def get_category(self) -> 'Category':
134
+ """Получить родительский раздел раздела
135
+
136
+ Returns:
137
+ Объект Catrgory, в котором создан раздел
138
+ """
139
+
140
+ return await self.API.get_thread_category(self.id)