|
@@ -549,11 +549,11 @@ class BotAgent:
|
|
|
self.register_per_hours()
|
|
|
self.ep.libHandleEvents(100)
|
|
|
|
|
|
- def create_account(self, recreate = False):
|
|
|
+ def create_account(self, recreate = False, timeout_sec=86400):
|
|
|
start_time = time.time()
|
|
|
try:
|
|
|
_hour = datetime.now().strftime('%Y%m%d%H')
|
|
|
- self.cache.set_register_per_hours(_hour)
|
|
|
+ self.cache.set_register_per_hours(_hour, expire=timeout_sec)
|
|
|
if recreate:
|
|
|
for k, v in self.accounts.items():
|
|
|
try:
|
|
@@ -573,7 +573,7 @@ class BotAgent:
|
|
|
cred = pj.AuthCredInfo("digest", "*", f"{user_part}", 0, self.password)
|
|
|
acfg.sipConfig.authCreds.append(cred)
|
|
|
|
|
|
- acfg.regConfig.timeoutSec = 86400 # 注册超时时间(秒)
|
|
|
+ acfg.regConfig.timeoutSec = timeout_sec # 注册超时时间(秒)
|
|
|
acfg.regConfig.retryIntervalSec = 10 # 重试间隔时间(秒)
|
|
|
acfg.regConfig.firstRetryIntervalSec = 10 # 首次重试间隔时间(秒)
|
|
|
|
|
@@ -599,8 +599,7 @@ class BotAgent:
|
|
|
def register_per_hours(self):
|
|
|
_hour = datetime.now().strftime('%Y%m%d%H')
|
|
|
_lock = self.cache.lock_register_per_hours(_hour)
|
|
|
- if _lock and len(self.accounts) == len(self.user_part_range):
|
|
|
- self.cache.set_register_per_hours(_hour)
|
|
|
+ if not _lock and len(self.accounts) == len(self.user_part_range):
|
|
|
self.create_account(recreate=True)
|
|
|
|
|
|
def transfer(self, user_part, call_id, device_id, service_id='00000000000000000'):
|