diff options
author | diSabler <dissy@ya.ru> | 2020-08-03 14:19:39 +0300 |
---|---|---|
committer | diSabler <dissy@ya.ru> | 2020-08-03 14:19:39 +0300 |
commit | 1ae2a8e285da9ca0c11541862229b260e3daa8d7 (patch) | |
tree | d6bb8fa791128aa9bb4a89bbfc3f78faf5ac0fab | |
parent | a718abd0ba590d408bea83ae1ae0e8b5fa7ea382 (diff) |
add: more than one bot`s owner
-rw-r--r-- | isida.py | 4 | ||||
-rwxr-xr-x | kernel.py | 11 | ||||
-rw-r--r-- | plugins/help.py | 4 | ||||
-rw-r--r-- | plugins/whoami.py | 2 |
4 files changed, 15 insertions, 6 deletions
@@ -109,7 +109,9 @@ if __name__ == "__main__": crash('Multilaunch detected! Kill pid %s before launch bot again!' % last_pid) except: SM = '\n'.join(str(t) for t in sys.exc_info()) - if 'ProcessLookupError' not in SM: + if 'No such process' in SM: + pass + elif 'ProcessLookupError' not in SM: crash('Unknown exception!\n%s' % SM) writefile(pid_file,str(PID)) @@ -250,6 +250,13 @@ def get_config_int(_config, _section, _name): except:
return -1
+# Get integer array of values from config
+def get_config_int_array(_config, _section, _name):
+ try:
+ return [int(t) for t in _config.get(_section, _name).split() if t]
+ except:
+ return [-1]
+
# Get binary value from config
# True == 1, '1', 'yes', 'true'
# False == all else
@@ -439,7 +446,7 @@ def check_updates(): pprint(json.dumps(msg_in, indent=2, separators=(',', ': ')), 'magenta')
continue
- IS_OWNER = msg_in['message']['from'].get('id', '') == OWNER_ID
+ IS_OWNER = msg_in['message']['from'].get('id', '') in OWNER_ID
CMD = msg_in['message'].get('text', '').strip()
splitter = '<%s>' % random.randint(0, 2 ** 32)
CMD = CMD.replace(BOT_NAME, splitter)
@@ -681,7 +688,7 @@ DEBUG_LOG = get_config_bin(CONFIG, CONFIG_DEBUG, 'logging') DEBUG_CONSOLE = get_config_bin(CONFIG, CONFIG_DEBUG, 'console')
DEBUG_JSON = get_config_bin(CONFIG, CONFIG_DEBUG, 'json')
HALT_ON_EXCEPTION = get_config_bin(CONFIG, CONFIG_DEBUG, 'halt_on_exception')
-OWNER_ID = get_config_int(CONFIG, CONFIG_OWNER, 'id')
+OWNER_ID = get_config_int_array(CONFIG, CONFIG_OWNER, 'id')
API_URL = TELEGRAM_API_URL % CONFIG_API_TOKEN + '/%s'
diff --git a/plugins/help.py b/plugins/help.py index 3c5b913..1e27a5c 100644 --- a/plugins/help.py +++ b/plugins/help.py @@ -25,7 +25,7 @@ def get_su(t): return ['', 'ā ļø'][t]
def cmd_help(raw_in, text):
- IS_OWNER = raw_in['message']['from'].get('id', '') == OWNER_ID
+ IS_OWNER = raw_in['message']['from'].get('id', '') in OWNER_ID
text = text.lower().strip()
if not text:
msg = ['š¤ iSida telegram bot',
@@ -65,7 +65,7 @@ def cmd_help(raw_in, text): send_msg(raw_in, msg)
def cmd_commands(raw_in):
- IS_OWNER = raw_in['message']['from'].get('id', '') == OWNER_ID
+ IS_OWNER = raw_in['message']['from'].get('id', '') in OWNER_ID
try:
CHAT_ID = raw_in['message']['chat'].get('id', 0)
except:
diff --git a/plugins/whoami.py b/plugins/whoami.py index bbf37b5..8514102 100644 --- a/plugins/whoami.py +++ b/plugins/whoami.py @@ -27,7 +27,7 @@ def cmd_whoami(raw_in): msg += ' <b>%s</b>' % raw_in['message']['from'].get('last_name', '')
ID = raw_in['message']['from'].get('id', 0)
msg += '\nš ID: <b>%s</b>' % ID
- IS_OWNER_TXT = ['No', 'Yes'][raw_in['message']['from'].get('id', '') == OWNER_ID]
+ IS_OWNER_TXT = ['No', 'Yes'][raw_in['message']['from'].get('id', '') in OWNER_ID]
msg += '\nš¤ Bot\'s owner: <b>%s</b>' % IS_OWNER_TXT
try:
CHAT_ID = raw_in['message']['chat'].get('id', 0)
|