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 diff --git a/samples/git.yaml b/samples/git.yaml new file mode 100644 index 0000000..2c70053 --- /dev/null +++ b/samples/git.yaml @@ -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/