Update to new Api
This commit is contained in:
parent
97589e4645
commit
c430c0e40e
|
@ -1 +1,5 @@
|
|||
Client for Inquisicao
|
||||
|
||||
Dont forget to:
|
||||
|
||||
config supybot.plugins.Inquisicao.apiKey your_api_key
|
|
@ -51,6 +51,7 @@ Inquisicao = conf.registerPlugin('Inquisicao')
|
|||
# This is where your configuration variables (if any) should go. For example:
|
||||
# conf.registerGlobalValue(Inquisicao, 'someConfigVariableName',
|
||||
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
|
||||
|
||||
conf.registerGlobalValue(Inquisicao, 'apiKey',
|
||||
registry.String("", _("""Inquisicao API key""")))
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
|
|
|
@ -50,6 +50,7 @@ class Inquisicao(callbacks.Plugin):
|
|||
self.__parent = super(Inquisicao, self)
|
||||
self.__parent.__init__(irc)
|
||||
self.__truncate = 380 # max chars
|
||||
self.__apiKey = self.registryValue('apiKey')
|
||||
|
||||
def __truncate_unicode_to_byte_limit(self, src, byte_limit, encoding='utf-8'):
|
||||
"""Ripado daqui: https://stackoverflow.com/a/24839091"""
|
||||
|
@ -135,8 +136,14 @@ class Inquisicao(callbacks.Plugin):
|
|||
return result
|
||||
|
||||
def __do_request(self, action, arguments):
|
||||
baseurl = "https://inquisicao.deadbsd.org/api/"
|
||||
response = requests.get(baseurl + action + "?" + urlencode(arguments))
|
||||
baseurl = "https://inquisicao.info/api/v1/"
|
||||
response = requests.get(
|
||||
baseurl + action + "?" + urlencode(arguments),
|
||||
headers={
|
||||
"Accept": "application/json",
|
||||
"Authorization": "Bearer " + self.__apiKey
|
||||
}
|
||||
)
|
||||
return json.loads(response.content.decode('utf-8'))
|
||||
|
||||
def find(self, irc, msg, args, text, position):
|
||||
|
|
Loading…
Reference in New Issue