From 0a3a644e622117a64a9e058b49df92e449ce4979 Mon Sep 17 00:00:00 2001 From: elkmaennchen Date: Sat, 28 Mar 2020 18:15:15 +0100 Subject: [PATCH] english translation --- README.md | 47 +++++++++++++++++++++++++++++++++++++++-- gitscord_webhook.php | 50 ++++++++++++++++++++++---------------------- 2 files changed, 70 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index d8db2a7..0acf8ab 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Définition des paramètres : * bot_name : nom du bot sur Discord (remplace le nom défini dans Discord) * bot_avatar : image de profil du bot sur Discord (remplace l'image défini dans Discord), mettre une URL absolue -Il suffit ensuite de mettre le fichier PHP (*gitscord_webhook.php*, mais vous pouvez le renommer à votre convenance) dans un des dossiers servis par votre serveur HTTP(S), avec le fichier *gitscord_webhook_config.json* (ne pas renommer, ou en changer le nom dans le script PHP). +Il suffit ensuite de mettre le fichier PHP (*gitscord_webhook.php*, mais vous pouvez le renommer à votre convenance) dans un des dossiers servis par votre serveur HTTP(S), avec le fichier *gitscord_webhook_config.json* juste a côté (ne pas renommer, ou changer le nom dans le script PHP également). Enfin dans Gitlab, menus "Settings" puis "Integrations" d'un projet, indiquer l'URL du fichier PHP et choisissez les événements à afficher dans Discord. @@ -93,4 +93,47 @@ Para soportar el desarrollo de este proyecto, puede particularmente abrir issues * los fallos de seguridad que nota (con el label *Security*) * ideas de nuevas funcionalidades (con el label *Feature*) -# GitScord webhook (English) \ No newline at end of file +# GitScord webhook (English) + +GitScord is a middleman webhook between Gitlab and Discord, in order to have nicer to read messages than messages auto-generated by Gitlab. + +## Features +GitScord use the whole formatting possibilities of Discord, to make the messages both complete and easily readable. + +Existing features : + * support commits, tags, issues, notes, merge requests + * multilingual + * control bot aspects in Discord + * 100% PHP, straightforward installation with few dependencies + +In development features : + * support job, pipeline, wikipage + * less verbose mode + +## Installation +### Requirement +GitScord is entirely written in PHP. As the *JSON* module is in PHPcore, the only requirement is to have installed PHP >= 5.2.0 or PHP >= 7, compiled with the *curl* module. + +The server on which is put the script have to be reachable in HTTP(S) from your Gitlab, and this server need to be able to make a HTTP(S) request to *discordapp.com*. + +### Configuration +First, create a webhook in the parameters of your Discord server (please refer to the help page on official Discord website if needed). + +Then create a configuration file *gitscord_webhook_config.json*. +You can find help in the example files *gitscord_webhook_config.json.exemple.full* and *gitscord_webhook_config.json.exemple.minimal*, which respectively contains the full parameters list and the compulsory parameters list. +Definition of the parameters : + * discord_url : address of the Discord-provided webhook + * language : language of messages sent by the bot, choose between en, es and fr + * bot_name : name of the bot on Discord (override the name set in Discord) + * bot_avatar : avatar image of the bot on Discord (override the image set in Discord), put an absolute URL + +Put the PHP file (*gitscord_webhook.php*, but you can rename it as you want) in a folder of your HTTP(S) server, with the file *gitscord_webhook_config.json* in the same folder (do not rename it, or change the name in the PHP script too). + +Finally, on Gitlab in menus "Settings" and "Integrations" of a project, put theURL of the PHP file and choose the event you need to notified of in Discord. + +## Contributions +To be involved in the development of this project, you can in particular open issues of Gitlab for : + * the bugs you noticed using it + * security problem you found (with the label *Security*) + * ideas of new features (with the label *Feature*) + diff --git a/gitscord_webhook.php b/gitscord_webhook.php index bac150e..5c7343e 100644 --- a/gitscord_webhook.php +++ b/gitscord_webhook.php @@ -1,6 +1,6 @@ "**An error occured with GitScord**\nPlease report in Issues tab on cr@ns gitlab (gitlab.crans.org/elkmaennchen/gitscord-webhook)\n".$message, 'username' => 'GitScord in fail')); +function send_error($url,$message="") { // showing an error on Discord chan + send_to_discord($url, array('content' => "**An error occurred with GitScord**\nPlease report in Issues tab on cr@ns Gitlab (gitlab.crans.org/elkmaennchen/gitscord-webhook)\n".$message, 'username' => 'GitScord in fail')); } // _layout functions : markdown and JSON encapsulation for Discord function push_layout($messageJSON,$JSON,$lang) { - $txt_ligne_push=["fr"=>'nouveau(x) commit(s)',"es"=>'nuevo(s) commit(s)',"en"=>' ',]; - $txt_title_push=["fr"=>'a push dans',"es"=>'hizo un push en',"en"=>' ',]; - $txt_add_push=["fr"=>'Ajoutés',"es"=>'Añadidos',"en"=>' ',]; - $txt_mod_push=["fr"=>'Modifiés',"es"=>'Modificados',"en"=>' ',]; - $txt_suppr_push=["fr"=>'Supprimés',"es"=>'Suprimidos',"en"=>' ',]; + $txt_ligne_push=["fr"=>'nouveau(x) commit(s)',"es"=>'nuevo(s) commit(s)',"en"=>'new commit(s)',]; + $txt_title_push=["fr"=>'a push dans',"es"=>'hizo un push en',"en"=>'pushed in',]; + $txt_add_push=["fr"=>'Ajoutés',"es"=>'Añadidos',"en"=>'Added',]; + $txt_mod_push=["fr"=>'Modifiés',"es"=>'Modificados',"en"=>'Modified',]; + $txt_suppr_push=["fr"=>'Supprimés',"es"=>'Suprimidos',"en"=>'Deleted',]; $messageJSON['content'] = $JSON['total_commits_count'].' '.$txt_ligne_push[$lang] ; $messageJSON['embeds'] = array(); for ($numCommit=$JSON['total_commits_count']-1; $numCommit>=0; $numCommit--) { @@ -123,8 +123,8 @@ function push_layout($messageJSON,$JSON,$lang) { } function tag_layout($messageJSON,$JSON,$lang) { - $txt_ligne_tag=["fr"=>'Nouveau tag',"es"=>'Nuevo tag',"en"=>' ',]; - $txt_title_tag=["fr"=>'a tagué un commit dans',"es"=>'hizo un tag en',"en"=>' ',]; + $txt_ligne_tag=["fr"=>'Nouveau tag',"es"=>'Nuevo tag',"en"=>'New tag',]; + $txt_title_tag=["fr"=>'a tagué un commit dans',"es"=>'hizo un tag en',"en"=>'tagged a commit in',]; $messageJSON['content'] = $txt_ligne_tag[$lang] ; $messageJSON['embeds'] = array(array('title'=> $txt_title_tag[$lang].' *'.$JSON['project']['name'].'*', 'description'=> $JSON['message'], @@ -135,10 +135,10 @@ function tag_layout($messageJSON,$JSON,$lang) { } function issue_layout($messageJSON,$JSON,$lang) { - $txt_ligne_issue=["fr"=>'Nouveau problème',"es"=>'Nuevo problema',"en"=>' ',]; - $txt_title_open_issue=["fr"=>'a ouvert une issue dans',"es"=>'abrió un asunto en',"en"=>' ',]; - $txt_title_update_issue=["fr"=>'a mis à jour une issue dans',"es"=>'actualizó un asunto en',"en"=>' ',]; - $txt_title_close_issue=["fr"=>'a fermé une issue dans',"es"=>'cierró un asunto en',"en"=>' ',]; + $txt_ligne_issue=["fr"=>'Nouveau problème',"es"=>'Nuevo problema',"en"=>'New issue',]; + $txt_title_open_issue=["fr"=>'a ouvert une issue dans',"es"=>'abrió un asunto en',"en"=>'opened an issue in',]; + $txt_title_update_issue=["fr"=>'a mis à jour une issue dans',"es"=>'actualizó un asunto en',"en"=>'modified an issue in',]; + $txt_title_close_issue=["fr"=>'a fermé une issue dans',"es"=>'cierró un asunto en',"en"=>'closed an issue in',]; if ($JSON['object_attributes']['action'] == "open") { $txt_title_issue=$txt_title_open_issue[$lang]; } @@ -158,8 +158,8 @@ function issue_layout($messageJSON,$JSON,$lang) { } function note_layout($messageJSON,$JSON,$lang) { - $txt_ligne_note=["fr"=>'Nouvelle note',"es"=>'Nueva note',"en"=>' ',]; - $txt_title_note=["fr"=>'a noté quelque chose dans',"es"=>'marcó algo en',"en"=>' ',]; + $txt_ligne_note=["fr"=>'Nouvelle note',"es"=>'Nueva note',"en"=>'New note',]; + $txt_title_note=["fr"=>'a noté quelque chose dans',"es"=>'marcó algo en',"en"=>'noted something in',]; $txt_object_name=""; if ($JSON['object_attributes']['noteable_type'] == "Issue") { $txt_object_name=$JSON['issue']['title']; @@ -180,10 +180,10 @@ function note_layout($messageJSON,$JSON,$lang) { } function MR_layout($messageJSON,$JSON,$lang) { - $txt_ligne_MR=["fr"=>'Nouvelle merge request',"es"=>'Nueva merge request',"en"=>' ',]; - $txt_open_action=["fr"=>'a ouvert une MR dans',"es"=>'abrió una MR en',"en"=>' ',]; - $txt_merge_action=["fr"=>'a mergé une MR dans',"es"=>'ejecutó una MR en',"en"=>' ',]; - $txt_unknown_action=["fr"=>'a modifié une MR dans',"es"=>'cambió una MR en',"en"=>' ',]; + $txt_ligne_MR=["fr"=>'Nouvelle merge request',"es"=>'Nueva merge request',"en"=>'New merge request',]; + $txt_open_action=["fr"=>'a ouvert une MR dans',"es"=>'abrió una MR en',"en"=>'opened a MR in',]; + $txt_merge_action=["fr"=>'a mergé une MR dans',"es"=>'ejecutó una MR en',"en"=>'merged a MR in',]; + $txt_unknown_action=["fr"=>'a modifié une MR dans',"es"=>'cambió una MR en',"en"=>'modified a MR in',]; if ($JSON['object_attributes']['action'] == "open") { $txt_action=$txt_open_action[$lang]; $txt_action_description=$JSON['object_attributes']['description']; @@ -194,9 +194,9 @@ function MR_layout($messageJSON,$JSON,$lang) { } else { $txt_action=$txt_unkown_action[$lang]; - $txt_action_description="*Problem with webhook, please report.*"; + $txt_action_description="*Problem with GitScord, please report.*"; } - $messageJSON['content'] = $txt_ligne_MR[$lang] ; + $messageJSON['content'] = $txt_ligne_MR[$lang]; $messageJSON['embeds'] = array(array('title'=> $txt_title_MR[$lang].' *'.$JSON['project']['name'].'*', 'description'=> "**".$JSON['object_attributes']['title']."**\n".$txt_action_description, 'url'=> $JSON['object_attributes']['url'],