<commit_before>package plugins

// This plugin manages a common config-file pointer
// and the locks on it.

import (
	"strings"
	"sync"
	"ircclient"
	"github.com/kless/goconfig/config"
)

type ConfigPlugin struct {
	ic       *ircclient.IRCClient
	Conf     *config.Config
	// Operations to the Config structure should be atomic
	lock     *sync.Mutex
}

func NewConfigPlugin(conf *config.Config) *ConfigPlugin {
	return &ConfigPlugin{nil, conf, new(sync.Mutex)}
}
func (cp *ConfigPlugin) Register(cl *ircclient.IRCClient) {
	cp.ic = cl
}
func (cp *ConfigPlugin) String() string {
	return "config"
}
func (cp *ConfigPlugin) ProcessLine(msg *ircclient.IRCMessage) {
	// Empty
}
func (cp *ConfigPlugin) Unregister() {
	cp.lock.Lock()
	cp.Conf.WriteFile("go-faui2k11", 0644, "go-faui2k11 config")
	cp.lock.Unlock()
}
func (cp *ConfigPlugin) Info() string {
	return "run-time configuration manager plugin"
}
func (cp *ConfigPlugin) ProcessCommand(cmd *ircclient.IRCCommand) {
	// Proof of concept implementation
	var target string
	if cmd.Target != cp.ic.GetNick() {
		target = cmd.Target
	} else {
		target = strings.SplitN(cmd.Source, "!", 2)[0]
	}
	switch cmd.Command {
	case "listplugins":
		cp.ic.SendLine("PRIVMSG " + target + " :List of installed plugins:")
		for mod := range cp.ic.IterPlugins() {
			cp.ic.SendLine("PRIVMSG " + target + " :" + mod.String() + " - " + mod.Info())
		}
		cp.ic.SendLine("PRIVMSG " + target + " :-- end of list")
	case "version":
		cp.ic.SendLine("PRIVMSG " + target + " :This is go-faui2k11, version 0.01a")
	case "quit":
		cp.ic.Disconnect("Bye")
	}
}

func (cp *ConfigPlugin) Lock() {<commit_msg>plugins/conf: removed duplicate/verbose listplugins handler<commit_after>package plugins

// This plugin manages a common config-file pointer
// and the locks on it.

import (
	"strings"
	"sync"
	"ircclient"
	"github.com/kless/goconfig/config"
)

type ConfigPlugin struct {
	ic       *ircclient.IRCClient
	Conf     *config.Config
	// Operations to the Config structure should be atomic
	lock     *sync.Mutex
}

func NewConfigPlugin(conf *config.Config) *ConfigPlugin {
	return &ConfigPlugin{nil, conf, new(sync.Mutex)}
}
func (cp *ConfigPlugin) Register(cl *ircclient.IRCClient) {
	cp.ic = cl
}
func (cp *ConfigPlugin) String() string {
	return "config"
}
func (cp *ConfigPlugin) ProcessLine(msg *ircclient.IRCMessage) {
	// Empty
}
func (cp *ConfigPlugin) Unregister() {
	cp.lock.Lock()
	cp.Conf.WriteFile("go-faui2k11", 0644, "go-faui2k11 config")
	cp.lock.Unlock()
}
func (cp *ConfigPlugin) Info() string {
	return "run-time configuration manager plugin"
}
func (cp *ConfigPlugin) ProcessCommand(cmd *ircclient.IRCCommand) {
	// Proof of concept implementation
	var target string
	if cmd.Target != cp.ic.GetNick() {
		target = cmd.Target
	} else {
		target = strings.SplitN(cmd.Source, "!", 2)[0]
	}
	switch cmd.Command {
	case "version":
		cp.ic.SendLine("PRIVMSG " + target + " :This is go-faui2k11, version 0.01a")
	case "quit":
		cp.ic.Disconnect("Bye")
	}
}

func (cp *ConfigPlugin) Lock() {
{'fraction_non_alphanumeric': 0.1438943894389439, 'fraction_numerical': 0.011881188118811881, 'mean_word_length': 4.0855704697986575, 'pattern_counts': {'":': 5, '<': 3, '<?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': '1251917', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1076, 'n_words': 271}