Dependency on CentOS and a question

KildClient forum.
Post Reply
Joxtur
Posts: 3
Joined: Sun May 04, 2014 10:02 pm

Dependency on CentOS and a question

Post by Joxtur »

Hi -

After installing KildClient on CentOS 6.5, it took me a while to find the missing dependency to stop the program from crashing on connect.

perl-Locale-gettext is a dependency that isn't automatically installed.

Also, I'm connecting to a ROM derivative that has the color prompt prior to username and password. Is there a way to get an autologin to work with that scenario?

Sample prompts
Do you want color? (Y/n)
Please Enter Your Name ->
Please enter your password ->

I'm liking what I see so far. thanks!
ekalin
Site Admin
Posts: 45
Joined: Sun Feb 05, 2012 3:59 pm

Re: Dependency on CentOS and a question

Post by ekalin »

Joxtur wrote:Hi -

After installing KildClient on CentOS 6.5, it took me a while to find the missing dependency to stop the program from crashing on connect.

perl-Locale-gettext is a dependency that isn't automatically installed.
How did you install it? From a rpm package? Where did you get it from?
Joxtur wrote:Also, I'm connecting to a ROM derivative that has the color prompt prior to username and password. Is there a way to get an autologin to work with that scenario?

Sample prompts
Do you want color? (Y/n)
Please Enter Your Name ->
Please enter your password ->
You can't use the autologin feature for that, it does not support this format. But you can create three triggers for these lines that send the appropriate responses.
Joxtur
Posts: 3
Joined: Sun May 04, 2014 10:02 pm

Re: Dependency on CentOS and a question

Post by Joxtur »

It was an rpm from RPM Forge, though I later installed from source to get the newest version.

A shame on needing to trigger login, I was hoping to also use autolog to create session log files based on the character name, which isn't set if autologin isn't selected. Are there any options available?
jmud
Posts: 19
Joined: Mon Jun 04, 2012 4:59 am

Re: Dependency on CentOS and a question

Post by jmud »

Joxtur wrote:Are there any options available?
Your best option is to hope that someone will write a KildClient plugin for you: a plugin that will detect the character's name, and write everything to a logfile named after the character (including the text received before you type the character's name).

...No need to thank me!

Code: Select all

package logger;
#: Version: 1
#: Description: Handles non-standard mud login and writes character logfiles
#: Author: A S Lewis

use strict;
use diagnostics;
use warnings;

use File::HomeDir;
use Glib qw/TRUE FALSE/;

# Global variables
our ($LOG_DIR, $FILE_TYPE, $LOG_FLAG, $CHAR_NAME, $TEXT_BUFFER);

# 234567890123456789012345678901234567890123456789012345678901234567890123456789
BEGIN {

	# Global variables
	# ----------------
	
	# Set the directory (folder) in which logfiles are written. The default
	#	is to write to a directory like '/home/myname/kclogs'
	$LOG_DIR = File::HomeDir->my_home . '/kclogs/';
	# The type of file written - filename ends with '.txt', but you can 
	#	change it to '.log', if you prefer
	$FILE_TYPE = '.txt';

	# Flag set to TRUE when we should write to logfiles (or store text, 
	#	ready to be written to logfiles), 
	$LOG_FLAG = TRUE;
	
	# The user's character, once it has been detected
	$CHAR_NAME = undef;
	
	# Text received from the mud is stored here, temporarily, until the 
	#	character's name has been detected
	$TEXT_BUFFER = undef;
	
	# Interfaces
	# ----------
	
	# Create three triggers to handle the mud login
	$::world->trigger(
		# Trigger pattern
		'Do you want color',
		# Trigger action - call a function in this plugin
		'/logger->set_colour();',
		# Optional attributes
		{
			name => 'logger_trig_1',
			enabled => 1,
		},
	);
	
	$::world->trigger(
		# Trigger pattern
		'Please Enter Your Name',
		# Trigger action - call a function in this plugin
		'/logger->enter_name();',
		# Optional attributes
		{
			name => 'logger_trig_2',
			enabled => 1,
		},
	);
	
	$::world->trigger(
		# Trigger pattern
		'Please enter your password',
		# Trigger action - call a function in this plugin
		'/logger->enter_pass();',
		# Optional attributes
		{
			name => 'logger_trig_3',
			enabled => 1,
		},
	);	
	
	# Also create an alias to capture the user's response to the 'Please
	#	Enter Your Name' prompt. The alias starts disabled, and is only
	#	enabled briefly after the prompt is received from the mud
        $::world->alias(
		# Alias pattern: capture a single-word command, which should be 
		#	the character's name
		'^\s+',
		# Alias substitution - call a function in this plugin
		'/logger->set_name("$1");',
		# Optional attributes
		{
			name => 'logger_alias_1',
			enabled => 0,
		},
	),
	
	# Create a hook to capture all text received from the world, and to
	#	write it to the logfile
	$::world->hook(
		# Hook event
		'OnReceivedText',
		# Hook action
		'/logger->write_log("$hookdata");',
		# Optional attributes
		{
			name => 'logger_hook_1',
			enabled => 1,
		},
	);	
}

# Trigger/alias response functions

sub set_colour {
	
	# Do we want colour? Why, yes we do!
	$::world->send('y');
	
	# Disable the trigger - we only need it once
	$::world->distrigger('logger_trig_1');

	return 1;	
}
		
sub enter_name {
	
	# Enable the temporary alias which captures the user's response to the 
	#	'Enter your name' prompt
	$::world->enaalias('logger_alias_1');

	# Disable the trigger - we only need it once
	$::world->distrigger('logger_trig_2');
	
	return 1;
}

sub enter_pass {
	
	# Disable the trigger - we only need it once
	$::world->distrigger('logger_trig_3');

	return 1;	
}
	
sub set_name {

	my ($name) = @_;
	
	# The user has entered the character's name. Set the global variable
	$CHAR_NAME = $name;
	
	# Disable the alias - we only need it once
	$::world->disalias('logger_alias_1');
	
	# If any text has been stored in the buffer (and there should be some),
	#	write it to the logfile now
	if ($TEXT_BUFFER) {
		
		&write_log($TEXT_BUFFER);
	}
	
	# The alias prevented the character's name from being sent to the mud,
	#	so send the name now
	$::world->send($name);
	
	return 1;
}

sub write_log {
	
	my ($text) = @_;
	
	# Local variables
	my ($file_path, $file_handle);

	# If the character's name hasn't been detected yet, store the text in 
	#	the buffer
	if (! $CHAR_NAME) {
		
		$TEXT_BUFFER .= $text;
		
	# Otherwise, write to the logfile (if we're allowed)
	} elsif ($LOG_FLAG) {
		
		# Set the path to the logfile
		$file_path = $LOG_DIR . $CHAR_NAME . $FILE_TYPE;
		
		# Write to the logfile
		if (open ($file_handle, ">>$file_path")) {
			
			print $file_handle $text;
			
			close $file_handle;
		}
	}
	
	return 1;		
}
You don't say which mud you're playing, so I have not been able to test the plugin. So let me know, if it doesn't work.
jmud
Posts: 19
Joined: Mon Jun 04, 2012 4:59 am

Re: Dependency on CentOS and a question

Post by jmud »

Actually, this is probably closer to what you want.

If you specify a character in KildClient's 'Connect to' window, the plugin starts writing to that character's logfile immediately. Otherwise, it captures your response to the 'Enter your name' prompt, and uses that character's logfile.

Code: Select all

package logger;
#: Version: 2
#: Description: Handles non-standard mud login and writes character logfiles
#: Author: A S Lewis

use strict;
use diagnostics;
use warnings;

use File::HomeDir;
use Glib qw/TRUE FALSE/;

# Global variables
our ($LOG_DIR, $FILE_TYPE, $LOG_FLAG, $CHAR_NAME, $TEXT_BUFFER);

BEGIN {

	# Global variables
	# ----------------
	
	# Set the directory (folder) in which logfiles are written. The default
	#	is to write to a directory like '/home/myname/kclogs'
	$LOG_DIR = File::HomeDir->my_home . '/kclogs/';
	# The type of file written - filename ends with '.txt', but you can 
	#	change it to '.log', if you prefer
	$FILE_TYPE = '.txt';

	# Flag set to TRUE when we should write to logfiles (or store text, 
	#	ready to be written to logfiles), 
	$LOG_FLAG = TRUE;
	
	# The user's character. If the user hasn't specified a character in the
	#	KildClient 'Connect to' window, $CHAR_NAME remains set to
	#	'undef', and we use an alias to capture the character's name
	$CHAR_NAME = $::world->getcharacter();
	
	# Text received from the mud is stored here, temporarily, until the 
	#	character's name has been detected
	$TEXT_BUFFER = undef;
	
	# Interfaces
	# ----------
	
	# Create three triggers to handle the mud login
	$::world->trigger(
		# Trigger pattern
		'Do you want color',
		# Trigger action - call a function in this plugin
		'/logger->set_colour();',
		# Optional attributes
		{
			name => 'logger_trig_1',
			enabled => 1,
		},
	);
	
	$::world->trigger(
		# Trigger pattern
		'Please Enter Your Name',
		# Trigger action - call a function in this plugin
		'/logger->enter_name();',
		# Optional attributes
		{
			name => 'logger_trig_2',
			enabled => 1,
		},
	);
	
	$::world->trigger(
		# Trigger pattern
		'Please enter your password',
		# Trigger action - call a function in this plugin
		'/logger->enter_pass();',
		# Optional attributes
		{
			name => 'logger_trig_3',
			enabled => 1,
		},
	);	

	if (! $CHAR_NAME) {
		
		# The user hasn't specified a character name in KildClient's
		#	'Connect to' window, so we also create an alias to 
		#	capture the user's response to the 'Please Enter Your 
		#	Name' prompt. The alias starts disabled, and is only
		#	enabled briefly after the prompt is received from the 
		#	mud
		$::world->alias(
			# Alias pattern: capture a single-word command, which should be 
			#	the character's name
			'^\s+',
			# Alias substitution - call a function in this plugin
			'/logger->set_name("$1");',
			# Optional attributes
			{
				name => 'logger_alias_1',
				enabled => 0,
			},
		),
	}
	
	# Create a hook to capture all text received from the world, and to
	#	write it to the logfile
	$::world->hook(
		# Hook event
		'OnReceivedText',
		# Hook action
		'/logger->write_log("$hookdata");',
		# Optional attributes
		{
			name => 'logger_hook_1',
			enabled => 1,
		},
	);	
}

# Trigger/alias response functions

sub set_colour {
	
	# Do we want colour? Why, yes we do!
	$::world->send('y');
	
	# Disable the trigger - we only need it once
	$::world->distrigger('logger_trig_1');

	return 1;	
}
		
sub enter_name {
	
	# Enable the temporary alias which captures the user's response to the 
	#	'Enter your name' prompt
	$::world->enaalias('logger_alias_1');

	# Disable the trigger - we only need it once
	$::world->distrigger('logger_trig_2');
	
	return 1;
}

sub enter_pass {
	
	# Disable the trigger - we only need it once
	$::world->distrigger('logger_trig_3');

	return 1;	
}
	
sub set_name {

	my ($name) = @_;
	
	# The user has entered the character's name. Set the global variable
	$CHAR_NAME = $name;
	
	# Disable the alias - we only need it once
	$::world->disalias('logger_alias_1');
	
	# If any text has been stored in the buffer (and there should be some),
	#	write it to the logfile now
	if ($TEXT_BUFFER) {
		
		&write_log($TEXT_BUFFER);
	}
	
	# The alias prevented the character's name from being sent to the mud,
	#	so send the name now
	$::world->send($name);
	
	return 1;
}

sub write_log {
	
	my ($text) = @_;
	
	# Local variables
	my ($file_path, $file_handle);

	# If the character's name hasn't been detected yet, store the text in 
	#	the buffer
	if (! $CHAR_NAME) {
		
		$TEXT_BUFFER .= $text;
		
	# Otherwise, write to the logfile (if we're allowed)
	} elsif ($LOG_FLAG) {
		
		# Set the path to the logfile
		$file_path = $LOG_DIR . $CHAR_NAME . $FILE_TYPE;
		
		# Write to the logfile
		if (open ($file_handle, ">>$file_path")) {
			
			print $file_handle $text;
			
			close $file_handle;
		}
	}
	
	return 1;		
}
Joxtur
Posts: 3
Joined: Sun May 04, 2014 10:02 pm

Re: Dependency on CentOS and a question

Post by Joxtur »

the mud is actually my own, Lands of M'dhavian, mdhavian.net 7500

Thanks for the plugin, I actually know perl, so if it isn't exact, I am pretty sure I can make it work.
Post Reply