Last active
          May 6, 2020 04:37 
        
      - 
      
- 
        Save ver-1000000/8fc3437c61d1e08b1fdc735dd0a3ca3d to your computer and use it in GitHub Desktop. 
    swatchdogコマンドを活用し、MinecraftのログをSlackに通知するやつ
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| WEBHOOK_URL="https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/xxxxxxxxxxxxxxxxxxxxxxxx" | |
| USERNAME="MinecraftLogger" | |
| CHANNEL="#minecraft" | |
| ICON=":minecraft:" | |
| TEXT=`echo "$*" | sed 's/<\(\w\+\)>/<:\1:>/'` | |
| TEXT=`echo "$TEXT" | sed 's/Stopping server/サーバーを *終了* しています/'` | |
| TEXT=`echo "$TEXT" | sed 's/Starting minecraft server/サーバーを *起動* しています: /'` | |
| TEXT=`echo "$TEXT" | sed 's/joined the game/が *参加* しました/'` | |
| TEXT=`echo "$TEXT" | sed 's/left the game/が *退出* しました/'` | |
| TEXT=`echo "$TEXT" | sed 's/fell from a high place/は高いところから落ちた!/'` | |
| TEXT=`echo "$TEXT" | sed 's/was slain/は殺害された!/'` | |
| TEXT=`echo "$TEXT" | sed 's/was killed/は殺害された!/'` | |
| TEXT=`echo "$TEXT" | sed 's/was shot by/は射抜かれて殺害された! by/'` | |
| author="akai" | |
| data=`cat << EOF | |
| payload={ | |
| "channel": "$CHANNEL", | |
| "username": "$USERNAME", | |
| "icon_emoji": "$ICON", | |
| "link_names": 1 , | |
| "attachments": [{ | |
| "text": '$TEXT' | |
| }] | |
| } | |
| EOF` | |
| curl -X POST --data-urlencode "$data" $WEBHOOK_URL | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | watchfor !/(WARN| Disconnected| (Ambiguity|Loaded|Starting Minecraft|Done|Loading|Default|Generating|Using|Preparing|Reloading|Time|Can't|logged in|UUID|Saving))/ | |
| echo | |
| exec '/srv/minecraft/hard/swatch/minecraft_log_notifier_to_slack.sh "$_"' | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment