o2sms

 view release on metacpan or  search on metacpan

bin/aftsms  view on Meta::CPAN

		# capitalise first letter of every sentence 
		$message = &t9ify($message);
	}

	#$message =~ s/^$man_delim//; # remove unneeded splitters
	#$message =~ s/$man_delim$//; # remove unneeded splitters

	# truncate message to maximum length
	if (length($message) > $sms_max_length)
	{
		&log_warning("very long message, truncating to $sms_max_length chars");
		$message = substr($message,0,$sms_max_length);
	}

	# check do we need to split up the message
	if ((length($message) > $single_max_length) || ($message =~ m/$man_delim/))
	{
		if (($split_messages == OFF) && ($message !~ m/$man_delim/))
		{
			&log_fatal("message is too long (" . length($message) . "/$single_max_length), exitting");
		}

		my $restmsg = $message;
		my $partmsg;

		while ((length($restmsg) > $single_max_length) || ($restmsg =~ m/$man_delim/))
		{
			# if manual split, and message part can fit, then add the first bit and loop
			if ($restmsg =~ m/^(.*?)$man_delim(.*)/sm)
			{
				if (length($1) < $single_max_length)
				{
					$partmsg = $1;
					$restmsg = $2;
					push (@message_parts, $partmsg) if ($partmsg =~ m/\S/);
					next;
				}
			}

			# if we don't want to split..
			if ($split_messages == OFF)
			{
				&log_fatal("message part " . (scalar(@message_parts) + 1) . " is too long (" . length($restmsg) . "/$single_max_length), exitting");
			}

			# message too long, split at the most natural place
			if ($hard_split == ON)
			{
				($partmsg, $restmsg) = &split_message_hard($single_max_length, $restmsg);
			}
			else
			{
				($partmsg, $restmsg) = &split_message($single_max_length, $restmsg);
			}

			push (@message_parts, $partmsg) if ($partmsg =~ m/\S/);
		}

		push (@message_parts, $restmsg . $signature) if ($restmsg =~ m/\S/);

		&log_warning("long or split message, splitting into " . scalar(@message_parts) . " parts");
	}
	else
	{
		push (@message_parts, $message . $signature);
	}

	# fill the end of each message part with white spaces to clear the "free web text" ad
	#foreach my $message_part (@message_parts)
	#{
	#	my $msg_fill = " " x ($single_max_length - length($message_part) + length($signature));
	#	$message_part .= $msg_fill;
	#}

	return @message_parts;
}

# -- save alias
sub save_aliases
{
	return if (&is_win32()); # a few things inexplicibly don't work on win32 in this method

	if (!(&is_interactive))
	{
		return;
	}

	if (!defined($config_file))
	{
		return;
	}

	RECIPIENT: while (my ($number, $name) = each(%recipients))
	{
		ALIAS: foreach my $anumber (values %aliases)
		{
			if ($anumber == $number)
			{
				next RECIPIENT;
			}
		}

		PROMPT: while ($name eq "")
		{
			print $RL_OUT "[ create alias for '$number' with this name : ] ";

			my $name4num = <STDIN>;

			chomp($name4num);

			if ($name4num !~ m/\S/)
			{
				last;
			}
			elsif ($name4num !~ m/[\w\.\-\_]+/)
			{
				&log_error("invalid alias name '$name4num'");
			}
			elsif (exists($aliases{$name4num}))
			{
				&log_error("alias already exists");



( run in 0.808 second using v1.01-cache-2.11-cpan-71847e10f99 )