<commit_before>package main

import (
	"fmt"
	"github.com/sysr-q/kyubu/cpe"
	"github.com/sysr-q/kyubu/packets"
	"strings"
)

// LogMessage is an example hook function that simply logs all message packets
// that pass through Kurafuto. It's not that interesting, honestly.
//
//   parser := NewParser(...)
//   parser.Register(packets.Message{}, LogMessage)
func LogMessage(p *Player, dir HookDirection, packet packets.Packet) bool {
	var msg *packets.Message
	msg = packet.(*packets.Message)
	if dir == FromClient {
		Log(Colorify(fmt.Sprintf("&f<%s>&r %s", p.Name, msg.Message)))
	} else {
		Log(Colorify(fmt.Sprintf("&6[SERVER]&r %s", msg.Message)))
	}
	return false
}

// DropPacket is a simple hook which will "skip" dropped packets included in the
// server's drop list (including dropped CPE extensions).
func DropPacket(p *Player, dir HookDirection, packet packets.Packet) (drop bool) {
	if Ku == nil || Ku.Config == nil {
		drop = false
		return
	}
	for _, id := range Ku.Config.Drop {
		if id != packet.Id() {
			continue
		}
		drop = true
		break
	}
	if ep, ok := packet.(cpe.ExtPacket); !drop && ok {
		for _, ext := range Ku.Config.DropExts {
			if ext != ep.String() {
				continue
			}
			drop = true
			break
		}
	}
	if drop {
		Debugf("(%s) %s dropped packet %#.2x (%s)", p.Id, p.Name, packet.Id(), dir.String())
	}
	return
}

func DebugPacket(p *Player, dir HookDirection, packet packets.Packet) (drop bool) {
	if Ku == nil || Ku.Config == nil {
		return
	}
	for _, id := range Ku.Config.Ignore {
		if id != packet.Id() {
			continue
		}
		return
	}
	name := "Unknown"
	if info, ok := packets.Packets[packet.Id()]; ok {
		name = info.Name
	}
	Debugf("(%s) %s; %s packet %#.2x [%s]", p.Id, p.Name, dir.String(), packet.Id(), name)
	return
}

func EdgeCommand(p *Player, dir HookDirection, packet packets.Packet) (drop bool) {
	if dir != FromClient || Ku == nil || Ku.Config == nil || !Ku.Config.EdgeCommands {
		return
	}

	var bits []string

	if msg, ok := packet.(*packets.Message); ok {
		bits = strings.Split(msg.Message, " ")
	} else {
		return
	}

	if len(bits) < 1 || bits[0] != ":kura" {
		return
	}
	switch bits[1] {
		case " ":
			msg, _ := packets.NewMessage(127, "&5Kurafuto wuz here!")
			p.toClient <- msg
		case "list":
			message := fmt.Sprintf("&5%s players are online!", len(Ku.Players))
			msg, _ := packets.NewMessage(127, message)
			p.toClient <- msg
		case "help":
			msg, _ := packets.NewMessage(127, "&5Type :kura list or :kura jump <server>")
			p.toClient <- msg
		default:
			msg, _ := packets.NewMessage(127, "&5Coming soon!")
			p.toClient <- msg
	} 
	return true
}
<commit_msg>Change default response to :kura<commit_after>package main

import (
	"fmt"
	"github.com/sysr-q/kyubu/cpe"
	"github.com/sysr-q/kyubu/packets"
	"strings"
)

// LogMessage is an example hook function that simply logs all message packets
// that pass through Kurafuto. It's not that interesting, honestly.
//
//   parser := NewParser(...)
//   parser.Register(packets.Message{}, LogMessage)
func LogMessage(p *Player, dir HookDirection, packet packets.Packet) bool {
	var msg *packets.Message
	msg = packet.(*packets.Message)
	if dir == FromClient {
		Log(Colorify(fmt.Sprintf("&f<%s>&r %s", p.Name, msg.Message)))
	} else {
		Log(Colorify(fmt.Sprintf("&6[SERVER]&r %s", msg.Message)))
	}
	return false
}

// DropPacket is a simple hook which will "skip" dropped packets included in the
// server's drop list (including dropped CPE extensions).
func DropPacket(p *Player, dir HookDirection, packet packets.Packet) (drop bool) {
	if Ku == nil || Ku.Config == nil {
		drop = false
		return
	}
	for _, id := range Ku.Config.Drop {
		if id != packet.Id() {
			continue
		}
		drop = true
		break
	}
	if ep, ok := packet.(cpe.ExtPacket); !drop && ok {
		for _, ext := range Ku.Config.DropExts {
			if ext != ep.String() {
				continue
			}
			drop = true
			break
		}
	}
	if drop {
		Debugf("(%s) %s dropped packet %#.2x (%s)", p.Id, p.Name, packet.Id(), dir.String())
	}
	return
}

func DebugPacket(p *Player, dir HookDirection, packet packets.Packet) (drop bool) {
	if Ku == nil || Ku.Config == nil {
		return
	}
	for _, id := range Ku.Config.Ignore {
		if id != packet.Id() {
			continue
		}
		return
	}
	name := "Unknown"
	if info, ok := packets.Packets[packet.Id()]; ok {
		name = info.Name
	}
	Debugf("(%s) %s; %s packet %#.2x [%s]", p.Id, p.Name, dir.String(), packet.Id(), name)
	return
}

func EdgeCommand(p *Player, dir HookDirection, packet packets.Packet) (drop bool) {
	if dir != FromClient || Ku == nil || Ku.Config == nil || !Ku.Config.EdgeCommands {
		return
	}

	var bits []string

	if msg, ok := packet.(*packets.Message); ok {
		bits = strings.Split(msg.Message, " ")
	} else {
		return
	}

	if len(bits) < 1 || bits[0] != ":kura" {
		return
	}
	switch bits[1] {
		case " ":
			msg, _ := packets.NewMessage(127, "&5Kurafuto wuz here!")
			p.toClient <- msg
		case "list":
			message := fmt.Sprintf("&5%s players are online!", len(Ku.Players))
			msg, _ := packets.NewMessage(127, message)
			p.toClient <- msg
		case "help":
			msg, _ := packets.NewMessage(127, "&5Type :kura list or :kura jump <server>")
			p.toClient <- msg
		default:
			msg, _ := packets.NewMessage(127, "&5Type :kura list or :kura jump <server>")
			p.toClient <- msg
	} 
	return true
}

{'fraction_non_alphanumeric': 0.16587946344228227, 'fraction_numerical': 0.008312866049499339, 'mean_word_length': 3.311074918566775, 'pattern_counts': {'":': 8, '<': 18, '<?xml version=': 0, '>': 8, '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': '2152774', 'n_tokens_mistral': 2067, 'n_tokens_neox': 1910, 'n_words': 533}