!BdLmuYxxJLTcSOjoxj:matrix.org

Admin' of Matrix Using I.E.: Bash Scripting, cURL, JSON, et cetera. ☞ ؟⸮UNOFFICIAL⸮؟ – Self Support Community for community self support.

78 Members
Depositary workgroup for some good code snippets that get things done in Matrix rooms and Homeservers, despite lag and GUI client freezing¦hanging, from ye ole terminal emulated command prompt. ¶Aimed at intermediate skilled practicioners. ¶Kindly prefer POST over GET method as appropriate, where putting your access_token in a URL/URL that leaves the browser is not smart. ¶Get a cli on that mobile! • Try to post files that Matrix clients may read natively. • We should have a list of all working Event Types i.e. m.room.power_levels . • https://web.archive.org/web/20180712100113/https://gist.github.com/RickCogley/69f430d4418ae5498e8febab44d241c9 • https://matrix.org/docs/api/client-server/ • https://github.com/anoadragon453/matrix-scripts • https://en.wiktionary.org/wiki/depositary http://grammarist.com/usage/depository-repository/ https://en.wiktionary.org/wiki/depository21 Servers

Load older messages


SenderMessageTime
16 Jan 2022
@gregfro:nitro.chatcrab fog changed their display name from gregfro to JJ11013.14:59:47
@gregfro:nitro.chatcrab fog changed their display name from JJ11013 to crab fog.15:00:29
26 Jan 2022
@skobido:matrix.orgskobido joined the room.23:52:38
18 Feb 2022
@delta2.o.1:matrix.orgdelta joined the room.06:25:08
8 Mar 2022
@silly_rabbit_run:matrix.orgsilly_rabbit_run joined the room.18:20:55
9 Mar 2022
@bonniemel:matrix.orgBonnieClaire joined the room.07:27:28
30 Mar 2022
@amewzing:matrix.orgamewzing joined the room.04:10:29
2 Apr 2022
@ks684pbfgz:matrix.orgks684pbfgz joined the room.13:17:56
7 Apr 2022
@funkyf00l:matrix.orgF F joined the room.16:17:02
18 Apr 2022
@ruanime:matrix.orgruanime joined the room.06:37:31
@wybpip:matrix.org@wybpip:matrix.org joined the room.09:10:36
@wybpip:matrix.org@wybpip:matrix.org left the room.09:10:37
1 May 2022
@wybpip:matrix.org@wybpip:matrix.org joined the room.19:14:31
@wybpip:matrix.org@wybpip:matrix.org left the room.19:14:32
6 May 2022
@newchair:matrix.org@newchair:matrix.org joined the room.00:18:34
@newchair:matrix.org@newchair:matrix.org

If I have data like this:

{
  "key": "2022-05-1",
  "value": {
    "Fajr": "4:51 %am%",
    "Duha": "6:15 %am%",
    "Dhuhr": "1:13 %pm%",
    "Asr": "5:04 %pm%",
    "Maghrib": "8:11 %pm%",
    "Isha": "9:36 %pm%"
  }
}
{
  "key": "2022-05-2",
  "value": {
    "Fajr": "4:49 %am%",
    "Duha": "6:14 %am%",
    "Dhuhr": "1:13 %pm%",
    "Asr": "5:04 %pm%",
    "Maghrib": "8:12 %pm%",
    "Isha": "9:37 %pm%"
  }
}

how can I convert it to:

REM 2022-05-1 AT 4:51AM MSG Fajr
REM 2022-05-1 AT 6:15AM MSG Duha
REM 2022-05-1 AT 1:13PM MSG Dhuhar
REM 2022-05-1 AT 5:04PM MSG Asr
REM 2022-05-1 AT 8:11PM MSG Maghrib
REM 2022-05-1 AT 9:36AM MSG Isha
REM 2022-05-2 AT 4:49AM MSG Fajr
REM 2022-05-2 AT 6:14AM MSG Duha
...
...

using jq

00:39:45
@cheako:matrix.org@cheako:matrix.orgppl are going to hate this suggestion, but it looks like an awk problem to me.00:49:54
@newchair:matrix.org@newchair:matrix.orgawk is fine too idc I just thought jq would be easier bcs its json03:11:38
7 May 2022
@newchair:matrix.org@newchair:matrix.org

I ended up doing it with python

#!/usr/bin/env python

import sys
import requests
import json

params = {
        'user_ip': requests.get('http://ifconfig.so').text,
        'show_entire_month': '1'
}

response = requests.get('http://www.islamicfinder.us/index.php/api/prayer_times', params=params)
data = json.loads(response.text)['results']

reminders = ""
for date in data:
    for rem in data[date]:
        time = data[date][rem].replace(str([c for c in '% ']), '').upper()
        reminders += f"REM {date} AT {time} MSG {rem} time %2\n"

try:
    with open(sys.argv[1], 'w') as f:
        f.write(reminders)
except:
    print(reminders, end="")
21:00:37
9 May 2022
@vidaldf:matrix.org@vidaldf:matrix.org joined the room.03:36:22
@vidaldf:matrix.org@vidaldf:matrix.org left the room.03:40:43
18 May 2022
@akc3n:grapheneos.org@akc3n:grapheneos.org joined the room.02:42:53
3 Jun 2022
@_neb_wikipedia:matrix.org@_neb_wikipedia:matrix.org 20:37:40
4 Jun 2022
@fomapan:matrix.orgfomapan joined the room.21:24:37
14 Jun 2022
@sblotgq067:matrix.org@sblotgq067:matrix.org joined the room.06:32:35
15 Jun 2022
@sblotgq067:matrix.org@sblotgq067:matrix.org left the room.10:10:28
16 Jun 2022
@z4lin:matrix.org@z4lin:matrix.org joined the room.16:00:54
20 Jun 2022
@better_sleeping:converser.eu@better_sleeping:converser.eu joined the room.20:43:03
@better_sleeping:converser.eu@better_sleeping:converser.eu left the room.20:43:28
26 Jun 2022
@z4lin:matrix.org@z4lin:matrix.org changed their display name from zyyylj to no xd challenge.20:23:27

Show newer messages


Back to Room ListRoom Version: