From 1dee3c949d7118fba8e23b79ab86e50ebd995b6a Mon Sep 17 00:00:00 2001 From: Canorus Date: Fri, 7 Dec 2018 11:01:29 +0900 Subject: [PATCH] 1.0-61 - fixed toot ending with exclamation mark not taking parameter. --- README.md | 4 ++-- toot.py | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1645d79..bdea4eb 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,8 @@ Original repository is removed because I found out a file contains my login cred ### Todo -- [ ] Toot ending with exclamation mark. This is **urgent** -- [x] `reply` to notification hmm +- [x] ~~Toot ending with exclamation mark. This is **urgent**~~ fixed on 1.0-61 +- [x] ~~`mreply` to notification hmm~~ - [ ] `-web` - [x] ~~Contents warning message~~ - [ ] multiple accounts diff --git a/toot.py b/toot.py index af9749c..9c21e88 100644 --- a/toot.py +++ b/toot.py @@ -34,11 +34,9 @@ def clipboard_image(): try: toot_sp = re.compile(" !.*?:.?").split(toot) - print(toot_sp) - toot_split = re.findall('!.*?:',toot) + toot_split = re.findall(' !.*?:',toot) for i in range(len(toot_split)): - toot_split[i] = toot_split[i][1:-1] - print(toot_split) + toot_split[i] = toot_split[i][2:-1] toot_split.insert(0,'status') except: # if finding param breaks @@ -74,10 +72,11 @@ def clipboard_image(): for i in range(len(toot_sp)): hd[toot_split[i]] = unicodedata.normalize('NFC',toot_sp[i]) -if 'prev' in toot_sp: +if 'prev' in toot_split: account_id = requests.get(instance+'/api/v1/accounts/verify_credentials',headers=status_h).json()['id'] + #print(requests.get(instance+'/api/v1/accounts/verify_credentials',headers=status_h).json()) prev_status = requests.get(instance+'/api/v1/accounts/'+account_id+'/statuses',headers=status_h).json()[0]['id'] - hd['in_reply_to_id'] = prev_status + hd['in_reply_to_id']=prev_status if 'clipboard' in toot_split: media_id = '' @@ -88,5 +87,11 @@ def clipboard_image(): del hd['cb'] hd['media_ids[]']=media_id +if 'in_reply_to_id' in toot_split and 'silent' not in toot_split: + import json + who_reply_to = json.loads(requests.get(instance+'/api/v1/statuses/'+hd['in_reply_to_id']).content.decode('utf-8'))['account']['acct'] + hd['status'] += ' @'+who_reply_to + +#print('hd is '+str(hd)) st = requests.post(instance+'/api/v1/statuses',data=hd,headers=status_h) print(st.json())