Skip to content

Commit

Permalink
Merge pull request #5 from deltachat-bot/adb/delete-from-server-by-de…
Browse files Browse the repository at this point in the history
…fault

delete messages form server immediately by default
  • Loading branch information
adbenitez authored Feb 5, 2024
2 parents 1cf808e + e354f7a commit 80c6aa9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/deltachat-bot/public-bots
go 1.21

require (
github.com/deltachat-bot/deltabot-cli-go v0.5.0
github.com/deltachat/deltachat-rpc-client-go v1.127.1-0.20240204004424-951cc3a470da
github.com/deltachat-bot/deltabot-cli-go v0.6.0
github.com/deltachat/deltachat-rpc-client-go v1.134.0
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.2
)
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ github.com/creachadair/mds v0.8.2/go.mod h1:4vrFYUzTXMJpMBU+OA292I6IUxKWCCfZkgXg
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/deltachat-bot/deltabot-cli-go v0.5.0 h1:WHHbG5++bO65risHzBj2jo0AOpBhJjVTKt6XH7d1KYo=
github.com/deltachat-bot/deltabot-cli-go v0.5.0/go.mod h1:Lj4cmrHgOk0LKUOei5RAjx94VLTs11CfPhIqOBT+g8c=
github.com/deltachat/deltachat-rpc-client-go v1.127.1-0.20240204004424-951cc3a470da h1:j7ghoKrimFDeXQit5d11XhLZHhiKIdxbPyUZveQcwg8=
github.com/deltachat/deltachat-rpc-client-go v1.127.1-0.20240204004424-951cc3a470da/go.mod h1:Ctd0M0o87y2B0QSOn8QN6IMDWjHD7XzDKsjNMYwP208=
github.com/deltachat-bot/deltabot-cli-go v0.6.0 h1:9hTulfKBsNshj22jsCGZ8NcDM1nPNrnU3/Ftiphy28w=
github.com/deltachat-bot/deltabot-cli-go v0.6.0/go.mod h1:sBXNRNrIjYgVT5aT1Lv2Wt7WthdTphNRt40RJovrzhI=
github.com/deltachat/deltachat-rpc-client-go v1.134.0 h1:rpGa/kL417ufyxsivT/G751aZifh8bpiPTIsXMzdDAI=
github.com/deltachat/deltachat-rpc-client-go v1.134.0/go.mod h1:Ctd0M0o87y2B0QSOn8QN6IMDWjHD7XzDKsjNMYwP208=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
Expand Down
8 changes: 4 additions & 4 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ if ! command -v golangci-lint &> /dev/null
then
echo "golangci-lint not found, installing..."
# binary will be $(go env GOPATH)/bin/golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
fi
if ! golangci-lint run
then
exit 1
fi

# Install test dependencies
mkdir -p "$HOME/.cargo/bin/"
export PATH="$HOME/.cargo/bin/:$PATH"
if ! command -v deltachat-rpc-server &> /dev/null
then
echo "deltachat-rpc-server not found, installing..."
pip install deltachat-rpc-server
curl -L https://github.com/deltachat/deltachat-core-rust/releases/latest/download/deltachat-rpc-server-x86_64-linux --output deltachat-rpc-server
chmod +x deltachat-rpc-server
export PATH=`pwd`:"$PATH"
fi
if ! command -v courtney &> /dev/null
then
Expand Down
22 changes: 22 additions & 0 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/deltachat-bot/deltabot-cli-go/botcli"
"github.com/deltachat/deltachat-rpc-client-go/deltachat"
"github.com/deltachat/deltachat-rpc-client-go/deltachat/option"
"github.com/spf13/cobra"
)

Expand All @@ -18,6 +19,27 @@ var cli = botcli.New("public-bots")
func onBotInit(cli *botcli.BotCli, bot *deltachat.Bot, cmd *cobra.Command, args []string) {
bot.OnUnhandledEvent(onEvent)
bot.OnNewMsg(onNewMsg)

accounts, err := bot.Rpc.GetAllAccountIds()
if err != nil {
cli.Logger.Error(err)
}
for _, accId := range accounts {
name, err := bot.Rpc.GetConfig(accId, "displayname")
if err != nil {
cli.Logger.Error(err)
}
if name.UnwrapOr("") == "" {
err = bot.Rpc.SetConfig(accId, "displayname", option.Some("Public Bots"))
if err != nil {
cli.Logger.Error(err)
}
err = bot.Rpc.SetConfig(accId, "delete_server_after", option.Some("1"))
if err != nil {
cli.Logger.Error(err)
}
}
}
}

func onBotStart(cli *botcli.BotCli, bot *deltachat.Bot, cmd *cobra.Command, args []string) {
Expand Down

0 comments on commit 80c6aa9

Please sign in to comment.