Skip to content

Commit 4e2396f

Browse files
committed
resolved issue with not getting username on startup
1 parent f00a469 commit 4e2396f

File tree

1 file changed

+6
-108
lines changed

1 file changed

+6
-108
lines changed

src/tiktok_main.py

Lines changed: 6 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
def handleSettings(settings, on_connect=False):
5050
settings = { list(settings[i])[0] : list(settings[i].values())[0] for i in range(len(settings)) }
5151
autoConnect = settings.get('Auto Connect', False)
52+
tk.Username = settings.get('TikTok Username')
5253
if autoConnect == "True":
53-
tk.Username = settings.get('TikTok Username')
5454
if tk.Username != "":
5555
tk.startup = True
5656
tk.set_client(tk.Username)
@@ -113,10 +113,11 @@ def onAction(data):
113113
tk.stop_TikTok_Thread()
114114

115115
if data['data'][0]['value'] == "Connect":
116-
tk.startup = True
117-
tk.set_client(tk.Username)
118-
run_tk()
119-
tk.isalive = True
116+
if tk.Username != "":
117+
tk.startup = True
118+
tk.set_client(tk.Username)
119+
run_tk()
120+
tk.isalive = True
120121

121122

122123
# Shutdown handler
@@ -505,106 +506,3 @@ def run_tk():
505506

506507

507508

508-
509-
510-
511-
#base64_data = TP.Tools.convertImage_to_base64("https://p16-sign.tiktokcdn-us.com/tos-useast5-avt-0068-tx/e9c3e8035885276e96c77632deefb252~tplv-tiktok-shrink:72:72.webp?x-expires=1690077600&x-signature=cIucsUGKGER85kf%2BNZV6eGr5DRo%3D")
512-
#print(base64_data)
513-
514-
515-
516-
517-
#import requests
518-
#
519-
#def get_content_type(url):
520-
# try:
521-
# r = requests.head(url)
522-
# content_type = r.headers.get('content-type')
523-
# return content_type
524-
# except requests.exceptions.RequestException as e:
525-
# print(f"Error: {e}")
526-
# return None
527-
#
528-
#url = "https://p16-sign.tiktokcdn-us.com/tos-useast5-avt-0068-tx/d650a1cd818572f3ec9790500c72b486~c5_100x100.webp?x-expires=1690077600&x-signature=C4Oi5uTpk6kWmiZvTWuvtoC0%2Ba4%3D"
529-
#url2 = "https://p19-sign.tiktokcdn-us.com/tos-useast5-avt-0068-tx/d650a1cd818572f3ec9790500c72b486~c5_100x100.webp?x-expires=1690077600&x-signature=nTEOqi970NMerDIShzKZEnukcYQ%3D"
530-
#content_type = get_content_type(url)
531-
#
532-
#content_type2 = get_content_type(url2)
533-
#
534-
#if content_type:
535-
# print(f"Content-Type: {content_type}")
536-
#else:
537-
# print("Failed to retrieve Content-Type.")
538-
539-
540-
541-
542-
543-
## from TikTokLive import TikTokLiveClient
544-
## from TikTokLive.types.events import CommentEvent
545-
##
546-
## client = TikTokLiveClient("@fadkeys_welfare_bidding")
547-
##
548-
##
549-
##
550-
## # created a signed url for http request to send a live message to tiktok
551-
##
552-
## async def sign_url(raw_url: str, session_id: str):
553-
## """
554-
##
555-
## You will need to create your OWN function to modify the HTTP request to your liking so that it passes TikTok Auth.
556-
## TikTokLive cannot and will not provide signatures, but if you want this functionality, it's here.
557-
##
558-
## :param raw_url: The URL that requires signing
559-
## :param session_id: The sessionid sending the message
560-
## :return: None
561-
##
562-
## """
563-
## # generate a signed url
564-
## signed_url: str = raw_url + (
565-
## f"&msToken={'wfRVE37020y77mqvBK-OKij3ghtSsaG1WVzkREKXymjJ9WJmWozhhS7XSyB5ZhVXquqOcAi9uRllk4Eh_bc2ql7GTf7V_Py09gu05plC0Zq70VcDj3r1bKeD-u5jnN538_VFqS0='}"
566-
## f"&X-Bogus={'DFSzywGL47bANy5htjG6wsXyYJlH'}"
567-
## f"&User-Agent={'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36'}"
568-
## f"&browserVersion={'5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36'}"
569-
## f"&browserName={'Mozilla'}"
570-
## f"&_signature={'_02B4Z6wo00001mCGiLQAAIDDQyemG.O51kpgpowAAPyq40'}"
571-
## )
572-
##
573-
## # You will need to supply your own headers
574-
## headers: dict = {
575-
## "Cookie": "ttwid=1%7CWmE5zijCzdsDvqBxWbhA8K0c8Aj3ku2pul-mJz2eQ0g%7C1689948120%7Cce10b6849f6bacc94c5acaf4e43d82f9414b301982d8cc08ca4ce890fad6cd13;",
576-
## **client._http.headers
577-
## }
578-
## return signed_url, headers
579-
##
580-
##
581-
## #@client.on("message")
582-
## async def on_ping(event: CommentEvent):
583-
## """
584-
## When someone runs the /ping command, choose how to react
585-
## :param event: Comment event
586-
## :return: None
587-
## """
588-
##
589-
## # # If not ping, return
590-
## # if event.comment.lower() != "/ping":
591-
## # return
592-
##
593-
## # Reply with Pong
594-
## reply: str = f"how are you?"
595-
## print(f"The bot will respond in chat with \"{reply}\"")
596-
##
597-
## await client.send_message(
598-
## text=reply,
599-
## sign_url_fn=sign_url,
600-
## session_id="d66beceff0b4513baba65ea6c265981b"
601-
## )
602-
## sys.exit()
603-
##
604-
## if __name__ == '__main__':
605-
## """
606-
## An example showing you how you can send comments to your live
607-
##
608-
## """
609-
## client.add_listener("comment", on_ping)
610-
## client.run()

0 commit comments

Comments
 (0)