1
1
from .http import HTTPClient , HTTPResponse
2
- from .errors import EndpointRequiresToken , ServiceException
2
+ from .errors import EndpointRequiresToken , ServiceException , PostingUnsupported
3
3
from urllib .parse import urlencode as _encode_query
4
+ from urllib .parse import quote as _encode_uri
4
5
5
6
class Service :
6
7
"""
@@ -624,6 +625,172 @@ def get_bot_votes(self, bot_id: str) -> HTTPResponse:
624
625
requires_token = True
625
626
)
626
627
628
+ class DBLista (Service ):
629
+ """
630
+ Represents the DBLista service.
631
+
632
+ .. seealso::
633
+ - `DBLista Website <https://dblista.pl/>`_
634
+ - `DBLista API Documentation <https://docs.dblista.pl/>`_
635
+ """
636
+
637
+ BASE_URL = 'https://www.cloudlist.xyz/api'
638
+
639
+ @staticmethod
640
+ def aliases () -> list :
641
+ return ['dblistapl' , 'dblista.pl' , 'dblista' ]
642
+
643
+ @staticmethod
644
+ def _post (
645
+ http_client : HTTPClient , bot_id : str , token : str
646
+ ) -> HTTPResponse :
647
+ raise PostingUnsupported ()
648
+
649
+ def add_bot (self , data : dict ) -> HTTPResponse :
650
+ """|httpres|\n
651
+ Updates the bot's listing with the data provided.
652
+
653
+ Parameters
654
+ -----------
655
+ data: :class:`dict`
656
+ The data being posted. This should include the ID of the bot.
657
+ """
658
+ return self ._request (
659
+ method = 'POST' ,
660
+ path = '/bots' ,
661
+ json = data ,
662
+ headers = { 'Authorization' : self .token },
663
+ requires_token = True
664
+ )
665
+
666
+ def update_bot (self , data : dict ) -> HTTPResponse :
667
+ """|httpres|\n
668
+ Updates the bot's listing with the data provided.
669
+
670
+ Parameters
671
+ -----------
672
+ data: :class:`dict`
673
+ The data being posted. This should include the ID of the bot.
674
+ """
675
+ return self ._request (
676
+ method = 'PUT' ,
677
+ path = '/bots' ,
678
+ json = data ,
679
+ headers = { 'Authorization' : self .token },
680
+ requires_token = True
681
+ )
682
+
683
+ def get_bot (self , bot_id : str ) -> HTTPResponse :
684
+ """|httpres|\n
685
+ Gets the bot's stats on this service.
686
+
687
+ Parameters
688
+ -----------
689
+ bot_id: :class:`str`
690
+ The bot's ID.
691
+ """
692
+ return self ._request (
693
+ method = 'GET' ,
694
+ path = f'/bots/{ bot_id } '
695
+ )
696
+
697
+ def get_bots (self , page : int = 0 ) -> HTTPResponse :
698
+ """|httpres|\n
699
+ Gets the bot's stats on this service.
700
+
701
+ Parameters
702
+ -----------
703
+ page: :class:`int`
704
+ The page you want to get.
705
+ """
706
+ return self ._request (
707
+ method = 'GET' ,
708
+ path = f'/bots/list/{ page } '
709
+ )
710
+
711
+ def get_unverified_bots (self ) -> HTTPResponse :
712
+ """|httpres|\n
713
+ Gets a list of unverified bots on this service.
714
+ """
715
+ return self ._request (
716
+ method = 'GET' ,
717
+ path = '/bots/list/unverified'
718
+ )
719
+
720
+ def get_rejected_bots (self ) -> HTTPResponse :
721
+ """|httpres|\n
722
+ Gets a list of rejected bots on this service.
723
+ """
724
+ return self ._request (
725
+ method = 'GET' ,
726
+ path = '/bots/list/rejected'
727
+ )
728
+
729
+ def rate_bot (self , bot_id : str , data : dict ) -> HTTPResponse :
730
+ """|httpres|\n
731
+ Adds a rating to a bot on the service.
732
+
733
+ Parameters
734
+ -----------
735
+ bot_id: :class:`str`
736
+ The bot's ID.
737
+ data: :class:`dict`
738
+ The data being posted. This should include the ID of the bot.
739
+ """
740
+ return self ._request (
741
+ method = 'POST' ,
742
+ path = f'/bots/{ bot_id } /rate' ,
743
+ json = data ,
744
+ headers = { 'Authorization' : self .token },
745
+ requires_token = True
746
+ )
747
+
748
+ def remove_rating (self , bot_id : str ) -> HTTPResponse :
749
+ """|httpres|\n
750
+ Removes a rating from a bot on the service.
751
+
752
+ Parameters
753
+ -----------
754
+ bot_id: :class:`str`
755
+ The bot's ID.
756
+ """
757
+ return self ._request (
758
+ method = 'DELETE' ,
759
+ path = f'/bots/{ bot_id } /rate' ,
760
+ headers = { 'Authorization' : self .token },
761
+ requires_token = True
762
+ )
763
+
764
+ def remove_bot (self , bot_id : str ) -> HTTPResponse :
765
+ """|httpres|\n
766
+ Removes a bot from the service.
767
+
768
+ Parameters
769
+ -----------
770
+ bot_id: :class:`str`
771
+ The bot's ID.
772
+ """
773
+ return self ._request (
774
+ method = 'DELETE' ,
775
+ path = f'/bots/{ bot_id } ' ,
776
+ headers = { 'Authorization' : self .token },
777
+ requires_token = True
778
+ )
779
+
780
+ def search (self , query : str ) -> HTTPResponse :
781
+ """|httpres|\n
782
+ Searches for bots on the service.
783
+
784
+ Parameters
785
+ -----------
786
+ query: :class:`str`
787
+ The query to search for.
788
+ """
789
+ return self ._request (
790
+ method = 'GET' ,
791
+ path = f'/bots/search/{ _encode_uri (query , safe = '~()*!.\' ' )} '
792
+ )
793
+
627
794
class DiscordBotsGG (Service ):
628
795
"""
629
796
Represents the Discord Bots service.
@@ -1944,8 +2111,8 @@ def get_unverified_bots(self) -> HTTPResponse:
1944
2111
)
1945
2112
1946
2113
Service .SERVICES = [
1947
- Arcane , BotListSpace , BotsForDiscord , BotsOfDiscord , BotsOnDiscord ,
1948
- Carbon , CloudBotList , CloudList , DiscordBotsGG , DiscordAppsDev , DiscordBoats ,
2114
+ Arcane , BotListSpace , BotsForDiscord , BotsOfDiscord , BotsOnDiscord , Carbon ,
2115
+ CloudBotList , CloudList , DBLista , DiscordBotsGG , DiscordAppsDev , DiscordBoats ,
1949
2116
DiscordBotList , DiscordBotWorld , DiscordExtremeList , DivineDiscordBots , GlennBotList ,
1950
2117
LBots , ListMyBots , MythicalBots , SpaceBotsList , TopGG , WonderBotList , YABL
1951
2118
]
0 commit comments