1
1
import os
2
2
import json
3
+ import configparser
3
4
4
5
import asyncio
5
6
import websockets
@@ -34,69 +35,60 @@ async def setup(websocket):
34
35
json_file .write (json .dumps (data ))
35
36
json_file .close ()
36
37
print ("Saving finished" )
37
- elif (data ['authenticationkeytwitch' ] == "" ):
38
- print ('Error With Twitch Token' )
39
- print ('Fetching New Tokens...' )
40
- print ("click authorize, copy the token from access_token=, till the & seperator" )
41
- webbrowser .open (link )
42
- twauthtoken = input ()
43
- data ["authenticationkeytwitch" ] = twauthtoken
44
- json_file .close ()
45
- json_file = open ('token.json' , "w" )
46
- json_file .write (json .dumps (data ))
47
- json_file .close ()
48
38
else :
49
39
json_file .close ()
50
40
else :
51
41
print ('Fetching New Tokens...' )
52
42
authtoken = await token (websocket )
53
43
print (authtoken )
54
44
print ('Saving authtoken for Future Use...' )
55
- print ("click authorize, copy the token from access_token=, till the & seperator" )
56
- webbrowser .open (link )
57
- twauthtoken = input ()
58
45
with open ('token.json' , "w" ) as json_file :
59
46
jsonfilecon = {
60
47
"chatspeed" : 0.1 ,
61
48
"authenticationkey" : authtoken ,
62
- "authenticationkeytwitch" : twauthtoken ,
63
- "data" :{
64
- "!spin" : "spin(vtubestudio,x,y,s)" ,
65
- "!reset" : "mdmv(vtubestudio,0.2,False,0,0,0,-76)" ,
66
- "!rainbow" : "rainbow(vtubestudio)" }
49
+ "authenticationkeytwitch" : ""
67
50
}
68
51
json_file .write (json .dumps (jsonfilecon ))
69
52
json_file .close ()
70
53
await authen (websocket ,authtoken )
71
-
54
+ if os .path .exists ('commands.ini' ):
55
+ config = configparser .ConfigParser ()
56
+ cmm = config .read ('commands.ini' )
57
+ else :
58
+ config = configparser .ConfigParser ()
59
+ with open ('commands.ini' , "w" ) as configfile :
60
+ config ['COMMANDS' ] = {
61
+ "!spin" : "spin(websocket,x,y,s)" ,
62
+ "!reset" : "mdmv(websocket,0.2,False,0,0,0,-76)" ,
63
+ "!rainbow" : "rainbow(websocket)"
64
+ }
65
+ config .write (configfile )
72
66
data = json .load (open ('token.json' ))
73
-
67
+ json_file . close ()
74
68
###############################
75
69
# command auto generation #
76
70
###############################
77
71
mdls = await listvtsmodel (websocket )
78
72
runs = mdls ["data" ]["numberOfModels" ]
79
73
i = 0
80
- for key in data [ "data" ]:
74
+ for key in config [ 'COMMANDS' ]:
81
75
i += 1
82
76
nmumm = runs - i
83
77
if i < nmumm :
84
- for i in range (runs ):
85
- ff = mdls ["data" ]["availableModels" ][i ]["modelName" ]
86
- gg = mdls ["data" ]["availableModels" ][i ]["modelID" ]
87
- name = "!" + ff
88
- mdss = mdch .__name__ + "(" + "vtubestudio" + ",'" + str (gg )+ "')"
89
- data ["data" ][name ] = mdss
90
- json_file .close ()
91
- json_file = open ('token.json' , "w" )
92
- json_file .write (json .dumps (data ))
93
- json_file .close ()
78
+ with open ('commands.ini' , "w" ) as configfile :
79
+ for i in range (runs ):
80
+ ff = mdls ["data" ]["availableModels" ][i ]["modelName" ]
81
+ gg = mdls ["data" ]["availableModels" ][i ]["modelID" ]
82
+ name = "!" + ff
83
+ mdss = mdch .__name__ + "(" + "websocket" + ",'" + str (gg )+ "')"
84
+ config ['COMMANDS' ][name ] = mdss
85
+ config .write (configfile )
94
86
###############################
95
87
# command auto generation end #
96
88
###############################
97
89
print ("Successfully Loaded" )
98
90
print ("Detected Commands" )
99
- for key in data [ "data" ]:
91
+ for key in config [ 'COMMANDS' ]:
100
92
print (key )
101
93
print ("type your streamid and press enter" )
102
94
op = input ("do you want to use [1]Youtube chat, [2]Twitch chat " )
@@ -105,6 +97,16 @@ async def setup(websocket):
105
97
op = input ("input streamid " )
106
98
chat = LiveChat (video_id = op )
107
99
elif (op == "2" ):
100
+ if (data ['authenticationkeytwitch' ] == '' ):
101
+ print ("click authorize, copy the token from access_token=, till the & seperator" )
102
+ webbrowser .open (link )
103
+ twauthtoken = input ()
104
+ with open ('token.json' , "w" ) as json_file :
105
+ data ["authenticationkeytwitch" ] = twauthtoken
106
+ json_file .write (json .dumps (data ))
107
+ json_file .close ()
108
+ data = json .load (open ('token.json' ))
109
+ json_file .close ()
108
110
ttv = True
109
111
chnm = input ("input channel name " )
110
- return [yt ,ttv ,data ,chat ,chnm ]
112
+ return [yt ,ttv ,data ,chat ,chnm , config ]
0 commit comments