-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.py
More file actions
47 lines (45 loc) · 1.56 KB
/
function.py
File metadata and controls
47 lines (45 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import random
import string
import json
import requests
class function:
@staticmethod
def generate_random_string(length=16):
characters = string.ascii_letters + string.digits
random_string = ''.join(random.choice(characters) for _ in range(length))
return random_string
@staticmethod
def user_in_room(self, id):
try:
return self.user_cache[id][1]["room"]
except:
return False
@staticmethod
def card_list(self, room_id):
card = []
i=0
for x in self.room_game[room_id]["fite_card"]:
card.append({"id":x["id_card"], "nh":i})
i=i+1
return f"Fight_cards('{json.dumps(card)}', 2)"
@staticmethod
def check_update(self):
try:
if json.loads(requests.get("https://api.github.com/repos/dmitrysenpai/Cardsvs-Reload/releases").content)[0]["tag_name"] != self.version:
return True
return False
except:
return False
@staticmethod
def chat_load(self):
code = '$("#chat").html(""); '
for x in self.cache_chat_global:
code = code + f'Writemsg("{x["username"]}", "{self.function.html_special_chars(x["text"])}"); '
return code + ' $(".chatblok").scrollTop(100000);'
def html_special_chars(self, text):
return text \
.replace(u"&", u"&") \
.replace(u'"', u""") \
.replace(u"'", u"'") \
.replace(u"<", u"<") \
.replace(u">", u">")