mirror of
				https://github.com/pragma-/pbot.git
				synced 2025-11-04 08:37:24 +01:00 
			
		
		
		
	modules: remove some outdated modules
This commit is contained in:
		
							parent
							
								
									a3caf1755c
								
							
						
					
					
						commit
						e0d50c2f72
					
				
							
								
								
									
										61
									
								
								modules/acronym.pl
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										61
									
								
								modules/acronym.pl
									
									
									
									
										vendored
									
									
								
							@ -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 width=.*?>(.*?)<\/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";
 | 
			
		||||
							
								
								
									
										221
									
								
								modules/cstd.pl
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										221
									
								
								modules/cstd.pl
									
									
									
									
										vendored
									
									
								
							@ -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 <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, "<n1256.txt" or die "Could not open n1256.txt: $!";
 | 
			
		||||
my @contents = <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";
 | 
			
		||||
							
								
								
									
										126
									
								
								modules/google.pl
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										126
									
								
								modules/google.pl
									
									
									
									
										vendored
									
									
								
							@ -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>(.*?)<\/b>/g;
 | 
			
		||||
  $header = $2;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if ($text =~ m/Did you mean\:/g)
 | 
			
		||||
{
 | 
			
		||||
  $text =~ m/<i>(.*?)<\/i>/g;
 | 
			
		||||
  $footer = "Alternatively, try '$1' for more results.";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
print "$arguments ($header): ";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if ($text =~ m/Showing web page information/g)
 | 
			
		||||
{
 | 
			
		||||
  $text =~ m/<p class=g>(.*?)<br>/g;
 | 
			
		||||
  $header = $1;
 | 
			
		||||
  $header =~ s/<.*?>//g;
 | 
			
		||||
  print "$header";
 | 
			
		||||
 | 
			
		||||
  if ($text =~ m/Description:(.*?)<br>/)
 | 
			
		||||
  {
 | 
			
		||||
    $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/<li class=g><h3 class=r><a href=\"(.*?)\".*?>(.*?)<\/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;
 | 
			
		||||
  $t =~ s/<\/em>//g;
 | 
			
		||||
  print $t;
 | 
			
		||||
  $i++;
 | 
			
		||||
 | 
			
		||||
#while ($t =~ m/(.)/g)
 | 
			
		||||
#{
 | 
			
		||||
#  print "($1) = " . ord($1). "\n";
 | 
			
		||||
#}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
print " - $footer\n" if defined $footer;
 | 
			
		||||
							
								
								
									
										21
									
								
								modules/gspy.pl
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								modules/gspy.pl
									
									
									
									
										vendored
									
									
								
							@ -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, ";
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										21
									
								
								modules/gtop10.pl
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								modules/gtop10.pl
									
									
									
									
										vendored
									
									
								
							@ -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/<td class="bodytext2" .*?<a class="style10".*?>(.*?)<\/a>/g)
 | 
			
		||||
{
 | 
			
		||||
  print "$1, ";
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										112
									
								
								modules/gtop15.pl
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										112
									
								
								modules/gtop15.pl
									
									
									
									
										vendored
									
									
								
							@ -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 href="#(.*?)" class="style10">(.*?)<\/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/<td colspan="3"\s*class="zeit_monthly_head">.*?<b>\s*$country\s*<\/b>/gms;
 | 
			
		||||
 | 
			
		||||
my $i = 15;
 | 
			
		||||
while ($html =~ m/<a href=".*?"\s*class="zeit_link">\s*(.*?)\s*<\/a>(.*?)<\/li>/gms)
 | 
			
		||||
{
 | 
			
		||||
  my $result = $1;
 | 
			
		||||
  if (length $2)
 | 
			
		||||
  {
 | 
			
		||||
    $2 =~ m/<span\s*class="zeit_small_txt">\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);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										87
									
								
								modules/seen.pl
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										87
									
								
								modules/seen.pl
									
									
									
									
										vendored
									
									
								
							@ -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 = <FILE>;
 | 
			
		||||
    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 = <FILE>;
 | 
			
		||||
      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);
 | 
			
		||||
							
								
								
									
										227
									
								
								modules/weather.pl
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										227
									
								
								modules/weather.pl
									
									
									
									
										vendored
									
									
								
							@ -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\shref="\/forecast\/(.*?)">(.*?)<\/a>/g)
 | 
			
		||||
  {
 | 
			
		||||
    $i = $1;
 | 
			
		||||
    $weather = $2;
 | 
			
		||||
 | 
			
		||||
    $weather =~ s/<b>//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/<a href="\/">Weather<\/a>\s>/g;
 | 
			
		||||
  $text =~ m/<a href=.*?>(.*?)<\/a>\s>/g;
 | 
			
		||||
  $country = $1;
 | 
			
		||||
 | 
			
		||||
  if ($country eq "North America")
 | 
			
		||||
  {
 | 
			
		||||
    $text =~ m/<a href=.*?>(.*?)<\/a>\s>/g;
 | 
			
		||||
    $country = $1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if ($country ne "Canada")
 | 
			
		||||
  {
 | 
			
		||||
    $text =~ m/<a href=.*?>(.*?)<\/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/<td\swidth\=\".*?align\=center\scolspan\=.*?\sface\=.*?\s.*?<b>(.*?)<\/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/<b>(.*?)°/g);
 | 
			
		||||
 | 
			
		||||
  if ($date == 0)
 | 
			
		||||
  {
 | 
			
		||||
    $text =~ m/Arial\ssize=2>(.*?)</g;
 | 
			
		||||
    $cond = $1
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    for($i = 0; $i <= $date; $i++)
 | 
			
		||||
    {
 | 
			
		||||
      $text =~ m/<td\salign.*?\scolspan.*?size=2>(.*?)&/mgi;
 | 
			
		||||
      $cond = $1;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if ($cond eq "Unknown")
 | 
			
		||||
  {
 | 
			
		||||
    for($i = 0; $i <= $date; $i++)
 | 
			
		||||
    {
 | 
			
		||||
      $text =~ m/<td\salign.*?\scolspan.*?size=2>(.*?)&/mgi;
 | 
			
		||||
      $cond = $1;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  for($i = 0; $i <= $date; $i++)
 | 
			
		||||
  {
 | 
			
		||||
    $text =~
 | 
			
		||||
m/<td\salign=right\scolspan=1.*?face=Arial>High\:.*?size=3\sface=Arial>\n\s\s(.*?)\&/sgi;
 | 
			
		||||
    $high = $1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  for($i = 0; $i <= $date; $i++)
 | 
			
		||||
  {
 | 
			
		||||
    $text =~
 | 
			
		||||
m/<td\salign=right\scolspan=1.*?face=Arial>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(.*?)</sg);
 | 
			
		||||
 | 
			
		||||
  $wind =~ s/\n//g;
 | 
			
		||||
  $wind =~ s/\r//g;
 | 
			
		||||
 | 
			
		||||
  $text =~ m/Humidity:/g;
 | 
			
		||||
  $humid = $1
 | 
			
		||||
  if ($text =~ m/size=2>\n(.*?)\n/sg);
 | 
			
		||||
 | 
			
		||||
  $text =~ m/Sunrise:/g;
 | 
			
		||||
  $sunup = $1
 | 
			
		||||
  if ($text =~ m/size=2>\n(.*?)</sg);
 | 
			
		||||
 | 
			
		||||
  $text =~ m/Sunset:/g;
 | 
			
		||||
  $sundown = $1
 | 
			
		||||
  if ($text =~ m/size=2>\n(.*?)</sg);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  $today = "Today: $1"
 | 
			
		||||
    if $text =~ m/<b>Today:<\/b>\s(.*?)<p>/g;
 | 
			
		||||
 | 
			
		||||
  $tonight = "Tonight: $1"
 | 
			
		||||
    if $text =~ m/<b>Tonight:<\/b>\s(.*?)<p>/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";
 | 
			
		||||
  }
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user