mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 22:09:26 +01:00
Progress on refactoring and polishing everything
This commit is contained in:
parent
b6c6100de1
commit
883a62920d
@ -45,15 +45,15 @@ sub initialize {
|
||||
sub stdin_reader {
|
||||
my ($self, $input) = @_;
|
||||
|
||||
# make sure we're in the foreground first
|
||||
$self->{foreground} = (tcgetpgrp($self->{tty_fd}) == getpgrp()) ? 1 : 0;
|
||||
return if not $self->{foreground};
|
||||
|
||||
# decode STDIN input from utf8
|
||||
$input = decode('UTF-8', $input);
|
||||
|
||||
chomp $input;
|
||||
|
||||
# make sure we're in the foreground first
|
||||
$self->{foreground} = (tcgetpgrp($self->{tty_fd}) == getpgrp()) ? 1 : 0;
|
||||
return if not $self->{foreground};
|
||||
|
||||
$self->{pbot}->{logger}->log("---------------------------------------------\n");
|
||||
$self->{pbot}->{logger}->log("Got STDIN: $input\n");
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
# File: Indefinite.pm
|
||||
#
|
||||
# Purpose: Implements a/an inflexion for nouns.
|
||||
|
||||
package PBot::Utils::Indefinite;
|
||||
|
||||
use 5.010; use warnings;
|
||||
|
||||
use feature 'unicode_strings';
|
||||
use PBot::Imports;
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw/Exporter/;
|
||||
|
@ -1,10 +1,17 @@
|
||||
package PBot::Utils::LWPUserAgentCached;
|
||||
use strict;
|
||||
|
||||
# File: LWPUserAgentCached.pm
|
||||
#
|
||||
# Purpose: variant of LWP::UserAgent::WithCache. Instead of depending on
|
||||
# the 'expires' or 'Last-Modified' attributes, we always cache for the
|
||||
# specified duration.
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package PBot::Utils::LWPUserAgentCached;
|
||||
|
||||
use PBot::Imports;
|
||||
|
||||
use base qw/LWP::UserAgent/;
|
||||
use Cache::FileCache;
|
||||
use File::HomeDir;
|
||||
|
@ -1,16 +1,16 @@
|
||||
#!/usr/bin/env perl
|
||||
# File: ParseDate.pm
|
||||
#
|
||||
# Purpose: Intelligently parses strings like "3pm", "5 minutes", "next week",
|
||||
# etc, into seconds.
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use feature 'unicode_strings';
|
||||
|
||||
package PBot::Utils::ParseDate;
|
||||
|
||||
use PBot::Imports;
|
||||
|
||||
use DateTime;
|
||||
use DateTime::Format::Flexible;
|
||||
use DateTime::Format::Duration;
|
||||
|
@ -1,14 +1,22 @@
|
||||
# File: SafeFilename.pm
|
||||
#
|
||||
# Purpose: for strings containing filenames, translates potentially unsafe
|
||||
# characters into safe expansions; e.g. "foo/bar" becomes "foo&fslash;bar".
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package PBot::Utils::SafeFilename;
|
||||
|
||||
use 5.010; use warnings;
|
||||
use feature 'unicode_strings';
|
||||
use PBot::Imports;
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw/Exporter/;
|
||||
our @EXPORT = qw/safe_filename/;
|
||||
|
||||
sub safe_filename {
|
||||
my $name = shift;
|
||||
my ($name) = @_;
|
||||
my $safe = '';
|
||||
|
||||
while ($name =~ m/(.)/gms) {
|
||||
|
@ -1,12 +1,18 @@
|
||||
# File: ValidateString.pm
|
||||
#
|
||||
# Purpose: ensures that a given string conforms to PBot's limitations
|
||||
# for internal strings. This means ensuring the string is not too long,
|
||||
# does not have undesired characters, etc.
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package PBot::Utils::ValidateString;
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use PBot::Imports;
|
||||
|
||||
use feature 'unicode_strings';
|
||||
use utf8;
|
||||
|
||||
# export validate_string() subroutine
|
||||
# export validate_string subroutine
|
||||
require Exporter;
|
||||
our @ISA = qw/Exporter/;
|
||||
our @EXPORT = qw/validate_string/;
|
||||
|
Loading…
Reference in New Issue
Block a user