Skip to content

Commit

Permalink
Merge pull request #14 from OperationalDev/FixUserDisconnectingBug
Browse files Browse the repository at this point in the history
Bot breaks if a dead player leaves in the middle of a round
  • Loading branch information
OperationalDev authored Nov 14, 2020
2 parents 3dd8c00 + 83cfd21 commit 8342d6d
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 32 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ jobs:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Get version from tag
id: tag_name
run: |
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
- name: Checkout code
uses: actions/checkout@v2
- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
validation_depth: 10
version: ${{ steps.tag_name.outputs.current_version }}
path: ./CHANGELOG.md
- name: Create Release
Expand All @@ -26,11 +29,11 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
tag_name: ${{ steps.changelog_reader.outputs.version }}
release_name: Release ${{ steps.changelog_reader.outputs.version }}
body: ${{ steps.changelog_reader.outputs.changes }}
draft: false
prerelease: false
prerelease: ${{ steps.changelog_reader.outputs.status == 'prereleased' }}
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }}
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
Expand Down
53 changes: 36 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,48 @@
# Change Log
# Changelog
All notable changes to this project will be documented in this file.

## v0.2.8
### Changes
- Added github actions to build artifacts.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v0.2.2
### Bugs

## [Unreleased]
### Added
- game names are now checked case insensitive
- if no comment set, use mumble name

### Changed
### Deprecated
### Removed
### Fixed
### Security


## [0.3.0]
### Added
- Notifications im mumble if in game player name and mumble user name don't match.

### Fixed
- Player leaving mumble no longer causes the bot to go into a panic.
- A player leaving or disconnecting from the game no longer causes the bot to do an update.

## [0.2.2]
### Fixed
- Fixed moving player to dead when voted out for real this time.
- New Nil pointer dereference bug fixed.


## v0.2.1
### Bugs
## [0.2.1]
### Fixed
- Players always get moved to the dead channel when voted out.
- Nil pointer dereference bug fixed.
- Fixed certificate commands in README.


## v0.2.0
### Changes
- Updated README to include setup instructions.

### New Features
## [0.2.0]
### Added
- Allow passing botname, cert, key, server as parameters from config file.

### Changed
- Updated README to include setup instructions.

## v0.1.0
- Initial Release
## [0.1.0]
### Added
- Initial Release
25 changes: 15 additions & 10 deletions mumble/mumble.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ func Meeting(c *gumble.Client, deadplayers []string) {

for _, deadplayer := range deadplayers {
user := c.Users.Find(deadplayer)
log.Println("Mute player", user.Name)
user.SetMuted(true)
user.SetDeafened(false)
user.Move(alive)
log.Println(user.Name, "is dead")
if user != nil {
log.Println("Mute player", user.Name)
user.SetMuted(true)
user.SetDeafened(false)
user.Move(alive)
log.Println(user.Name, "is dead")
}
}
}

Expand All @@ -98,11 +100,13 @@ func Resumegame(c *gumble.Client, deadplayers []string) {

for _, deadplayer := range deadplayers {
user := c.Users.Find(deadplayer)
log.Println("Unmute player", user.Name)
user.SetMuted(false)
user.SetDeafened(false)
user.Move(dead)
log.Println(user.Name, "is dead")
if user != nil {
log.Println("Unmute player", user.Name)
user.SetMuted(false)
user.SetDeafened(false)
user.Move(dead)
log.Println(user.Name, "is dead")
}
}
}

Expand Down Expand Up @@ -145,6 +149,7 @@ func Namecheck(c *gumble.Client, player string) {
return
}
}
lobby.Send("Player "+player+" does not have a mumble user set.", true)
log.Println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
log.Println("Player", player, "does not have a mumble user set.")
log.Println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
Expand Down
6 changes: 6 additions & 0 deletions socket/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

type player struct {
Name string `json:"Name"`
Action int `json:"Action"`
Color int `json:"Color"`
IsDead bool `json:"IsDead"`
Disconnected bool `json:"Disconnected"`
Expand Down Expand Up @@ -85,6 +86,11 @@ func SocketioServer(client *gumble.Client, listenaddress string, listenport stri
player := player{}
_ = json.Unmarshal([]byte(msg), &player)

if player.Action == 1 || player.Action == 5 {
log.Println(player, "left the game.")
return
}

if gamestate == "LOBBY" {
mumble.Namecheck(client, strings.TrimSpace(player.Name))
} else {
Expand Down

0 comments on commit 8342d6d

Please sign in to comment.