redditadmin 0.0.4__py3-none-any.whl → 0.0.6__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,166 @@
1
+ Metadata-Version: 2.4
2
+ Name: redditadmin
3
+ Version: 0.0.6
4
+ Summary: Extensible Python administrative bot
5
+ Project-URL: Homepage, https://github.com/Grod56/reddit-admin
6
+ Project-URL: Issues, https://github.com/Grod56/reddit-admin/issues
7
+ Author-email: Grod56 <providenceuniversalstudios@gmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+
15
+ # Reddit Admin
16
+
17
+ [![pypi](https://img.shields.io/pypi/v/redditadmin.svg)](https://pypi.org/project/redditadmin/)
18
+
19
+ Plugin-based, extensible administrative Reddit bot framework capable of managing and running multiple 'plugins' (i.e. scripts) asynchronously. Built on top of the PRAW API client wrapper.
20
+
21
+ It includes a working implementation of the bot itself and tools to build plugins for the bot to run.
22
+
23
+ ## Installation
24
+
25
+ ```console
26
+ pip install redditadmin
27
+ ```
28
+
29
+ For instructions on installing Python and `pip` see "The Hitchhiker's Guide to Python"
30
+ [Installation Guides](https://docs.python-guide.org/en/latest/starting/installation/).
31
+
32
+ ## Quickstart
33
+
34
+ `reddit-admin` requires two things in order for it to work:
35
+
36
+ - Valid OAuth script application credentials i.e. `client_id`, `client_secret`, `username`, `password` and `user_agent` (see more about that [here](https://github.com/reddit-archive/reddit/wiki/OAuth2-Quick-Start-Example#first-steps))
37
+ - A list of plugins (will discuss more about how to implement these later)
38
+
39
+ Assuming that both of these are provided for, the bot may be run in this way:
40
+
41
+ ```py
42
+ from redditadmin import get_reddit_admin, BotCredentials
43
+
44
+ # Enter the OAuth credentials into the BotCredentials constructor
45
+ bot_credentials = BotCredentials(
46
+ client_id="example_id",
47
+ client_secret="example_secret",
48
+ user_agent="example_useragent",
49
+ username="example_username",
50
+ password="example_password"
51
+ )
52
+
53
+ # List of plugins provided by the user
54
+ plugins = [plugin1, plugin2, ...]
55
+
56
+ # Built-in function to get an instance of the reddit-admin bot
57
+ reddit_admin = get_reddit_admin(
58
+ plugins=plugins
59
+ )
60
+
61
+ # Running the bot
62
+ reddit_admin.run(
63
+ bot_credentials=bot_credentials,
64
+ listen=False # (Default value)
65
+ )
66
+ ```
67
+
68
+ _NOTE: `RedditAdmin.run()` is a blocking command, meaning that no further code will execute until either the `RedditAdmin.stop()` function is called elsewhere, or if the bot receives a `SIGINT` or `SIGTERM` signal._
69
+
70
+ Console output:
71
+
72
+ ```
73
+ redditadmin.core : Initializing the bot
74
+ Asynchronous Plugins Executor : Initializing Plugins Executor
75
+ Asynchronous Plugins Executor : Retrieving initial program commands
76
+ Asynchronous Plugins Executor : Executing initial program commands
77
+ Asynchronous Plugins Executor : Running program 'plugin1_program'
78
+ Asynchronous Plugins Executor : Running program 'plugin2_program'
79
+ Asynchronous Plugins Executor : Programs Executor initialized
80
+ redditadmin.core : Bot successfully initialized
81
+ redditadmin.core : The bot is now running
82
+ ```
83
+
84
+ ### Bot modes
85
+
86
+ The bot runs in two modes: 'listening' mode and 'autonomous' mode. In listening mode, the bot is capable of receiving commands through the console input, while in autonomous mode, the bot only responds to system signals (e.g. `SIGINT`).
87
+
88
+ Listening mode bot commands:
89
+
90
+ - `status` - displays the status of running plugin programs
91
+ - `run` - runs a plugin program (provided one is not already running)
92
+ - `shutdown/quit/exit` - shuts down the bot
93
+
94
+ ## Plugins
95
+
96
+ Plugins are mini-applications run and managed by Reddit Admin which instantiate a specific task or program.
97
+
98
+ The `redditadminplugins` Python package contains some useful plugins which may be adapted to the user's needs (see more [here](https://pypi.org/project/redditadminplugins/)).
99
+
100
+ To create a custom plugin, you need to do 2 things:
101
+
102
+ - To implement a `Program`
103
+ - To implement a `Plugin` based on the implemented program
104
+
105
+ For example, we may create a plugin which automatically posts a submission to the r/test subreddit when run as follows:
106
+
107
+ Program:
108
+
109
+ ```py
110
+ from redditadmin import Plugin, Program, get_reddit_admin
111
+
112
+
113
+ class MyProgram[Program]:
114
+ """The program to post our submission"""
115
+
116
+ def __init__(praw_reddit):
117
+ super().__init__("My Program")
118
+ self.praw_reddit = praw_reddit
119
+
120
+ def execute(self, *args, **kwargs):
121
+ """Overriden from the Program superclass"""
122
+
123
+ self.praw_reddit.subreddit('test').submit(
124
+ title="Testing 123",
125
+ url="https://google.com"
126
+ )
127
+ ```
128
+
129
+ Plugin:
130
+
131
+ ```py
132
+ class MyPlugin[Plugin[MyProgram]]
133
+ """The plugin for our program"""
134
+
135
+ def __init__():
136
+ super().__init__("myprogram")
137
+
138
+ def get_program(self, reddit_interface):
139
+ """Overriden from Plugin superclass"""
140
+
141
+ praw_reddit = reddit_interface.get_praw_reddit
142
+
143
+ return MyProgram(praw_reddit)
144
+ ```
145
+
146
+ Voila! We may now supply our plugin to the bot and run it just as we did before
147
+
148
+ ```py
149
+ plugin = MyPlugin()
150
+ bot_credentials = ...
151
+
152
+ reddit_admin = get_reddit_admin(
153
+ plugins=[plugin]
154
+ )
155
+
156
+ reddit_admin.run(
157
+ bot_credentials=bot_credentials
158
+ )
159
+ ```
160
+
161
+ For more information on how to use PRAW in your plugins, see the official repository [here](https://github.com/praw-dev/praw).
162
+
163
+ ## See more
164
+
165
+ - [reddit-admin-plugins](https://github.com/Grod56/reddit-admin-plugins)
166
+ - [PRAW](https://github.com/praw-dev/praw)
@@ -16,7 +16,7 @@ redditadmin/utility/decorators.py,sha256=T0Mir1zX3_tHVDuU3UaQ1Mg1ayapaL84_GSbuif
16
16
  redditadmin/utility/exceptions.py,sha256=8XliprLrcYtKYji6JPYw6nfC3yA0i551iOSV3Op06A4,652
17
17
  redditadmin/utility/redditinterface.py,sha256=kWmUrdQffujf3j9bDE9wCH3FAmvckeaOWcl9NV3MRy0,415
18
18
  redditadmin/utility/redditsubmission.py,sha256=tB830FGKmnFMBg5GXrMcGKYdGtSSYgt_uCCaLnNYlC4,862
19
- redditadmin-0.0.4.dist-info/METADATA,sha256=lBDvuLj28a18VyjP2ae02Xx8wZudDQ38YkbwckcbcLc,523
20
- redditadmin-0.0.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
21
- redditadmin-0.0.4.dist-info/licenses/LICENSE,sha256=kieFEKjHWxFgNnmvKA_eXHmaQQZ9ZgEI_5m14IiVzAo,1091
22
- redditadmin-0.0.4.dist-info/RECORD,,
19
+ redditadmin-0.0.6.dist-info/METADATA,sha256=QU7GBJQ8cRPmx2shBPPEUBMRS1sC7MmEFQ-Jy0-1k1Q,5366
20
+ redditadmin-0.0.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
21
+ redditadmin-0.0.6.dist-info/licenses/LICENSE,sha256=kieFEKjHWxFgNnmvKA_eXHmaQQZ9ZgEI_5m14IiVzAo,1091
22
+ redditadmin-0.0.6.dist-info/RECORD,,
@@ -1,15 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: redditadmin
3
- Version: 0.0.4
4
- Summary: Extensible Python administrative bot
5
- Project-URL: Homepage, https://github.com/Grod56/reddit-admin
6
- Project-URL: Issues, https://github.com/Grod56/reddit-admin/issues
7
- Author-email: Grod56 <providenceuniversalstudios@gmail.com>
8
- License-Expression: MIT
9
- License-File: LICENSE
10
- Classifier: Operating System :: OS Independent
11
- Classifier: Programming Language :: Python :: 3
12
- Requires-Python: >=3.9
13
- Description-Content-Type: text/markdown
14
-
15
- Extensible Reddit admin bot