-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram.py
245 lines (223 loc) · 6.5 KB
/
program.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
from random import randrange
from shutil import ExecError
import string
from TikTokLive import TikTokLiveClient
from TikTokLive.types.events import CommentEvent, ConnectEvent, JoinEvent, FollowEvent, GiftEvent
import PySimpleGUI as pg
import asyncio
currWord = ""
encryptedWord = ""
client: TikTokLiveClient = TikTokLiveClient(unique_id="@kursosi4ka") #your id
pg.theme("DarkAmber")
layout = [
[pg.Push("darkred")],
[pg.Text(
"Guess the word",
key='-NAZVA-',
text_color = "white",
size=(50, 1),
font=('Lucida',34),
justification='center',)
],[pg.Push("darkred")],[pg.Push()],
[pg.Text("Follow for more games!",font=('Lucida',20),text_color = "pink",size=(50, 2),justification='center' )],
[pg.Text(
"Current word:",
font=('Lucida',27),
text_color = "red",
size=(50, 1)
,justification='center')
],
[pg.Text
(
"а**вw*в",
key = '-WORD-',
font=('Lucida',60),
text_color = "white",
size=(50, 1),
background_color=None,
justification='center'
)
],
[pg.Text
(
"‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾",
font=2,
size=(50, 1),
text_color = "white",
justification='center'
)
], [pg.Push()],
[pg.Image
(
"try1.png",
size = (70,70)
),
pg.Image
(
"tenis.png",
size = (70,70)
),
pg.Image
(
"dinamil1.png",
size = (70,70)
),
pg.Image
(
"gg1.png",
size = (70,70)
),
pg.Image
(
"tik1.png",
size = (70,70)
),
pg.Text
(
"→1 hint",
text_color = "white",
font=('Lucida',15)
)
],[pg.Push()],[pg.Push()],[pg.Push()],
[pg.Text
(
"The last word was guessed by:\n@kursosi4ka",
key = '-GB-',
font=('Lucida',23),
text_color = "DarkGoldenrod1",
size=(50, 4),
justification='center',
auto_size_text= True
)
],
[pg.Text
(
"Hello, ЩІЩАЩ",
key = '-Hello-',
font=('Lucida',23),
text_color = "white",
size=(50, 2),
justification='center',
auto_size_text= True
)
],
[pg.Multiline
(
"Thanks for a gift, ЩІЩАЩ and me and u and wqrqw adaq",
key = '-GIFTFOLLOW-',
background_color = "firebrick4",
no_scrollbar = True,
font=('Lucida',23),
text_color = "white",
size=(50, 2),
justification='center',
auto_size_text= True
)
],
[pg.Push()],[pg.Push()],[pg.Push()],[pg.Push()],[pg.Push()],
[pg.Push("darkred")]
]
window = pg.Window(' ', layout, size=(500, 800))
@client.on("comment")
async def on_comment(event: CommentEvent):
global currWord
global guessed
print(f"{event.user.nickname} -> {event.comment}", flush=True)
try:
if event.comment == currWord:
if not guessed:
guessed = True
window['-GB-'].update(f"The last word was guessed by:\n@{event.user.uniqueId}\n({currWord})")
word = get_word()
currWord = word
encrypt(word)
guessed = False
else:
return
except Exception as i:
print(i)
@client.on("connect")
async def on_connect(_: ConnectEvent):
print("Connected to Room ID:", client.room_id, flush=True)
word = get_word()
encrypt(word)
@client.on("join")
async def on_join(event: JoinEvent):
print(f"Hello, @{event.user.uniqueId}!")
window['-Hello-'].update(f"Hello, @{event.user.uniqueId}!")
@client.on("follow")
async def on_follow(event: FollowEvent):
print(f"Thanks for following, @{event.user.uniqueId}!")
window['-GIFTFOLLOW-'].update(f"Thanks for following, @{event.user.uniqueId}!")
@client.on("gift")
async def on_gift(event: GiftEvent):
global currWord
global encryptedWord
if event.gift.gift_type == 1 and event.gift.repeat_end == 1:
print(f"{event.user.uniqueId} sent {event.gift.repeat_count}x \"{event.gift.extended_gift.name}\"")
window['-GIFTFOLLOW-'].update(f"Thanks {event.user.uniqueId} for {event.gift.repeat_count}x \"{event.gift.extended_gift.name}\"")
elif event.gift.gift_type != 1:
print(f"{event.user.uniqueId} sent \"{event.gift.extended_gift.name}\"")
window['-GIFTFOLLOW-'].update(f"Thanks {event.user.uniqueId} for \"{event.gift.extended_gift.name}\"")
if encryptedWord.count("*") != 1:
count = 0
for c in encryptedWord:
if c == '*':
encryptedWord = encryptedWord[:count] + currWord[count] + encryptedWord[count+1:]
break
count += 1
window['-WORD-'].update(encryptedWord)
async def winReadLoop():
while(True):
await asyncio.sleep(0.01)
event, values = window.read(0)
if event == "__TIMEOUT__":
continue
if event is None or event == 'Exit':
return
def run(words):
asyncio.get_event_loop().run_until_complete(asyncio.gather(winReadLoop(), client.start()))
def encrypt(word: str):
global currWord
global encryptedWord
stars = starsSet[randrange(0,len(starsSet)-1)]
encryptedWord = ""
count = 0
for c in word:
if count in stars:
encryptedWord += "*"
else:
encryptedWord += c
count += 1
window['-WORD-'].update(encryptedWord)
print(f"\n\n\n[CURRENT WORD]\n{word}\n[CURRENT WORD]\n\n\n")
currWord = word
def get_word():
return words[randrange(0,len(words)-1)]
guessed = False
connected = False
words = []
starsSet = [ #cringe
[0,4,5],
[6,1,2],
[2,6,5],
[3,5,4],
[1,3,4],
[6,3,4],
[1,3,5],
[1,3,6],
[1,5,4],
[2,5,4],
[6,1,3],
[0,3,2],
[0,1,6],
[0,2,3],
[0,5,3],
[0,5,3]
]
with open('words.txt') as f:
line = f.read()
lines = line.split("\n")
for l in lines:
words.append(l)
run(words)