From e0d50c2f720863bf3511466406ddd7e905748d87 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sat, 1 Feb 2020 14:33:42 -0800 Subject: [PATCH] modules: remove some outdated modules --- modules/acronym.pl | 61 ------------ modules/cstd.pl | 221 ------------------------------------------- modules/google.pl | 126 ------------------------- modules/gspy.pl | 21 ----- modules/gtop10.pl | 21 ----- modules/gtop15.pl | 112 ---------------------- modules/seen.pl | 87 ----------------- modules/weather.pl | 227 --------------------------------------------- 8 files changed, 876 deletions(-) delete mode 100755 modules/acronym.pl delete mode 100755 modules/cstd.pl delete mode 100755 modules/google.pl delete mode 100755 modules/gspy.pl delete mode 100755 modules/gtop10.pl delete mode 100755 modules/gtop15.pl delete mode 100755 modules/seen.pl delete mode 100755 modules/weather.pl diff --git a/modules/acronym.pl b/modules/acronym.pl deleted file mode 100755 index d3aaac50..00000000 --- a/modules/acronym.pl +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/perl -w - -# 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/. - -# quick and dirty by :pragma - -use LWP::UserAgent; - -my ($result, $acro, $entries, $text); - -if ($#ARGV <0) -{ - print "What is the acronym you'd like to know about?\n"; - die; -} - -$acro = join("+", @ARGV); - -my $ua = LWP::UserAgent->new; -$ua->agent("Mozilla/5.0"); - -my $response = $ua->post("http://www.acronymsearch.com/index.php", - [ acronym => $acro, act => 'search' ]); - -if (not $response->is_success) -{ - print "Couldn't get acronym information.\n"; - die; -} - -$text = $response->content; - -$acro =~ s/\+/ /g; - -if ($text =~ m/No result found/) -{ - print "Sorry, couldn't figure out what '$acro' stood for.\n"; - die; -} - -$entries = 1; -$entries = $1 if ($text =~ m/"2">(.*?) results? found/gi); - -print "$acro ($entries entries): "; - -$acro=""; - -while ($text =~ m/(.*?)<\/td>/gsi) -{ - $acro = "$acro$1; "; -} - -$acro =~ s/\s+\[slang\]//gi; -$acro =~ s/\s+\[joke\]//gi; -$acro =~ s/\s+/ /g; -$acro =~ s/<.*?>//g; -$acro =~ s/ //g; -$acro =~ s/; ; $//; -print "$acro\n"; diff --git a/modules/cstd.pl b/modules/cstd.pl deleted file mode 100755 index c010034c..00000000 --- a/modules/cstd.pl +++ /dev/null @@ -1,221 +0,0 @@ -#!/usr/bin/perl - -# 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; - -my $debug = 0; - -# for paragraphs -my $USER_SPECIFIED = 1; -my $RESULTS_SPECIFIED = 2; - -my $search = join ' ', @ARGV; - -if (not length $search) { - print "Usage: cstd [-list] [-n#] [-section
] [search text] -- 'section' must be in the form of X.YpZ where X and Y are section/chapter and, optionally, pZ is paragraph. If both 'section' and 'search text' are specified, then the search space will be within the specified section. You may use -n # to skip to the #th match. To list only the section numbers containing 'search text', add -list.\n"; - exit 0; -} - -my ($section, $paragraph, $section_specified, $paragraph_specified, $match, $list_only, $list_titles); - -$section_specified = 0; -$paragraph_specified = 0; - -if ($search =~ s/-section\s*([0-9\.p]+)//i or $search =~ s/\b(\d+\.[0-9\.p]*)//i) { - $section = $1; - - if ($section =~ s/p(\d+)//i) { - $paragraph = $1; - $paragraph_specified = $USER_SPECIFIED; - } else { - $paragraph = 1; - } - - $section = "$section." if $section =~ m/^\d+$/; - - $section_specified = 1; -} - -if ($search =~ s/-n\s*(\d+)//) { - $match = $1; -} else { - $match = 1; -} - -if ($search =~ s/-list//i) { - $list_only = 1; - $list_titles = 1; # Added here instead of removing -titles option -} - -if ($search =~ s/-titles//i) { - $list_only = 1; - $list_titles = 1; -} - -$search =~ s/^\s+//; -$search =~ s/\s+$//; - -if (not defined $section) { - $section = "1."; - $paragraph = 1; -} - -if ($list_only and not length $search) { - print "You must specify some search text to use with -list.\n"; - exit 0; -} - -open FH, "; -close FH; - -my $text = join '', @contents; -$text =~ s/\r//g; - -my $result; -my $found_section = ""; -my $found_section_title = ""; -my $section_title; -my $found_paragraph; -my $found = 0; -my $matches = 0; -my $this_section; -my $comma = ""; - -if ($list_only) { - $result = "Sections containing '$search':\n "; -} - -$search =~ s/\s/\\s+/g; - -while ($text =~ m/^\s{4,6}(\d+\.[0-9\.]*)/msg) { - $this_section = $1; - - print "----------------------------------\n" if $debug >= 2; - print "Processing section [$this_section]\n" if $debug; - - my $section_text; - - if ($text =~ m/(.*?)^(?=\s{4,6}\d+\.)/msg) { - $section_text = $1; - } else { - print "No section text, end of file marker found.\n" if $debug >= 4; - last; - } - - if ($section_text =~ m/(.*?)$/msg) { - $section_title = $1 if length $1; - $section_title =~ s/^\s+//; - $section_title =~ s/\s+$//; - } - - if ($section_specified and $this_section !~ m/^$section/) { - print "No section match, skipping.\n" if $debug >= 4; - next; - } - - print "$this_section [$section_title]\n" if $debug >= 2; - - while ($section_text =~ m/^(\d+)\s(.*?)^(?=\d)/msgc or $section_text =~ m/^(\d+)\s(.*)/msg) { - my $p = $1 ; - my $t = $2; - - print "paragraph $p: [$t]\n" if $debug >= 3; - - if ($paragraph_specified == $USER_SPECIFIED and not length $search and $p == $paragraph) { - $result = $t if not $found; - $found_paragraph = $p; - $found_section = $this_section; - $found_section_title = $section_title; - $found = 1; - last; - } - - if (length $search) { - eval { - if ($t =~ m/\b$search/mis or $section_title =~ m/\b$search/mis) { - $matches++; - if ($matches >= $match) { - if ($list_only) { - $result .= sprintf("%s%-15s", $comma, $this_section."p".$p); - $result .= " $section_title" if $list_titles; - $comma = ",\n "; - } else { - if (not $found) { - $result = $t; - $found_section = $this_section; - $found_section_title = $section_title; - $found_paragraph = $p; - $paragraph_specified = $RESULTS_SPECIFIED; - } - $found = 1; - } - } - } - }; - - if ($@) { - print "Error in search regex; you may need to escape characters such as *, ?, ., etc.\n"; - exit 0; - } - } - } - - last if $found && $paragraph_specified == $USER_SPECIFIED; - - if ($paragraph_specified == $USER_SPECIFIED) { - print "No such paragraph '$paragraph' in section '$section' of n1256.\n"; - exit 0; - } - - if (defined $section_specified and not length $search) { - $found = 1; - $found_section = $this_section; - $found_section_title = $section_title; - $found_paragraph = $paragraph; - $result = $section_text; - last; - } -} - -if (not $found and $comma eq "") { - $search =~ s/\\s\+/ /g; - if ($section_specified) { - print "No such text '$search' found within section '$section' in C99 Draft Standard (n1256).\n" if length $search; - print "No such section '$section' in C99 Draft Standard (n1256).\n" if not length $search; - exit 0; - } - - print "No such section '$section' in C99 Draft Standard (n1256).\n" if not length $search; - print "No such text '$search' found in C99 Draft Standard (n1256).\n" if length $search; - exit 0; -} - -$result =~ s/$found_section_title// if length $found_section_title; -$result =~ s/^\s+//; -$result =~ s/\s+$//; -=cut -$result =~ s/\s+/ /g; -$result =~ s/[\n\r]/ /g; -=cut - -if ($matches > 1 and not $list_only) { - print "Displaying \#$match of $matches matches: "; -} - -if ($comma eq "") { -=cut - print $found_section; - print "p" . $found_paragraph if $paragraph_specified; -=cut - print "\nhttp://blackshell.com/~msmud/cstd.html\#$found_section"; - print "p" . $found_paragraph if $paragraph_specified; - print "\n\n"; - print "[", $found_section_title, "]\n\n" if length $found_section_title; -} - -print "$result\n"; diff --git a/modules/google.pl b/modules/google.pl deleted file mode 100755 index 03cb7c7f..00000000 --- a/modules/google.pl +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/perl -w - -# 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/. - -# Quick and dirty by :pragma - -use LWP::UserAgent; - -my ($text, $arguments, $header, $footer, $t, $matches); - -$header = ""; -$footer = undef; -$matches = 1; - -if ($#ARGV < 0) -{ - print "Usage: google [number of results] query\n"; - die; -} - -$arguments = join("+", @ARGV); - -if ($arguments =~ m/([0-9]+)\+/) -{ - $matches = $1; - $arguments =~ s/$1//; -} - -my $ua = LWP::UserAgent->new; -$ua->agent("Mozilla/5.0"); - -my $response = $ua->get("http://www.google.com/search?q=$arguments"); - -if (not $response->is_success) -{ - print "Couldn't get google information.\n"; - die; -} - -$text = $response->content; - -$arguments =~ s/\+/ /g; - -if ($text =~ m/No pages were found/) -{ - print "No results found for '$arguments'.\n"; - die; -} - -if ($text =~ m/Results/g) -{ - $text =~ m/1<\/b> - .*?<\/b> of (about )?(.*?)<\/b>/g; - $header = $2; -} - -if ($text =~ m/Did you mean\:/g) -{ - $text =~ m/(.*?)<\/i>/g; - $footer = "Alternatively, try '$1' for more results."; -} - -print "$arguments ($header): "; - - -if ($text =~ m/Showing web page information/g) -{ - $text =~ m/

(.*?)
/g; - $header = $1; - $header =~ s/<.*?>//g; - print "$header"; - - if ($text =~ m/Description:(.*?)
/) - { - $header = $1; - $header =~ s/<.*?>//g; - print " - $header\n"; - } - die; -} - - -$matches = 5 if ($matches > 5); - -my $i = 0; - -my $quote = chr(226) . chr(128) . chr(156); -my $quote2 = chr(226) . chr(128) . chr(157); -my $dash = chr(226) . chr(128) . chr(147); - -while ($text =~ m/

  • (.*?)<\/a>/g && $i < $matches) -{ - if ($i > 0) - { - $t = ", $2: [$1]"; - } - else - { - $t = "$2: [$1]"; - } - $t =~ s/<[^>]+>//g; - $t =~ s/<\/[^>]+>//g; - $t =~ s/$quote/"/g; - $t =~ s/$quote2/"/g; - $t =~ s/$dash/-/g; - $t =~ s/"/"/g; - $t =~ s/&/&/g; - $t =~ s/&nsb;/ /g; - $t =~ s/'/'/g; - $t =~ s/<//g; - $t =~ s///g; - $t =~ s/<\/em>//g; - print $t; - $i++; - -#while ($t =~ m/(.)/g) -#{ -# print "($1) = " . ord($1). "\n"; -#} - -} - - -print " - $footer\n" if defined $footer; diff --git a/modules/gspy.pl b/modules/gspy.pl deleted file mode 100755 index 38ec1479..00000000 --- a/modules/gspy.pl +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/perl -w - -# 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 LWP::Simple; - -my $html; - -$html = get("http://www.metaspy.com/info.metac.spy/metaspy/unfiltered.htm"); - -defined $html or die "Oops, couldn't get the data."; - - -print "Recent search queries: "; - -while ($html =~ m/redir\.htm\?qkw\=(.*?)\"/g) -{ - print "$1, "; -} diff --git a/modules/gtop10.pl b/modules/gtop10.pl deleted file mode 100755 index bccb9716..00000000 --- a/modules/gtop10.pl +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/perl -w - -# 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 LWP::Simple; - -my $html; - -$html = get("http://www.google.com/press/zeitgeist.html"); - -defined $html or die "Oops, couldn't get the data."; - - -print "Top 10 Google search queries: "; - -while ($html =~ m/(.*?)<\/a>/g) -{ - print "$1, "; -} diff --git a/modules/gtop15.pl b/modules/gtop15.pl deleted file mode 100755 index e258270f..00000000 --- a/modules/gtop15.pl +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/perl -w - -# 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 LWP::Simple; - -my $html; - -if ($#ARGV < 0) -{ - print "Usage: !gtop15 country\n"; - exit 0; -} - -my $country = join " ", @ARGV; - -$country = lc $country; - -$html = get("http://www.google.com/press/intl-zeitgeist.html"); - -defined $html or die "Oops, couldn't get the data."; - -my %countries; - -while ($html =~ m/(.*?)<\/a>/g) -{ - $countries{$1} = $2; -} - -my $found = 0; - -if (not defined $countries{$country}) -{ - foreach my $c (values %countries) - { - if (lc $c eq $country) - { - $found = 1; - $country = $c; - last; - } - } -} -else -{ - $found = 1; -} - -if ($found == 0) -{ - print "Unknown country, valid countries are "; - foreach my $c (sort keys %countries) - { - print "$c,"; - } - exit 0; -} - -my %countries2; - -if (length($country) == 2) -{ - %countries2 = %countries; -} -else -{ - %countries2 = reverse %countries; -} - -print "Top 15 Google search queries ($countries2{$country}): "; - -$country = $countries2{$country} if (length($country) == 2); - -$html =~ m/.*?\s*$country\s*<\/b>/gms; - -my $i = 15; -while ($html =~ m/\s*(.*?)\s*<\/a>(.*?)<\/li>/gms) -{ - my $result = $1; - if (length $2) - { - $2 =~ m/\s*(.*?)<\/span>/; - $result = $1; - } - else - { - $result=~s/[^\t -~]//g; - -# print "[[$1]]\n"; -# my $p = $1; -# $result = ""; -# while ($p =~ m/(.)/g) -# { -# print $1 . "[" . ord($1) . "]"; -# next; - -# if (ord($1) > 122) -# { -# $p =~ m/./g; -# next; -# } -# next if (ord($1) < 97 && ord($1) > 122 && ord($1) < 65 && ord($1) > 90 -# && ord($1) < 48 && ord($1) > 57); - -# $result .= $1; -# } - } - print "$result, "; - last if (--$i == 0); -} diff --git a/modules/seen.pl b/modules/seen.pl deleted file mode 100755 index 6244d659..00000000 --- a/modules/seen.pl +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/perl -w - -# 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 strict; - -if ($#ARGV != 0) -{ - print "Usage: !seen nick\n"; - exit 0; -} - -my $nick = $ARGV[0]; - -my $file = "/home/msmud/irclogs/freenode/##c.log"; - -open(FILE, "< $file") - or die "Can't open $file for reading: $!\n"; - -seek(FILE, 0, 2); # seek to end of file - -my $pos = tell(FILE) - 2; -my $char; -my $result; - -while (seek(FILE, $pos--, 0)) -{ - read(FILE, $char, 1); - if ($char eq "\n") - { - my $line = ; - chomp $line; - - next if not defined $line; - - if ($line =~ m/^(\d\d:\d\d) -!- $nick (.*?)$/i) - { - $result = "date at $1: $nick $2\n"; - } - elsif ($line =~ m/^(\d\d:\d\d) <\s*$nick> (.*?)$/i) - { - $result = "date at $1: <$nick> $2\n"; - } - elsif ($line =~ m/^(\d\d:\d\d) * $nick (.*?)$/i) - { - $result = "date at $1: $nick $2\n"; - } - last if defined $result; - } -} - -if (defined $result) -{ - my $date; - - while (seek(FILE, $pos--, 0)) - { - read(FILE, $char, 1); - if ($char eq "\n") - { - my $line = ; - chomp($line); - - if ($line =~ m/^--- Log opened (.*?) \d\d:\d\d:\d\d(.*?)$/) - { - $date = $1 . $2; - last; - } - elsif ($line =~ m/^--- Day changed (.*?)$/) - { - $date = $1; - last; - } - } - } - - $result =~ s/^date/$date/; - print $result; -} -else -{ - print "I haven't seen $nick.\n"; -} - -close(FILE); diff --git a/modules/weather.pl b/modules/weather.pl deleted file mode 100755 index 7a6ea625..00000000 --- a/modules/weather.pl +++ /dev/null @@ -1,227 +0,0 @@ -#!/usr/bin/perl - -# 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 LWP::Simple; - -my ($text, $weather, $location, $date, $i, $day, @days); - -if ($#ARGV < 0) -{ - print "Try again. Please specify the location you would like weather for.\n"; - die; -} - -$location = join("+", @ARGV); - -$location =~ s/,/%2C/; - -if ($location =~ m/\+-(.*)/) -{ - $date = $1; - $location =~ s/\+-.*//; -} - -$i = 0; - -$text = get("http://weather.yahoo.com/search/weather2?p=$location"); - -$location =~ s/\+/ /g; -$location =~ s/%2C/,/g; - -if ($text =~ m/No match found/) -{ - print "$location is not a valid location for this service.\n"; - die; -} - -my $found = 0; -my $buf; - - -if ($text =~ m/location matches\:/g) -{ - $buf = "Multiple locations found: "; - - while ($text =~ m/(.*?)<\/a>/g) - { - $i = $1; - $weather = $2; - - $weather =~ s///g; - $weather =~ s/<\/b>//g; - $weather =~ s/^\s+//; - - $buf = $buf . "$weather - "; - - if ($location =~ m/$weather/i) - { - $text = get("http://weather.yahoo.com/forecast/$i"); - $found = 1; - } - } - $buf = $buf. "please specify one of these.\n"; - if (not $found) - { - print $buf; - die; - } -} - - my ($update, $temp, $high, $low, $tempc, $highc, $lowc, $cond, - $today, $tonight, $country, $state, $city, $humid, $wind, - $sunup, $sundown, $feels, $feelsc); - - $text =~ m/Weather<\/a>\s>/g; - $text =~ m/(.*?)<\/a>\s>/g; - $country = $1; - - if ($country eq "North America") - { - $text =~ m/(.*?)<\/a>\s>/g; - $country = $1; - } - - if ($country ne "Canada") - { - $text =~ m/(.*?)<\/a>\s>/g; - $state = $1; - } - - $text =~ m/^(.*?)<\/b><\/font>/mg; - $city = $1; - - $update = $1 - if $text =~ m/at:\s(.*?)<\/font><\/td>/gi; - - - while ($text =~ -m/(.*?)<\/b>/g) - { - push(@days, $1); - } - - foreach $day (@days) - { - if ($date =~ m/$day/i) - { - $date = $i; - last; - } - $i = $i + 1; - } - - if ($i > 4 && $date ne "") - { - print("\'$date\' is not a valid day, valid days for $country, $state, $city are: ", - join(" ", @days[1,2,3,4]), "\n"); - die; - } - - $text =~ m/Currently:/g; - $temp = $1 - if ($text =~ m/(.*?)°/g); - - if ($date == 0) - { - $text =~ m/Arial\ssize=2>(.*?)(.*?)&/mgi; - $cond = $1; - } - } - - if ($cond eq "Unknown") - { - for($i = 0; $i <= $date; $i++) - { - $text =~ m/(.*?)&/mgi; - $cond = $1; - } - } - - for($i = 0; $i <= $date; $i++) - { - $text =~ -m/High\:.*?size=3\sface=Arial>\n\s\s(.*?)\&/sgi; - $high = $1; - } - - for($i = 0; $i <= $date; $i++) - { - $text =~ -m/Low\:.*?size=3\sface=Arial>\n\s(.*?)\&/sgi; - $low = $1; - } - - if ($text =~ m/More Current Conditions<\/b>/g) - { - - $text =~ m/Feels Like:/g; - $feels = $1 - if ($text =~ m/size=2>\n(.*?)°/sg); - - $text =~ m/Wind:/g; - $wind = $1 - if ($text =~ m/size=2>\n(.*?)\n(.*?)\n/sg); - - $text =~ m/Sunrise:/g; - $sunup = $1 - if ($text =~ m/size=2>\n(.*?)\n(.*?)Today:<\/b>\s(.*?)

    /g; - - $tonight = "Tonight: $1" - if $text =~ m/Tonight:<\/b>\s(.*?)

    /g; - - $feelsc = int(5/9*($feels - 32)); - $tempc = int(5/9*($temp - 32)); - $highc = int(5/9*($high - 32)); - $lowc = int(5/9*($low - 32)); - - if ($date > 0) - { - $date = "[".$days[$date]."] "; - } - - $date =~ s/Mon/Monday/i; - $date =~ s/Tue/Tuesday/i; - $date =~ s/Wed/Wednesday/i; - $date =~ s/Thu/Thursday/i; - $date =~ s/Fri/Friday/i; - $date =~ s/Sat/Saturday/i; - $date =~ s/Sun/Sunday/i; - - - if ($date eq "") - { - print "$country, $state, $city (Updated $update): Temp: ".$temp."F/".$tempc."C (Feels like: $feels"."F/".$feelsc."C), ". - "High: ".$high."F/".$highc."C, Low: ".$low."F/".$lowc."C, ". - "Sky: $cond, Humidity: $humid, Wind: $wind, Sunrise: $sunup, Sunset: $sundown, $today $tonight\n"; - } - else - { - print "$country, $state, $city (Updated $update): $date". - "High: ".$high."F/".$highc."C, Low: ".$low."F/".$lowc."C, ". - "Sky: $cond.\n"; - }