bypass deleted messages (or rather messages without content)
This commit is contained in:
parent
10209348b3
commit
eef6224007
1 changed files with 20 additions and 19 deletions
|
@ -129,28 +129,29 @@ class ChannelMonitor(threading.Thread):
|
||||||
if msg.source.id == app.config['PNUTCLIENT_ID']:
|
if msg.source.id == app.config['PNUTCLIENT_ID']:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
user = self.generate_matrix_id(msg.user.username)
|
if 'content' in msg:
|
||||||
text = msg.content.text + "\n"
|
user = self.generate_matrix_id(msg.user.username)
|
||||||
# dt = datetime.datetime.strptime(msg.created_at, "%Y-%m-%dT%H:%M:%SZ")
|
text = msg.content.text + "\n"
|
||||||
dt = msg.created_at
|
# dt = datetime.datetime.strptime(msg.created_at, "%Y-%m-%dT%H:%M:%SZ")
|
||||||
ts = time.mktime(dt.timetuple())
|
dt = msg.created_at
|
||||||
|
ts = time.mktime(dt.timetuple())
|
||||||
|
|
||||||
for lnk in msg.content.entities.links:
|
for lnk in msg.content.entities.links:
|
||||||
text += "\n"
|
text += "\n"
|
||||||
if 'title' in lnk:
|
if 'title' in lnk:
|
||||||
text += lnk.title + "\n"
|
text += lnk.title + "\n"
|
||||||
if 'link' in lnk:
|
if 'link' in lnk:
|
||||||
text += lnk.link + "\n"
|
text += lnk.link + "\n"
|
||||||
|
|
||||||
for raw in msg.raw:
|
for raw in msg.raw:
|
||||||
if raw.type == 'io.pnut.core.oembed':
|
if raw.type == 'io.pnut.core.oembed':
|
||||||
if 'title' in raw.value:
|
if 'title' in raw.value:
|
||||||
text += raw.value.title + "\n"
|
text += raw.value.title + "\n"
|
||||||
if 'url' in raw.value:
|
if 'url' in raw.value:
|
||||||
text += raw.value.url + "\n"
|
text += raw.value.url + "\n"
|
||||||
|
|
||||||
# queue the message in reverse order (because of how pnut returns the messages)
|
# queue the message in reverse order (because of how pnut returns the messages)
|
||||||
pqueue.insert(0, {'user':user,'text':text,'ts':ts,'msgid':msg.id,'puser':msg.user.username,'chan':room.pnut_chan})
|
pqueue.insert(0, {'user':user,'text':text,'ts':ts,'msgid':msg.id,'puser':msg.user.username,'chan':room.pnut_chan})
|
||||||
|
|
||||||
# update the last message id
|
# update the last message id
|
||||||
if len(messages) > 0:
|
if len(messages) > 0:
|
||||||
|
|
Loading…
Reference in a new issue