| … | … | @@ -134,6 +134,7 @@ bogbot.add = async (msg) => { |
| 134 | 134 | if (!log.includes(hash)) { |
| 135 | 135 | log.push(hash) |
| 136 | 136 | newMessages = true |
| 137 | sort = true |
| 137 | 138 | } |
| 138 | 139 | } |
| 139 | 140 | } |
| … | … | @@ -149,3 +150,36 @@ bogbot.human = async (ts) => { |
| 149 | 150 | bogbot.visual = async (pubkey) => { |
| 150 | 151 | return vb(decode(pubkey), 256) |
| 151 | 152 | } |
| 153 | |
| 154 | let sort = true |
| 155 | |
| 156 | setInterval(async () => { |
| 157 | if (sort) { |
| 158 | const newArray = [] |
| 159 | |
| 160 | await Promise.all(log.map(async (hash) => { |
| 161 | const obj = { |
| 162 | hash, |
| 163 | sig: await bogbot.find(hash) |
| 164 | } |
| 165 | obj.opened = await bogbot.open(obj.sig) |
| 166 | console.log(obj) |
| 167 | obj.ts = obj.opened.substring(0, 13) |
| 168 | newArray.push(obj) |
| 169 | })) |
| 170 | |
| 171 | await newArray.sort((a,b) => a.ts - b.ts) |
| 172 | console.log(newArray) |
| 173 | |
| 174 | const newLog = [] |
| 175 | |
| 176 | await newArray.forEach(msg => { |
| 177 | newLog.push(msg.hash) |
| 178 | }) |
| 179 | |
| 180 | console.log(newLog) |
| 181 | log = newLog |
| 182 | newMessages = true |
| 183 | sort = false |
| 184 | } |
| 185 | }, 20000) |