Skip to content
This repository was archived by the owner on Aug 15, 2022. It is now read-only.

Commit 34d02e3

Browse files
committed
Fix #39
1 parent 349cc95 commit 34d02e3

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

ItsAGramLive/ItsAGramLive.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,14 @@ def __init__(self, username='', password=''):
6767
parser.add_argument("-proxy", type=str, help="Proxy format - user:password@ip:port", default=None)
6868
args = parser.parse_args()
6969

70+
username = args.username
71+
password = args.password
72+
7073
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'))
7275
self.device_id = self.generate_device_id(m.hexdigest())
7376

74-
self.set_user(username=args.username, password=args.password)
77+
self.set_user(username=username, password=password)
7578

7679
def set_user(self, username, password):
7780
self.username = username
@@ -282,6 +285,13 @@ def start(self):
282285
elif cmd == 'comments':
283286
self.get_comments()
284287

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+
285295
elif cmd[:4] == 'chat':
286296
to_send = cmd[5:]
287297
if to_send:
@@ -375,6 +385,7 @@ def send_comment(self, msg):
375385
if self.send_request("live/{}/comment/".format(self.broadcast_id), post=self.generate_signature(data)):
376386
if self.LastJson['status'] == 'ok':
377387
return True
388+
return False
378389

379390
def create_broadcast(self):
380391
data = json.dumps({'_uuid': self.uuid,
@@ -499,3 +510,22 @@ def get_comments(self):
499510
print(f"{comment['user']['username']} has posted a new comment: {comment['text']}")
500511
else:
501512
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

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setuptools.setup(
1212
name='ItsAGramLive',
13-
version='1.4.4',
13+
version='1.4.5',
1414
packages=setuptools.find_packages(),
1515
url='https://github.com/harrypython/itsagramlive',
1616
license='GPL-3.0',

0 commit comments

Comments
 (0)