Skip to content

Commit

Permalink
Adding on_join message
Browse files Browse the repository at this point in the history
  • Loading branch information
AtomicMaya committed Sep 26, 2022
1 parent 259c355 commit ed7aa2b
Show file tree
Hide file tree
Showing 22 changed files with 290 additions and 229 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Released]

## [0.1.6] - 2022-09-26

### Added
- Version file that exports the current version number.
- Welcome message (on join).
- Handler folder for all the event handlers.

### Changed
- File structure of the "extensions" (the various commands) to differentiate semantically. (moderation actions, management, etc)

### Removed
- Duplicate logging initialization in `main.go`.
- Various debug functions/experiments that are now sunset.

## `0.1.5-hotfix` - 2022-09-22
### Fixes
- Issue #5: [Link to issue](https://github.com/digital-overdose/digital-overdose-bot/issues/5s)
Expand Down Expand Up @@ -102,7 +116,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Initial run code.

[Unreleased]: https://github.com/digital-overdose/digital-overdose-bot/compare/v0.1.5...HEAD
[Unreleased]: https://github.com/digital-overdose/digital-overdose-bot/compare/v0.1.6...HEAD
[0.1.6]: https://github.com/digital-overdose/digital-overdose-bot/compare/v0.1.5...v0.1.6
[0.1.5]: https://github.com/digital-overdose/digital-overdose-bot/compare/v0.1.4...v0.1.5
[0.1.4]: https://github.com/digital-overdose/digital-overdose-bot/compare/v0.1.3...v0.1.4
[0.1.3]: https://github.com/digital-overdose/digital-overdose-bot/compare/v0.1.2...v0.1.3
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,18 @@ UPGRADE=https://github.com/digital-overdose/digital-overdose-bot/releases/downlo
## TODO

### Features (Future)

- [x] On Join message.
- [ ] `/warn` ⇾ Warn a user for a behavior (user, reason)
- [ ] `/unwarn` ⇾ Remove an attributed warn.
- [ ] `/ban` ⇾ Ban a user for a behavior (user, reason) + DM.
- [ ] `/unban` ⇾ Unban someone
- [ ] `/stats` ⇾ Number of people interacting over 2 weeks. Channel usage. Keep message ID in a file? (Cron)

#### Reqs

- Small DBMS, sqlite?

### Features (Important ⇾ Critical)

- [x] Ability to download new binary
Expand Down
102 changes: 51 additions & 51 deletions build-all-architectures.bat
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
@echo off
echo Building artifacts in /build
set VERSION=%1

:: call :build darwin amd64
:: call :build darwin arm64

:: call :build dragonfly amd64

:: call :build freebsd 386
:: call :build freebsd amd64
:: call :build freebsd arm

:: call :build linux 386
call :build linux amd64
call :build linux arm
call :build linux arm64
:: call :build linux ppc64
:: call :build linux ppc64le
:: call :build linux mips
:: call :build linux mipsle
:: call :build linux mips64
:: call :build linux mips64le

:: call :build netbsd 386
:: call :build netbsd amd64
:: call :build netbsd arm

:: call :build openbsd 386
:: call :build openbsd amd64
:: call :build openbsd arm

:: call :build plan9 386
:: call :build plan9 amd64

:: call :build solaris amd64

call :build windows 386
call :build windows amd64

echo Done!
exit /b

:build
set GOOS=%~1
set GOARCH=%~2
set EXT=
if "%GOOS%"=="windows" (
set EXT=.exe
)
go build -o build/digital-overdose-bot-v%VERSION%-%GOOS%-%GOARCH%%EXT% .
@echo off
echo Building artifacts in /build
set VERSION=%1

:: call :build darwin amd64
:: call :build darwin arm64

:: call :build dragonfly amd64

:: call :build freebsd 386
:: call :build freebsd amd64
:: call :build freebsd arm

:: call :build linux 386
call :build linux amd64
call :build linux arm
call :build linux arm64
:: call :build linux ppc64
:: call :build linux ppc64le
:: call :build linux mips
:: call :build linux mipsle
:: call :build linux mips64
:: call :build linux mips64le

:: call :build netbsd 386
:: call :build netbsd amd64
:: call :build netbsd arm

:: call :build openbsd 386
:: call :build openbsd amd64
:: call :build openbsd arm

:: call :build plan9 386
:: call :build plan9 amd64

:: call :build solaris amd64

call :build windows 386
call :build windows amd64

echo Done!
exit /b

:build
set GOOS=%~1
set GOARCH=%~2
set EXT=
if "%GOOS%"=="windows" (
set EXT=.exe
)
go build -o build/digital-overdose-bot-v%VERSION%-%GOOS%-%GOARCH%%EXT% .
echo Built build/digital-overdose-bot-v%VERSION%-%GOOS%-%GOARCH%%EXT%
3 changes: 2 additions & 1 deletion common/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ var (
canWriteToFile bool
)

// Creates the logging infrastrure for the program.
// Creates the logging infrastructure for the program.
// Initializes logging to a ./log/<datetime>.log file (if it can).
func InitializeLogging() {
log.SetOutput(os.Stdout)

Expand Down
3 changes: 3 additions & 0 deletions common/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package common

var VERSION = "0.1.6"
5 changes: 3 additions & 2 deletions cron/cron.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package cron

import (
commands_management "atomicnicos.me/digital-overdose-bot/extensions/commands/management"

"atomicnicos.me/digital-overdose-bot/common"
ext "atomicnicos.me/digital-overdose-bot/ext/commands"
"github.com/bwmarrin/discordgo"
)

Expand All @@ -21,7 +22,7 @@ var CronJobs = []*CronJob{
{
Name: "Automod: Verification Prune",
CronString: "0 12 */1 * *",
Job: ext.PurgeVerification,
Job: commands_management.PurgeVerification,
},
{
Name: "Management: Log cycling",
Expand Down
35 changes: 0 additions & 35 deletions ext/commands/deprecated.go

This file was deleted.

31 changes: 0 additions & 31 deletions ext/commands/is-user-admin.go

This file was deleted.

27 changes: 0 additions & 27 deletions ext/commands/test-current-feature.go

This file was deleted.

20 changes: 0 additions & 20 deletions ext/commands/test-dm-requester.go

This file was deleted.

40 changes: 34 additions & 6 deletions ext/commands.go → extensions/commands.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package ext
package extensions

import (
ext "atomicnicos.me/digital-overdose-bot/ext/commands"
commands "atomicnicos.me/digital-overdose-bot/extensions/commands"
commands_management "atomicnicos.me/digital-overdose-bot/extensions/commands/management"
commands_moderation "atomicnicos.me/digital-overdose-bot/extensions/commands/moderation"
"github.com/bwmarrin/discordgo"
)

Expand Down Expand Up @@ -39,6 +41,30 @@ var Commands = []*discordgo.ApplicationCommand{
},
},
},
{
Name: "warn",
Description: "Warns a user.",
Options: []*discordgo.ApplicationCommandOption{
{
Type: discordgo.ApplicationCommandOptionUser,
Name: "user",
Description: "The user to be warned.",
Required: true,
},
},
},
{
Name: "unwarn",
Description: "Unwarns a user.",
Options: []*discordgo.ApplicationCommandOption{
{
Type: discordgo.ApplicationCommandOptionUser,
Name: "user",
Description: "The user to have their last warning removed.",
Required: true,
},
},
},
/*{
Name: "is-user-admin",
Description: "Checks whether the user has the Manage Server permission",
Expand All @@ -63,10 +89,12 @@ var Commands = []*discordgo.ApplicationCommand{

// Command to bot function map.
var CommandHandlers = map[string]func(s *discordgo.Session, i *discordgo.InteractionCreate){
"purge-verification": ext.PurgeVerification,
"welcome": ext.WelcomeUser,
"test-current-feature": ext.TestCurrentFeature,
"upgrade": ext.UpgradeBot,
"purge-verification": commands_management.PurgeVerification,
"welcome": commands_moderation.WelcomeUser,
"test-current-feature": commands.TestCurrentFeature,
"upgrade": commands_management.UpgradeBot,
"warn": commands_moderation.Warn,
"unwarn": commands_moderation.Unwarn,
//"warn-user": ext.WarnUserTest,
//"is-user-admin": ext.IsUserAdmin,
//"test-dm-requester": ext.TestDMRequester,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ext
package extensions

import (
"fmt"
Expand All @@ -12,6 +12,9 @@ import (

// Purges the Verification channel of lurkers (> 7 days) or warns them (> 5 days)
func PurgeVerification(s *discordgo.Session, i *discordgo.InteractionCreate) {
if ok := common.ShouldExecutionBeSkippedIfDev(true); ok {
return
}
// If triggered by user-interaction
if i != nil {
if ok, _ := common.CheckHasPermissions(i, s, discordgo.PermissionManageRoles); !ok {
Expand All @@ -20,9 +23,6 @@ func PurgeVerification(s *discordgo.Session, i *discordgo.InteractionCreate) {
} else {
common.LogAndSend(":robot: :rotating_light: `/purge-verification` triggered by cron.", s)
}
if ok := common.ShouldExecutionBeSkippedIfDev(true); ok {
return
}

var (
listing = true // Loop controller.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ext
package extensions

import (
"fmt"
Expand Down
1 change: 1 addition & 0 deletions extensions/commands/moderation/ban.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package extensions
Loading

0 comments on commit ed7aa2b

Please sign in to comment.