diff options
author | diSabler <dissy@ya.ru> | 2020-05-14 00:21:50 +0300 |
---|---|---|
committer | diSabler <dissy@ya.ru> | 2020-05-14 00:21:50 +0300 |
commit | 547191ab0eadfe8e47ba5422621a17fa85045544 (patch) | |
tree | 3e03181ee408edb263981ef232065e2ff82d64cc | |
parent | 009088fb262427d28940cfcc66b1629a6ed042a5 (diff) |
fix: python3 support
-rwxr-xr-x | kernel.py | 4 | ||||
-rw-r--r-- | plugins/.domain.py | 4 | ||||
-rw-r--r-- | plugins/event.py | 6 | ||||
-rw-r--r-- | plugins/execute.py | 2 | ||||
-rw-r--r-- | plugins/turn.py | 4 |
5 files changed, 10 insertions, 10 deletions
@@ -273,8 +273,8 @@ def parser(t): try:
return ''.join([['?', l][l<='~'] for l in unicode(t)])
except:
- fp = file(slog_folder % 'critical_exception_%s.txt' % int(time.time()), 'wb')
- fp.write(t)
+ with open(slog_folder % 'critical_exception_%s.txt' % int(time.time()), 'wb') as fp:
+ fp.write(t)
fp.close()
# Log message
diff --git a/plugins/.domain.py b/plugins/.domain.py index 096c0f9..6244f55 100644 --- a/plugins/.domain.py +++ b/plugins/.domain.py @@ -74,10 +74,10 @@ def cmd_domaininfo(raw_in, text): for tmp in body:
if ':' in tmp:
if len(tmp.split(':')[0].split()) <= 2 and len(tmp.split(':')[1]) >= 2:
- if not tmp_body.has_key(tmp.split(':')[1]):
+ if tmp.split(':')[1] not in tmp_body:
tmp_body[tmp.split(':')[1]]=tmp.split(':')[0]
newbody.append(tmp)
- elif tmp.count(' ') <= 4 and not tmp_body.has_key(tmp):
+ elif tmp.count(' ') <= 4 and tmp not in tmp_body:
tmp_body[tmp] = tmp
newbody.append(tmp)
msg += '\n'+'\n'.join(newbody)
diff --git a/plugins/event.py b/plugins/event.py index 9cae21d..42a8556 100644 --- a/plugins/event.py +++ b/plugins/event.py @@ -42,8 +42,8 @@ def cmd_event(raw_in, less): MESSAGE = raw_in.get('message', {})
CHAT = MESSAGE.get('chat', {})
if CHAT.get('type', '') in ['supergroup', 'group']:
- if not less and raw_in['message'].has_key('reply_to_message'):
- if raw_in['message']['reply_to_message'].has_key('text'):
+ if not less and 'reply_to_message' in raw_in['message']:
+ if 'text' in raw_in['message']['reply_to_message']:
less = raw_in['message']['reply_to_message']['text']
if less:
CHAT_ID = CHAT['id']
@@ -51,7 +51,7 @@ def cmd_event(raw_in, less): USER_ID = FROM['id']
EVENT_NAME = less.capitalize().replace(' ', '_')
EVENTS[CHAT_ID] = EVENTS.get(CHAT_ID, {})
- if EVENTS[CHAT_ID].has_key(EVENT_NAME):
+ if EVENT_NAME in EVENTS[CHAT_ID]:
if USER_ID == EVENTS[CHAT_ID][EVENT_NAME]['id']:
msg = '❎ Event `%s` removed' % EVENT_NAME
_ = EVENTS[CHAT_ID].pop(EVENT_NAME)
diff --git a/plugins/execute.py b/plugins/execute.py index 166cf5d..cc973ef 100644 --- a/plugins/execute.py +++ b/plugins/execute.py @@ -35,7 +35,7 @@ def cmd_execute(raw_in, text): def cmd_calc(raw_in, text):
global calc_last_res
ID = raw_in['message']['from']['id']
- if 'ans' in text.lower() and calc_last_res.has_key(ID):
+ if 'ans' in text.lower() and ID in calc_last_res:
text = text.lower().replace('ans', calc_last_res[ID])
legal = string.digits + string.ascii_letters + '*/+-()=^!<>. '
ppc = 1
diff --git a/plugins/turn.py b/plugins/turn.py index c6bc6c9..52846bb 100644 --- a/plugins/turn.py +++ b/plugins/turn.py @@ -34,8 +34,8 @@ def turner_raw(to_turn): return msg
def cmd_turn(raw_in, less):
- if not less and raw_in['message'].has_key('reply_to_message'):
- if raw_in['message']['reply_to_message'].has_key('text'):
+ if not less and 'reply_to_message' in raw_in['message']:
+ if 'text' in raw_in['message']['reply_to_message']:
less = raw_in['message']['reply_to_message']['text']
if less:
msg = turner_raw(less)
|