Any Gitea users sending webhooks to Rocket.Chat? Share your scripts here

Let me start with my simple script, here’s the output

09%20PM

class Script {
  /**
   * @params {object} request
   */
  process_incoming_request({ request }) {
    var i_message; var message = ''; var text;
    repository = request.content['repository']['full_name'];
    
    for (i_message = 0; i_message < request.content.commits.length; i_message++) { 
      message += "[#"+request.content.commits[i_message]['id'].substring(0,10)+"]("+request.content.commits[i_message]['url']+")" + ': ' + request.content.commits[i_message]['message'];
    }

    if (i_message > 1) {
      text = i_message + ' commits pushed to ' + repository;
    } else {
      text = '1 commits pushed to ' + repository;
    }
    
    return {
      content:{
        text: text, 
         "attachments": [{
           "title": 'Compare All',
           "title_link": request.content['compare_url'],
           "text": message,
        }]
       }
    };
  }
}