Community
Implements the Community class.
Community(lemmy, community)
A class for Communities.
To obtain an instance of this class for c/test run:
community = lemmy.get_community("test")
Initialize a Community instance.
Parameters:
-
lemmy(Lemmy) –A Lemmy instance.
-
community(CommunityView) –
Source code in pylemmy/models/community.py
23 24 25 26 27 28 29 30 31 32 33 34 | |
stream: CommunityStream
property
Returns a stream of content.
This stream is to be used to monitor posts or comments.
Example:
community = lemmy.get_community("test")
for post in community.stream.get_posts():
process_post(post)
create_post(name, **kwargs)
Create a new post in this Community.
Parameters:
-
name(str) –Name of the post.
-
kwargs–See optional arguments in CreatePost.
Returns:
-
Post–The created Post.
Source code in pylemmy/models/community.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
get_comments(**kwargs)
Gets a list of Comments from this community.
Parameters:
-
kwargs–See optional arguments in GetComments.
Source code in pylemmy/models/community.py
63 64 65 66 67 68 69 70 71 72 73 | |
get_posts(**kwargs)
Gets a list of Posts from this community.
Parameters:
-
kwargs–See optional arguments in GetPosts.
Source code in pylemmy/models/community.py
51 52 53 54 55 56 57 58 59 60 61 | |
list_comment_reports(**kwargs)
List comment reports in this community.
Parameters:
-
kwargs–See optional arguments in ListCommentReports.
Source code in pylemmy/models/community.py
83 84 85 86 87 88 89 | |
list_post_reports(**kwargs)
List post reports in this community.
Parameters:
-
kwargs–See optional arguments in ListPostReports.
Source code in pylemmy/models/community.py
75 76 77 78 79 80 81 | |
CommunityStream(community)
Helper class to stream content from a specific community.
This class shouldn't be directly initialized, but rather accessed through [Community][pylemmy.community.Community].
Example:
community = lemmy.get_community("test")
for post in community.stream.get_posts():
process_post(post)
Initialize a CommunityStream.
Parameters:
-
community(Community) –A Community to run the stream on.
Source code in pylemmy/models/community.py
119 120 121 122 123 124 | |
get_comments(**kwargs)
Get a stream of Comments in the Community.
Parameters:
-
kwargs–See the optional arguments in stream_generator.
Source code in pylemmy/models/community.py
138 139 140 141 142 143 144 145 146 147 148 | |
get_posts(**kwargs)
Get a stream of Posts in the Community.
Parameters:
-
kwargs–See the optional arguments in stream_generator.
Source code in pylemmy/models/community.py
126 127 128 129 130 131 132 133 134 135 136 | |
MultiCommunityStream(communities)
Helper class to stream content from multiple communities.
This class shouldn't be directly initialized, but rather accessed through Lemmy.
Example: A simple example where we want to print the content of each post.
def process_content(elem: Union[Post, Comment]):
print(elem.post_view.post.name)
multi_stream = lemmy.multi_communities_stream(["community1", "community2"])
multi_stream.content_apply(process_content)
Initializer for MultiCommunityStream.
Parameters:
-
communities(List[Community]) –A list of communities to monitor.
Source code in pylemmy/models/community.py
167 168 169 170 171 172 | |
comments_apply(callback, **kwargs)
Apply a callback function to a stream of Comments in the Communities.
Example: A simple example where we want to print the content of each comment.
def process_content(elem: Union[Post, Comment]):
print(elem.comment_view.comment.content)
multi_stream = lemmy.multi_communities_stream(["community1", "community2"])
multi_stream.content_apply(process_content)
Parameters:
-
callback(Callable[[Comment], Any]) –Function that will be called for each Comment.
-
kwargs–See the optional arguments in stream_generator.
Source code in pylemmy/models/community.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
content_apply(callback, **kwargs)
Apply a callback function to a stream of Comments and Posts.
Example: A simple example where we want to print the content of each post/comment.
def process_content(elem: Union[Post, Comment]):
if isinstance(Post, elem):
print(elem.post_view.post.name)
elif isinstance(Comment, elem):
print(elem.comment_view.comment.content)
multi_stream = lemmy.multi_communities_stream(["community1", "community2"])
multi_stream.content_apply(process_content)
Parameters:
-
callback(Callable[[Union[Comment, Post]], Any]) –Function that will be called for each Comment/Post.
-
kwargs–See the optional arguments in stream_generator.
Source code in pylemmy/models/community.py
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 | |
posts_apply(callback, **kwargs)
Apply a callback function to a stream of Posts in the Communities.
Example: A simple example where we want to print the content of each post.
def process_content(elem: Union[Post, Comment]):
print(elem.post_view.post.name)
multi_stream = lemmy.multi_communities_stream(["community1", "community2"])
multi_stream.content_apply(process_content)
Parameters:
-
callback(Callable[[Post], Any]) –Function that will be called for each Post.
-
kwargs–See the optional arguments in stream_generator.
Source code in pylemmy/models/community.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |