aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Murphy <alec@checksum.fail>2017-05-29 00:10:11 -0400
committerAlec Murphy <alec@checksum.fail>2017-05-29 00:10:11 -0400
commit160af4171327d714a54fb470ebbd5112df142af3 (patch)
tree5c029eb938d4ece98a273b0daba49dd4f4e132c7
parente302f9efde902b69d19294e761778f50d250a972 (diff)
Fix for missing avatar
-rw-r--r--Crocodile.HC4
-rw-r--r--crocodile.py55
2 files changed, 30 insertions, 29 deletions
diff --git a/Crocodile.HC b/Crocodile.HC
index 3182e01..cca8362 100644
--- a/Crocodile.HC
+++ b/Crocodile.HC
@@ -26,7 +26,7 @@ U8 CROC_MSG[1024];
U0 CrocAvatar(CDoc *doc, U8 *author_id, U8 *avatar)
{
U8 *av_buffer=CAlloc(4096);
- if (StrCmp(avatar,"")==0) { return; };
+ if (StrCmp(avatar,"")==0 || StrCmp(avatar,"None")==0) { Free(av_buffer); return; };
U8 av_trunc[64];
U8 av_file[64];
StrCpy(av_trunc,avatar);
@@ -137,4 +137,4 @@ Sleep(100);
DocClear(discord_msgs->put_doc);
discord_msgloop = Spawn(&CrocUpdLoop);
- \ No newline at end of file
+
diff --git a/crocodile.py b/crocodile.py
index b91d78e..9c0df99 100644
--- a/crocodile.py
+++ b/crocodile.py
@@ -84,40 +84,41 @@ def CrocGetMsgs():
r_token = HGBD_PARAM_BUF[:HGBD_PARAM_BUF.find('\x00')]
r_chan_id = HGBD_PARAM_BUF[256:HGBD_PARAM_BUF.find('\x00',256)]
msgs_cnt = 0
+ ZeroParamBuf()
try:
croc_cmd = str(Crocodile.getchan_cmd)
croc_cmd = croc_cmd.replace('DISCORD_TOKEN',r_token)
croc_cmd = croc_cmd.replace('DISCORD_CHANNEL',r_chan_id + '/messages')
msgs_json = json.loads(subprocess.Popen(croc_cmd,shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE).communicate()[0])
msgs_cnt = len(msgs_json)
+ msg_ofs = BLK_SIZE
+ msgs_json.reverse()
+ for msg in msgs_json:
+ os.lseek(HGBD,msg_ofs,os.SEEK_SET)
+ os.write(HGBD, '\x00'*2048)
+ os.lseek(HGBD,msg_ofs,os.SEEK_SET)
+ os.write(HGBD,msg['id']+'\x00')
+ msg_ofs += 64
+ os.lseek(HGBD,msg_ofs,os.SEEK_SET)
+ os.write(HGBD,msg['timestamp'][:19].replace('T',' ')+'\x00')
+ msg_ofs += 64
+ os.lseek(HGBD,msg_ofs,os.SEEK_SET)
+ os.write(HGBD,msg['author']['username']+'\x00')
+ msg_ofs += 64
+ os.lseek(HGBD,msg_ofs,os.SEEK_SET)
+ os.write(HGBD,str(msg['author']['id'])+'\x00')
+ msg_ofs += 64
+ os.lseek(HGBD,msg_ofs,os.SEEK_SET)
+ os.write(HGBD,str(msg['author']['avatar'])+'\x00')
+ msg_ofs += 64
+ os.lseek(HGBD,msg_ofs,os.SEEK_SET)
+ os.write(HGBD,msg['content'].encode('utf8')+'\x00')
+ msg_ofs += 1024
+ os.lseek(HGBD,0,os.SEEK_SET)
+ os.write(HGBD,str(msgs_cnt))
except:
- pass
- ZeroParamBuf()
- os.lseek(HGBD,0,os.SEEK_SET)
- os.write(HGBD,str(msgs_cnt))
- msg_ofs = BLK_SIZE
- msgs_json.reverse()
- for msg in msgs_json:
- os.lseek(HGBD,msg_ofs,os.SEEK_SET)
- os.write(HGBD, '\x00'*2048)
- os.lseek(HGBD,msg_ofs,os.SEEK_SET)
- os.write(HGBD,msg['id']+'\x00')
- msg_ofs += 64
- os.lseek(HGBD,msg_ofs,os.SEEK_SET)
- os.write(HGBD,msg['timestamp'][:19].replace('T',' ')+'\x00')
- msg_ofs += 64
- os.lseek(HGBD,msg_ofs,os.SEEK_SET)
- os.write(HGBD,msg['author']['username']+'\x00')
- msg_ofs += 64
- os.lseek(HGBD,msg_ofs,os.SEEK_SET)
- os.write(HGBD,msg['author']['id']+'\x00')
- msg_ofs += 64
- os.lseek(HGBD,msg_ofs,os.SEEK_SET)
- os.write(HGBD,msg['author']['avatar']+'\x00')
- msg_ofs += 64
- os.lseek(HGBD,msg_ofs,os.SEEK_SET)
- os.write(HGBD,msg['content'].encode('utf8')+'\x00')
- msg_ofs += 1024
+ os.lseek(HGBD,0,os.SEEK_SET)
+ os.write(HGBD,str(0))
conn.send(chr(CROC_GETMSGS))
def CrocSendMsg():