Created
June 3, 2019 10:14
-
-
Save remisarrailh/55b5a7d29a985ee62dac818cded01946 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "e50cb0c0.87ac9", | |
"type": "tab", | |
"label": "Bot Discord", | |
"disabled": false, | |
"info": "" | |
}, | |
{ | |
"id": "64569321.c6707c", | |
"type": "discordSendMessage", | |
"z": "e50cb0c0.87ac9", | |
"name": "Envoi sur Discord", | |
"channel": "", | |
"token": "", | |
"x": 1290, | |
"y": 400, | |
"wires": [] | |
}, | |
{ | |
"id": "83c04ba9.69b57", | |
"type": "inject", | |
"z": "e50cb0c0.87ac9", | |
"name": "Toutes les heures entre 10h et 00h", | |
"topic": "", | |
"payload": "", | |
"payloadType": "str", | |
"repeat": "", | |
"crontab": "0 10-23 * * *", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 210, | |
"y": 240, | |
"wires": [ | |
[ | |
"90a28e1d.c93698" | |
] | |
] | |
}, | |
{ | |
"id": "90a28e1d.c93698", | |
"type": "http request", | |
"z": "e50cb0c0.87ac9", | |
"name": "Récupération HTTP ical", | |
"method": "GET", | |
"ret": "txt", | |
"paytoqs": false, | |
"url": "", | |
"tls": "", | |
"proxy": "", | |
"x": 510, | |
"y": 240, | |
"wires": [ | |
[ | |
"1a2c9ae8.e9d5b5" | |
] | |
] | |
}, | |
{ | |
"id": "1a2c9ae8.e9d5b5", | |
"type": "function", | |
"z": "e50cb0c0.87ac9", | |
"name": "Convertir en format lisible et copie dans flow.new_calendrier ", | |
"func": "// Récupération de la description\ndescription_raw = msg.payload.split(\"SUMMARY:\");\nvar description = [];\ndescription_raw.forEach(function (item, index) {\n if(index !== 0){\n description.push(item.split(\"\\n\")[0].trim());\n }\n});\n\n// Récupération de la date\ndate_raw = msg.payload.split(\"DTSTART;\");\nvar message_complet = \"Voici la liste des initiations et ateliers:\\n------------------------\\n\";\n\ndate_raw.forEach(function (item, index) {\n if(index !== 0){\n\n icalStr = item.split(\"\\n\")[0].trim();\n icalStr = item.split(\":\")[1].trim();\n\n //Conversion du temps\n var strAnnee = icalStr.substr(0,4);\n var strMois = icalStr.substr(4,2);\n var strJour = icalStr.substr(6,2);\n \n //Transformation date en jour\n strDate = strMois + \"/\" + strJour + \"/\" + strAnnee;\n var days = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'];\n strJourEntier = days[new Date(strDate).getDay()];\n\n //Transformation date en mois\n var month = ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'];\n strMoisEntier = month[new Date(strDate).getMonth()]; \n message_complet += description[index-1] + \" --> \" + strJourEntier + \" \" + strJour + \" \" + strMoisEntier + \"\\n\";\n }\n});\n\n//Fin du message\nmessage_complet += \"\\n Plus d'informations sur https://labsud.org/agenda/\";\n\n//Copie du message dans la variable new_calendrier\nflow.set(\"new_calendrier\", message_complet);\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 900, | |
"y": 240, | |
"wires": [ | |
[ | |
"56a42c0a.67eca4" | |
] | |
] | |
}, | |
{ | |
"id": "bae2b4d5.2d0e58", | |
"type": "switch", | |
"z": "e50cb0c0.87ac9", | |
"name": "Différence entre ICAL distant <--> ICAL local ?", | |
"property": "payload", | |
"propertyType": "msg", | |
"rules": [ | |
{ | |
"t": "neq", | |
"v": "new_calendrier", | |
"vt": "flow" | |
} | |
], | |
"checkall": "true", | |
"repair": false, | |
"outputs": 1, | |
"x": 620, | |
"y": 380, | |
"wires": [ | |
[ | |
"1328f9ed.07ba7e" | |
] | |
] | |
}, | |
{ | |
"id": "1e2b2d02.a824ab", | |
"type": "file", | |
"z": "e50cb0c0.87ac9", | |
"name": "Ecrit calendrier.xml", | |
"filename": "/home/pi/calendrier.xml", | |
"appendNewline": true, | |
"createDir": false, | |
"overwriteFile": "true", | |
"x": 1290, | |
"y": 340, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "ae937e21.53e7f", | |
"type": "file in", | |
"z": "e50cb0c0.87ac9", | |
"name": "Lire calendrier.xml", | |
"filename": "/home/pi/calendrier.xml", | |
"format": "utf8", | |
"chunk": false, | |
"sendError": false, | |
"x": 150, | |
"y": 380, | |
"wires": [ | |
[ | |
"751939ce.a9c138" | |
] | |
] | |
}, | |
{ | |
"id": "1328f9ed.07ba7e", | |
"type": "change", | |
"z": "e50cb0c0.87ac9", | |
"name": "Changer le payload vers nouvelle version", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "new_calendrier", | |
"tot": "flow" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 980, | |
"y": 380, | |
"wires": [ | |
[ | |
"1e2b2d02.a824ab", | |
"64569321.c6707c" | |
] | |
] | |
}, | |
{ | |
"id": "751939ce.a9c138", | |
"type": "function", | |
"z": "e50cb0c0.87ac9", | |
"name": "Bug", | |
"func": "msg.payload = msg.payload.substring(0, msg.payload.length - 1);\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 370, | |
"y": 380, | |
"wires": [ | |
[ | |
"bae2b4d5.2d0e58" | |
] | |
] | |
}, | |
{ | |
"id": "56a42c0a.67eca4", | |
"type": "fs-ops-access", | |
"z": "e50cb0c0.87ac9", | |
"name": "Calendrier.xml existe ?", | |
"path": "/home/pi/", | |
"pathType": "str", | |
"filename": "calendrier.xml", | |
"filenameType": "str", | |
"read": true, | |
"write": true, | |
"throwerror": false, | |
"x": 310, | |
"y": 300, | |
"wires": [ | |
[ | |
"ae937e21.53e7f" | |
], | |
[ | |
"65b65ab2.22b9fc" | |
] | |
] | |
}, | |
{ | |
"id": "bf683c1d.d1e7b", | |
"type": "file", | |
"z": "e50cb0c0.87ac9", | |
"name": "Créer calendrier.xml", | |
"filename": "/home/pi/calendrier.xml", | |
"appendNewline": true, | |
"createDir": false, | |
"overwriteFile": "true", | |
"x": 880, | |
"y": 300, | |
"wires": [ | |
[ | |
"ae937e21.53e7f" | |
] | |
] | |
}, | |
{ | |
"id": "65b65ab2.22b9fc", | |
"type": "change", | |
"z": "e50cb0c0.87ac9", | |
"name": "Changer en vide", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "payload", | |
"pt": "msg", | |
"to": "", | |
"tot": "str" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 590, | |
"y": 300, | |
"wires": [ | |
[ | |
"bf683c1d.d1e7b" | |
] | |
] | |
}, | |
{ | |
"id": "b6039bd1.38b3c8", | |
"type": "fs-ops-delete", | |
"z": "e50cb0c0.87ac9", | |
"name": "", | |
"path": "/home/pi", | |
"pathType": "str", | |
"filename": "calendrier.xml", | |
"filenameType": "str", | |
"x": 330, | |
"y": 500, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "6951a561.82df14", | |
"type": "inject", | |
"z": "e50cb0c0.87ac9", | |
"name": "Reset Calendrier", | |
"topic": "", | |
"payload": "", | |
"payloadType": "str", | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"x": 160, | |
"y": 500, | |
"wires": [ | |
[ | |
"b6039bd1.38b3c8" | |
] | |
] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment