Connectionpool

This commit is contained in:
Christian Rendina 2020-03-11 02:39:26 +01:00
parent 62caedbafd
commit e3e8cd1109
2 changed files with 7 additions and 1 deletions

View File

@ -5,3 +5,4 @@ Password=
[Bot] [Bot]
Token= Token=
ConnectionPool=

View File

@ -65,6 +65,7 @@ class Config:
self.apiId = cfg["Api"]["Id"] self.apiId = cfg["Api"]["Id"]
self.apiPassword = cfg["Api"]["Password"] self.apiPassword = cfg["Api"]["Password"]
self.botToken = cfg["Bot"]["Token"] self.botToken = cfg["Bot"]["Token"]
self.botConnectionPool = cfg["Bot"]["ConnectionPool"]
def getApiUrl(self): def getApiUrl(self):
return self.apiUrl return self.apiUrl
@ -77,6 +78,9 @@ class Config:
def getBotToken(self): def getBotToken(self):
return self.botToken return self.botToken
def getBotConnectionPool(self):
return self.botConnectionPool
class InlineBot: class InlineBot:
def __init__(self): def __init__(self):
@ -129,7 +133,8 @@ class InlineBot:
return r.headers[command.getHeaderField()] return r.headers[command.getHeaderField()]
def start(self): def start(self):
self.bot = Bot(token=self.config.getBotToken()) self.prequest = Request(con_pool_size=int(self.config.getBotConnectionPool()))
self.bot = Bot(token=self.config.getBotToken(), request=self.prequest)
self.updater = Updater(bot=self.bot,use_context=True) self.updater = Updater(bot=self.bot,use_context=True)
print("Inline bot v. {}".format(BOT_VERSION)) print("Inline bot v. {}".format(BOT_VERSION))