diff --git a/irc/cef.go b/irc/cef.go index 69390073..f6b46e9c 100644 --- a/irc/cef.go +++ b/irc/cef.go @@ -116,6 +116,16 @@ func handleConnection(conn net.Conn, instance *CefConnection) { } } break + case "FULLYREMOVE": + user := instance.server.clients.Get(line[1]) + if user != nil { + user.destroy(nil) + err := instance.server.accounts.Unregister(user.Account(), true) + if err != nil { + return + } + } + break default: println("Unknown cef message: ", line[0]) } diff --git a/irc/channel.go b/irc/channel.go index 0326c8b1..03e960b2 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -1459,7 +1459,7 @@ func (channel *Channel) Quit(client *Client) { client.server.channels.Cleanup(channel) } client.removeChannel(channel) - client.server.cefManager.KickBroadcast(channel.name, client.Username()) + client.server.cefManager.KickBroadcast(channel.name, client.Nick()) } func (channel *Channel) Kick(client *Client, target *Client, comment string, rb *ResponseBuffer, hasPrivs bool) { diff --git a/irc/script.go b/irc/script.go index b1511f63..81bc0747 100644 --- a/irc/script.go +++ b/irc/script.go @@ -5,8 +5,11 @@ package irc import ( "bufio" + "bytes" "io" + "net/http" "os/exec" + "strings" "syscall" "time" ) @@ -21,7 +24,27 @@ type scriptResponse struct { err error } +func RunHttp(command string, args []string, input []byte, timeout time.Duration) (output []byte, err error) { + client := http.Client{ + Timeout: timeout, + } + post, err := client.Post(command, "application/json", bytes.NewBuffer(input)) + if err != nil { + return nil, err + } + defer post.Body.Close() + output, err = io.ReadAll(post.Body) + + if err != nil { + return nil, err + } + return +} + func RunScript(command string, args []string, input []byte, timeout, killTimeout time.Duration) (output []byte, err error) { + if strings.HasPrefix(command, "http") { + return RunHttp(command, args, input, timeout) + } cmd := exec.Command(command, args...) stdin, err := cmd.StdinPipe() if err != nil {