From 83bdc01411c0d8e23d7c34ae1c2dd93eb946c1c6 Mon Sep 17 00:00:00 2001 From: Kim Brose <2803622+HarHarLinks@users.noreply.github.com> Date: Sat, 24 Feb 2024 15:04:40 +0100 Subject: [PATCH 1/3] Create samples/git.yml --- samples/git.yml | 120 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 samples/git.yml diff --git a/samples/git.yml b/samples/git.yml new file mode 100644 index 0000000..2c70053 --- /dev/null +++ b/samples/git.yml @@ -0,0 +1,120 @@ +templates: + any: + type: m.room.message + content: + msgtype: $${type} + body: '[$${1}/$${2}#$${3}]($${prefix}/$${1}/$${2}$${infix}$${3})' + format: org.matrix.custom.html + formatted_body: '$${1}/$${2}#$${3}' + + org: + type: m.room.message + content: + msgtype: $${type} + body: '[$${1}#$${2}]($${prefix}/$${org}/$${1}$${infix}$${2})' + format: org.matrix.custom.html + formatted_body: '$${1}#$${2}' + + project: + type: m.room.message + content: + msgtype: $${type} + body: '[$${project}$${1}]($${prefix}/$${org}$${project}$${infix}$${1})' + format: org.matrix.custom.html + formatted_body: '$${project}#$${1}' + +default_flags: +- ignorecase +antispam: + room: + max: 1 + delay: 1 + user: + max: 2 + delay: 1 + +rules: + # note that the order of the following rules is relevant, as they are evaluated top to bottom + # the order is generally by the `matches` regex from most specific to least (i.e. more wildcards) specific + + # matches some predefined repos that are not on the default hosted git service (see below) + some_codeberg: + matches: + - (matrix-community)/(graphics)\#([0-9]+) + - (imbev)/(simplematrixbotlib)\#([0-9]+) + template: any + variables: + type: m.notice + prefix: https://codeberg.org + infix: /issues/ + + # default service for specifically mentioned repos + # [a-zA-Z0-9\-_.] are the allowed project slug characters on GitHub + any_github: + matches: + - ([a-zA-Z0-9\-_.]+)/([a-zA-Z0-9\-_.]+)\#([0-9]+) + template: any + variables: + type: m.notice + prefix: https://github.com + infix: /pull/ + + # shortcut for project#issue that is not in the default org (and git service) (see below) + wrench_codeberg: + matches: + - (matrix-wrench)\#([0-9]+) + template: org + variables: + type: m.notice + prefix: https://gitlab.com + org: jaller94 + infix: /-/issues/ + + # shortcut for project#issue with an alias (which may also be in another than the default org) + # the actual project name is matrix-hookshot, given below, + # but this will also match hookshot#123 and autoexpand it for convenience + hookshot_alias_github: + matches: + - hookshot\#([0-9]+) + template: project + variables: + type: m.notice + prefix: https://github.com + org: matrix-org + project: matrix-hookshot + infix: /pull/ + + # mix and match of multiple settings + calendar_gitlab: + matches: + - calendar\#([0-9]+) + template: project + variables: + type: m.notice + prefix: https://gitlab.com + org: uhoreg + project: matrix_daily_calendar + infix: /-/issues/ + + # shortcut for project#issue, which will assume the given org + maubot_github: + matches: + - ([a-zA-Z0-9\-_.]+)\#([0-9]+) + template: org + variables: + type: m.notice + prefix: https://github.com + org: maubot + infix: /pull/ + + # shortcut for #issue, which will assume the given project + reactbot_github: + matches: + - \#([0-9]+) + template: project + variables: + type: m.notice + prefix: https://github.com + org: maubot + project: reactbot + infix: /pull/ From 746be780cc908344c51965eb82d5202816fa8aa9 Mon Sep 17 00:00:00 2001 From: Kim Brose <2803622+HarHarLinks@users.noreply.github.com> Date: Sat, 24 Feb 2024 15:06:40 +0100 Subject: [PATCH 2/3] Update README.md with samples/git.yaml --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 682b881..4323a8d 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ A [maubot](https://github.com/maubot/maubot) that responds to messages that matc * [samples/nitter.yaml](samples/nitter.yaml) has an example of matching tweet links and responding with a corresponding nitter.net link. * [samples/thread.yaml](samples/thread.yaml) has an example of replying in a thread. +* [samples/git.yaml](samples/git.yaml) contains a bot that will expand GitHub/GitLab/etc + issue/PR mentions to links including multiple configuration examples. ## Config format ### Templates From dbea869374c1b2f461f9c8c4d57436d317ad1d2d Mon Sep 17 00:00:00 2001 From: Kim Brose <2803622+HarHarLinks@users.noreply.github.com> Date: Sat, 24 Feb 2024 15:07:03 +0100 Subject: [PATCH 3/3] Rename samples/git.yml to samples/git.yaml --- samples/{git.yml => git.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename samples/{git.yml => git.yaml} (100%) diff --git a/samples/git.yml b/samples/git.yaml similarity index 100% rename from samples/git.yml rename to samples/git.yaml