<commit_before>package main

import (
    "log"
    "encoding/json"
    "errors"
    "time"
)

type Message struct {
    Event string
    Body map[string]interface{}
    Time int64
}

func (this *Message) FromSocket(sock *Socket) {
    log.Printf("Handling message fo type %s\n", this.Event)
    
    if this.Event == "MessageUser" {
        msg, err := this.formatBody()
        if err != nil {
            return
        }
        
        UID, ok := this.Body["UID"].(string)
        if !ok {
            return
        }
        
        rec, err := sock.Server.Store.Client(UID)
        if err != nil {
            return
        }
        
        rec.buff <- msg
    }
    
    if this.Event == "MessageAll" {
        msg_str, _ := json.Marshal(this)
        
        sock.Server.Store.redis.Publish("Message", string(msg_str))
    }
}

func (this *Message) FromRedis(server *Server) {
    log.Printf("Handling message fo type %s\n", this.Event)
    
    switch this.Event {
    
    case "MessageUser":
        msg, err := this.formatBody()
        if err != nil {
            return
        }
        
        UID, ok := this.Body["UID"].(string)
        if !ok {
            return
        }
        
        rec, err := server.Store.Client(UID)
        if err != nil {
            return
        }
        
        rec.buff <- msg
        return<commit_msg>use switch statment for messages<commit_after>package main

import (
    "log"
    "encoding/json"
    "errors"
    "time"
)

type Message struct {
    Event string
    Body map[string]interface{}
    Time int64
}

func (this *Message) FromSocket(sock *Socket) {
    log.Printf("Handling message fo type %s\n", this.Event)
    
    switch this.Event {
    case "MessageUser":
        msg, err := this.formatBody()
        if err != nil {
            return
        }
        
        UID, ok := this.Body["UID"].(string)
        if !ok {
            return
        }
        
        rec, err := sock.Server.Store.Client(UID)
        if err != nil {
            return
        }
        
        rec.buff <- msg
    
    case "MessageAll":
        msg_str, _ := json.Marshal(this)
        
        sock.Server.Store.redis.Publish("Message", string(msg_str))
    }
}

func (this *Message) FromRedis(server *Server) {
    log.Printf("Handling message fo type %s\n", this.Event)
    
    switch this.Event {
    
    case "MessageUser":
        msg, err := this.formatBody()
        if err != nil {
            return
        }
        
        UID, ok := this.Body["UID"].(string)
        if !ok {
            return
        }
        
        rec, err := server.Store.Client(UID)
        if err != nil {
            return
        }
        
        rec.buff <- msg
        return
{'fraction_non_alphanumeric': 0.11903895158354569, 'fraction_numerical': 0.0014561339643247178, 'mean_word_length': 1.414762741652021, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2422481', 'n_tokens_mistral': 842, 'n_tokens_neox': 835, 'n_words': 197}