Skip to content

Commit 49e5dd7

Browse files
committed
Add botlistspace, fix index.rst and poster
1 parent 65d2299 commit 49e5dd7

File tree

4 files changed

+86
-6
lines changed

4 files changed

+86
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ See more examples [here](/examples).
106106
## Services
107107

108108
### Supported Services
109+
- [botlist.space](https://botlist.space)
109110
- [top.gg (formerly discordbots.org)](https://top.gg)
110111
- [discord.bots.gg](https://discord.bots.gg)
111112
- *More services will be supported in a future release...*

dbots/poster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ def __repr__(self):
7070
# property fill-ins
7171

7272
@property
73-
def client_id(self) -> str or None::
73+
def client_id(self) -> str or None:
7474
return self._client_id
7575

7676
@property
77-
def shard_id(self) -> int or None::
77+
def shard_id(self) -> int or None:
7878
return self._shard_id
7979

8080
@property

dbots/service.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,79 @@ def __repr__(self):
3636
]
3737
return '<%s %s>' % (self.__class__.__name__, ' '.join('%s=%r' % t for t in attrs))
3838

39+
###############################
40+
41+
class BotListSpace(Service):
42+
"""
43+
Represents the botlist.space's service.
44+
45+
.. seealso::
46+
`Service's API Documentation <https://docs.botlist.space/>`_
47+
API Documentation for botlist.space
48+
"""
49+
50+
BASE_URL = 'https://api.botlist.space/v1'
51+
52+
@staticmethod
53+
def _post(
54+
http_client, bot_id, token,
55+
server_count = 0, user_count = 0,
56+
voice_connections = 0, shard_count = None,
57+
shard_id = None
58+
):
59+
return http_client.request(
60+
method = 'POST',
61+
path = f'{BotListSpace.BASE_URL}/bots/{bot_id}',
62+
headers = { 'Authorization': token, 'Content-Type': 'application/json' },
63+
json = { 'server_count': server_count }
64+
)
65+
66+
def get_statistics(self) -> HTTPResponse:
67+
return self._request(
68+
method = 'GET',
69+
path = '/statistics'
70+
)
71+
72+
def get_bots(self) -> HTTPResponse:
73+
return self._request(
74+
method = 'GET',
75+
path = '/bots'
76+
)
77+
78+
def get_bot(self, bot_id) -> HTTPResponse:
79+
return self._request(
80+
method = 'GET',
81+
path = f'/bots/{bot_id}'
82+
)
83+
84+
def get_bot_votes(self, bot_id) -> HTTPResponse:
85+
return self._request(
86+
method = 'GET',
87+
path = f'/bots/{bot_id}/upvotes',
88+
requires_token = True
89+
)
90+
91+
def get_bot_uptime(self, bot_id) -> HTTPResponse:
92+
return self._request(
93+
method = 'GET',
94+
path = f'/bots/{bot_id}/uptime'
95+
)
96+
97+
def get_user(self, user_id) -> HTTPResponse:
98+
return self._request(
99+
method = 'GET',
100+
path = f'/users/{user_id}'
101+
)
102+
103+
def get_user_bots(self, user_id) -> HTTPResponse:
104+
return self._request(
105+
method = 'GET',
106+
path = f'/users/{user_id}/bots'
107+
)
108+
109+
def get_widget_url(self, bot_id, style = 1, **query) -> str:
110+
return f'https://api.botlist.space/widget/{bot_id}/{style}?{_encode_query(query)}'
111+
39112
class DiscordBotsGG(Service):
40113
"""
41114
Represents the discord.bots.gg service.
@@ -159,6 +232,10 @@ def get_widget_url(self, bot_id, small_widget = None, **query) -> str:
159232
return f'{TopGG.BASE_URL}/widget/{subpath}{bot_id}.svg?{_encode_query(query)}'
160233

161234
Service.SERVICE_KEYMAP = {
235+
'botlistspace': BotListSpace,
236+
'botlist.space': BotListSpace,
237+
'bls': BotListSpace,
238+
162239
'discordbotsgg': DiscordBotsGG,
163240
'discord.bots.gg': DiscordBotsGG,
164241
'dbotsgg': DiscordBotsGG,

docs/index.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,21 @@ Services
119119

120120
Supported Services
121121
~~~~~~~~~~~~~~~~~~
122+
- `botlist.space <https://botlist.space>`_
122123
- `top.gg <https://top.gg>`_
123124
- `discord.bots.gg <https://discord.bots.gg>`_
124125
- *More services will be supported in a future release...*
125126

126127
Adding Custom Services
127128
~~~~~~~~~~~~~~~~~~~~~~
128-
You can add custom services by extending from the base service class (``dbots.Service``) and overriding the ``_post`` method.
129-
Make sure to add the custom service class to the service keymap. (``dbots.Service.SERVICE_KEYMAP``) An example of adding a custom service can be shown `here <https://github.com/dbots-pkg/dbots.py/blob/master/examples/custom_service.py>`_.
129+
You can add custom services by extending from the base service class (``dbots.Service``) and overriding the ``_post`` method.
130+
Make sure to add the custom service class to the service keymap. (``dbots.Service.SERVICE_KEYMAP``)
131+
An example of adding a custom service can be shown `here <https://github.com/dbots-pkg/dbots.py/blob/master/examples/custom_service.py>`_.
130132

131133
Adding a custom post function
132134
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
133-
You can add a custom post event by defining ``on_custom_post`` in the initialization of a Poster.
134-
This function can be used when executing ``poster.post('custom')`` and when all services are being posted to.
135+
You can add a custom post event by defining ``on_custom_post`` in the initialization of a Poster.
136+
This function can be used when executing ``poster.post('custom')`` and when all services are being posted to.
135137
An example of adding a custom post function can be shown `here <https://github.com/dbots-pkg/dbots.py/blob/master/examples/custom_post.py>`_.
136138

137139
Contribution

0 commit comments

Comments
 (0)