Prepare for room v3+, misc bugfixes
This commit is contained in:
@@ -7,7 +7,6 @@ import hashlib
|
||||
import base64
|
||||
import random
|
||||
import httpx
|
||||
import copy
|
||||
import json
|
||||
import re
|
||||
|
||||
@@ -263,14 +262,15 @@ def make_ref_hash(
|
||||
|
||||
def room_version_from_id(room):
|
||||
room_id_no_sigil = room.replace("!", "")
|
||||
|
||||
hexadecimal_room_id = bytes(room_id_no_sigil, "utf-8").hex()
|
||||
|
||||
if "1" not in hexadecimal_room_id and "2" not in hexadecimal_room_id:
|
||||
hexadecimal_room_id = "1" + hexadecimal_room_id[1:]
|
||||
versions = [str(i) for i in range(1, 3)]
|
||||
|
||||
if not any(ver in hexadecimal_room_id for ver in versions):
|
||||
hexadecimal_room_id = "2" + hexadecimal_room_id[1:]
|
||||
|
||||
def remove_chars(s):
|
||||
return re.sub("[^12]", "", s)
|
||||
return re.sub(f"[^{''.join(versions)}]", "", s)
|
||||
|
||||
nums = remove_chars(hexadecimal_room_id)
|
||||
|
||||
@@ -278,9 +278,9 @@ def room_version_from_id(room):
|
||||
s = s.replace(" ", "").lower()
|
||||
counts = Counter(s)
|
||||
most_common = counts.most_common(1)
|
||||
return most_common[0] if most_common else None
|
||||
return most_common[0] if most_common else ("2",)
|
||||
|
||||
return most_common_character(nums)[0]
|
||||
return str(most_common_character(nums)[0])
|
||||
|
||||
|
||||
room_dir = {
|
||||
|
||||
Reference in New Issue
Block a user