@@ -67,11 +67,14 @@ def __init__(self, username='', password=''):
67
67
parser .add_argument ("-proxy" , type = str , help = "Proxy format - user:password@ip:port" , default = None )
68
68
args = parser .parse_args ()
69
69
70
+ username = args .username
71
+ password = args .password
72
+
70
73
m = hashlib .md5 ()
71
- m .update (args . username .encode ('utf-8' ) + args . password .encode ('utf-8' ))
74
+ m .update (username .encode ('utf-8' ) + password .encode ('utf-8' ))
72
75
self .device_id = self .generate_device_id (m .hexdigest ())
73
76
74
- self .set_user (username = args . username , password = args . password )
77
+ self .set_user (username = username , password = password )
75
78
76
79
def set_user (self , username , password ):
77
80
self .username = username
@@ -282,6 +285,13 @@ def start(self):
282
285
elif cmd == 'comments' :
283
286
self .get_comments ()
284
287
288
+ elif cmd [:11 ] == 'pin comment' :
289
+ to_send = cmd [12 :]
290
+ if to_send :
291
+ self .pin_comment (to_send )
292
+ else :
293
+ print ('usage: chat <text to chat>' )
294
+
285
295
elif cmd [:4 ] == 'chat' :
286
296
to_send = cmd [5 :]
287
297
if to_send :
@@ -375,6 +385,7 @@ def send_comment(self, msg):
375
385
if self .send_request ("live/{}/comment/" .format (self .broadcast_id ), post = self .generate_signature (data )):
376
386
if self .LastJson ['status' ] == 'ok' :
377
387
return True
388
+ return False
378
389
379
390
def create_broadcast (self ):
380
391
data = json .dumps ({'_uuid' : self .uuid ,
@@ -499,3 +510,22 @@ def get_comments(self):
499
510
print (f"{ comment ['user' ]['username' ]} has posted a new comment: { comment ['text' ]} " )
500
511
else :
501
512
print ("There is no comments." )
513
+
514
+ def pin_comment (self , to_send ):
515
+ if self .send_comment (msg = to_send ):
516
+ if self .send_request ("live/{}/get_comment/" .format (self .broadcast_id )):
517
+ data = json .dumps (
518
+ {
519
+ "_csrftoken" : self .token ,
520
+ "_uid" : self .username_id ,
521
+ "_uuid" : self .uuid ,
522
+ "comment_id" : self .LastJson ['comments' ][- 1 ].get ("pk" )
523
+ })
524
+ if self .send_request (endpoint = 'live/{}/pin_comment/' .format (self .broadcast_id ),
525
+ post = self .generate_signature (data )):
526
+ print ('Live Posted to Story!' )
527
+ self .unmute_comment ()
528
+ return True
529
+
530
+ self .unmute_comment ()
531
+ return False
0 commit comments