mirror of
https://github.com/pinpox/gitea-matrix-bot
synced 2024-11-22 19:31:58 +01:00
Fix and flakify
This commit is contained in:
parent
f5fa9e7200
commit
740048e8cf
26
flake.lock
Normal file
26
flake.lock
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1689192006,
|
||||||
|
"narHash": "sha256-QM0f0d8oPphOTYJebsHioR9+FzJcy1QNIzREyubB91U=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "2de8efefb6ce7f5e4e75bdf57376a96555986841",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
56
flake.nix
Normal file
56
flake.nix
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
description = "A bot to post gitea events to a matrix channel";
|
||||||
|
|
||||||
|
# Nixpkgs / NixOS version to use.
|
||||||
|
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs }:
|
||||||
|
let
|
||||||
|
|
||||||
|
# System types to support.
|
||||||
|
supportedSystems =
|
||||||
|
[ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
|
||||||
|
|
||||||
|
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
|
||||||
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||||
|
|
||||||
|
# Nixpkgs instantiated for supported system types.
|
||||||
|
nixpkgsFor = forAllSystems (system:
|
||||||
|
import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ self.overlays.default ];
|
||||||
|
});
|
||||||
|
in
|
||||||
|
{
|
||||||
|
|
||||||
|
# A Nixpkgs overlay.
|
||||||
|
overlays.default = final: prev: {
|
||||||
|
gitea-matrix-bot = with final;
|
||||||
|
buildGoModule {
|
||||||
|
|
||||||
|
pname = "gitea-matrix-bot";
|
||||||
|
version = "master";
|
||||||
|
src = ./.;
|
||||||
|
vendorSha256 =
|
||||||
|
"sha256-Kce1ky4orC8pPSEUAbOeW/O2S4ThtOLdYIPaXfKGHA4=";
|
||||||
|
|
||||||
|
# TODO fix tests
|
||||||
|
doCheck = false;
|
||||||
|
meta = with lib; {
|
||||||
|
description = "A bot to post gitea events to a matrix channel";
|
||||||
|
homepage = "https://github.com/pinpox/gitea-matrix-bot";
|
||||||
|
license = licenses.gpl3;
|
||||||
|
maintainers = with maintainers; [ pinpox ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Package
|
||||||
|
packages = forAllSystems (system: {
|
||||||
|
inherit (nixpkgsFor.${system}) gitea-matrix-bot;
|
||||||
|
default = self.packages.${system}.gitea-matrix-bot;
|
||||||
|
});
|
||||||
|
|
||||||
|
# TODO: Add module
|
||||||
|
};
|
||||||
|
}
|
@ -9,7 +9,7 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
//GiteaBot is the main struct to hold the bot
|
// GiteaBot is the main struct to hold the bot
|
||||||
type GiteaBot struct {
|
type GiteaBot struct {
|
||||||
*matrixbot.MatrixBot
|
*matrixbot.MatrixBot
|
||||||
//map rooms to tokens
|
//map rooms to tokens
|
||||||
@ -17,10 +17,10 @@ type GiteaBot struct {
|
|||||||
db *GiteaDB
|
db *GiteaDB
|
||||||
}
|
}
|
||||||
|
|
||||||
//NewGiteaBot creates a new bot form user credentials
|
// NewGiteaBot creates a new bot form user credentials
|
||||||
func NewGiteaBot(user, pass, host string, DBPath string) *GiteaBot {
|
func NewGiteaBot(user, pass, host string, DBPath string) *GiteaBot {
|
||||||
|
|
||||||
bot, err := matrixbot.NewMatrixBot(user, pass, "gitea")
|
bot, err := matrixbot.NewMatrixBot(user, pass, host, "gitea")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
18
go.mod
Normal file
18
go.mod
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
module gitea-matrix-bot
|
||||||
|
|
||||||
|
go 1.20
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/alecthomas/kingpin/v2 v2.3.2
|
||||||
|
github.com/binaryplease/matrix-bot v0.0.0-20190422182545-e58f16f86ca7
|
||||||
|
github.com/go-ini/ini v1.67.0
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.17
|
||||||
|
github.com/sirupsen/logrus v1.9.3
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
|
||||||
|
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530 // indirect
|
||||||
|
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||||
|
)
|
31
go.sum
Normal file
31
go.sum
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
github.com/alecthomas/kingpin/v2 v2.3.2 h1:H0aULhgmSzN8xQ3nX1uxtdlTHYoPLu5AhHxWrKI6ocU=
|
||||||
|
github.com/alecthomas/kingpin/v2 v2.3.2/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE=
|
||||||
|
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc=
|
||||||
|
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
|
||||||
|
github.com/binaryplease/matrix-bot v0.0.0-20190422182545-e58f16f86ca7 h1:DaAe5WJc6OZlwBICe1nXU2qqZZ3Pfo8ueQKjz+UE5ls=
|
||||||
|
github.com/binaryplease/matrix-bot v0.0.0-20190422182545-e58f16f86ca7/go.mod h1:OoTSJ08SgAIAZFhlnq7/yx3QFUwlZChDCV5LTREdtMc=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
|
||||||
|
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||||
|
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530 h1:kHKxCOLcHH8r4Fzarl4+Y3K5hjothkVW5z7T1dUM11U=
|
||||||
|
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||||
|
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||||
|
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
|
||||||
|
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
|
||||||
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
||||||
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
3
main.go
3
main.go
@ -3,7 +3,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
// "fmt"
|
// "fmt"
|
||||||
"github.com/go-ini/ini"
|
"github.com/go-ini/ini"
|
||||||
"gopkg.in/alecthomas/kingpin.v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
|
|
||||||
"time"
|
"time"
|
||||||
// "time"
|
// "time"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
Loading…
Reference in New Issue
Block a user