From 009a87ffad8d3ea804dba65aedef7fddec7aa6d2 Mon Sep 17 00:00:00 2001 From: lookshe Date: Sun, 9 Sep 2012 21:02:03 +0200 Subject: don't know what changed, but there's something ;-) --- decision.tcl | 5 ++- eggdrop-pisg_mff.tcl | 47 ++++++++++++++++++++++++ join_mitsu.tcl | 11 ++++++ wiki.tcl | 6 ++++ wiki_export.pl | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++ youtube.pl | 26 ++++++++++++++ 6 files changed, 194 insertions(+), 1 deletion(-) create mode 100644 eggdrop-pisg_mff.tcl create mode 100644 join_mitsu.tcl create mode 100644 wiki_export.pl create mode 100644 youtube.pl diff --git a/decision.tcl b/decision.tcl index f0eb41c..8cf6967 100644 --- a/decision.tcl +++ b/decision.tcl @@ -72,6 +72,9 @@ if {[info exists do_dec($nick:$chan)]} { } set allargs [string map {" " _} $arguments] + set allargs [string map {"\[" _} $allargs] + set allargs [string map {"]" _} $allargs] +#putlog "all: $allargs" set arguments [split $arguments] set count 1 set klammer_count 0 @@ -97,7 +100,7 @@ if {[info exists do_dec($nick:$chan)]} { set myrand [rand $klammer_count] if {[info exists do_dec($allargs)]} { set myrand $do_dec($allargs) - timer 60 "unset do_dec($allargs)" + #timer 1 "unset do_dec($allargs)" } else { set do_dec($allargs) $myrand timer 60 "unset do_dec($allargs)" diff --git a/eggdrop-pisg_mff.tcl b/eggdrop-pisg_mff.tcl new file mode 100644 index 0000000..5311f3c --- /dev/null +++ b/eggdrop-pisg_mff.tcl @@ -0,0 +1,47 @@ +#pisg.tcl v0.15 by HM2K - auto stats script for pisg (perl irc statistics generator) +#based on a script by Arganan + +# WARNING - READ THIS +# +# If you use this script, PLEASE read the documentation about the "Silent" +# option. If you get the message "an error occured: Pisg v0.67 - perl irc +# statistics generator" in the channel, you are NOT running silent. Fix it. + +set pisgver "0.15" + +#Location of pisg execuitable perl script +set pisgexe "/home/eggdrop/eggdrop/pisg/pisg" + +#URL of the generated stats +set pisgurl "http://www.thehappy.de/~lookshe/pub/logs" + +#channel that the stats are generated for +set pisgchan "#mitsu_caht_runde" + +#Users with these flags can operate this function +set pisgflags "nm" + +#How often the stats will be updated in minutes, ie: 30 - stats will be updated every 30 minutes +set pisgtime "1440" + +bind pub $pisgflags !stats pub:pisgcmd + +proc pub:pisgcmd {nick host hand chan arg} { + global pisgexe pisgurl pisgchan + append out "PRIVMSG $pisgchan :" ; if {[catch {exec $pisgexe} error]} { append out "$pisgexe an error occured: [string totitle $error]" } else { append out "Stats Updated: $pisgurl" } + # puthelp $out +} + +proc pisgcmd_timer {} { + global pisgexe pisgurl pisgchan pisgtime + append out "PRIVMSG $pisgchan :" ; if {[catch {exec $pisgexe} error]} { append out "$pisgexe an error occured: [string totitle $error]" } else { append out "Stats Updated: $pisgurl" } + # puthelp $out + timer $pisgtime pisgcmd_timer +} + +if {![info exists {pisgset}]} { + set pisgset 1 + timer 2 pisgcmd_timer +} + +putlog "pisg.tcl $pisgver loaded" diff --git a/join_mitsu.tcl b/join_mitsu.tcl new file mode 100644 index 0000000..f1b260f --- /dev/null +++ b/join_mitsu.tcl @@ -0,0 +1,11 @@ +bind join - "#mitsu_chat_runde" join_help + +proc join_help {nick host hand chan} { + global botnick + if {$botnick == $nick} { + return 0 + } + putserv "PRIVMSG $chan :Willkommen im MFF-Chat $nick, stelle einfach deine Frage oder sag einfach nur Hallo. Warte bitte eine Weile auf Antwort, da die User auch ein Privatleben haben ;-) (PS: Ich bin nur ein Bot)" +} + +putlog "join_mitsu by lookshe loaded" diff --git a/wiki.tcl b/wiki.tcl index a461114..5135a92 100644 --- a/wiki.tcl +++ b/wiki.tcl @@ -3,6 +3,7 @@ bind pub - !wiki wiki bind pub - !ewiki ewiki #bind pub - !say say +bind pub - !mitsu mitsu bind pub - !google say proc say {nick host hand chan arg} { @@ -10,6 +11,11 @@ proc say {nick host hand chan arg} { # putserv "PRIVMSG $chan :das hier ist [string trimleft $chan #]"; } +proc mitsu {nick host hand chan arg} { + putserv "PRIVMSG $chan :www.mitsu-talk.de"; +# putserv "PRIVMSG $chan :das hier ist [string trimleft $chan #]"; +} + proc wiki {nick host hand chan arg} { global do_wiki if {[info exists do_wiki($nick:$chan)]} { diff --git a/wiki_export.pl b/wiki_export.pl new file mode 100644 index 0000000..b41a341 --- /dev/null +++ b/wiki_export.pl @@ -0,0 +1,100 @@ +#!/usr/bin/perl + +#use strict; +#use warnings; +use Web::Scraper; +use URI; +use HTML::Entities; +use Encode; +use URI::Escape; +use LWP::UserAgent; + +my $scrap; + +my $lang = $ARGV[1]; +if (!$lang) { + $lang = "de"; +} +my $wikiurl = "http://$lang.wikipedia.org/wiki/Special:Search?search=$ARGV[0]&go=Go"; + +my $ua = new LWP::UserAgent; +my $req = HTTP::Request->new('GET', $wikiurl); +my $res = $ua->request($req); +my $url = $res->request->uri; +my $origurl = $url; +$url =~ s/.*\/wiki\///; + +binmode(STDOUT, ":utf8"); + +if ($url !~ m/Special:Search/) { +#artikel + + $scrap = scraper { + process '//div[@id="bodyContent"]/p', 'text[]' => 'TEXT'; + process '//img', 'img[]' => '@src'; + process '//div[@id="bodyContent"]/ul/li', 'list[]' => 'TEXT'; + process '//table/tr/td', 'table[]' => 'TEXT'; + }; + $url = URI->new($wikiurl); + + my $res = $scrap->scrape($url); + my $text = $res->{'text'}; + my $img = $res->{'img'}; + my $list = $res->{'list'}; + my $table = $res->{'table'}; + my $isDis = 0; + + if ($#$table > 0) { + foreach (@$img) { +#print "$_\n"; +# if ($_ =~ m/^http:\/\/upload\.wikimedia\.org\/wikipedia\/commons\/thumb\/.*\/.*\/Disambig/) { + if ($_ =~ m/Disambig/i) { + $isDis = 1; + last; + } + } + } + if (!$isDis) { + $text = decode_entities($$text[0]); + $text =~ s/\([^\(\)]*\)||\[[^\[\]]*\]//g; + $text =~ s/\([^\(\)]*\)||\[[^\[\]]*\]//g; + $text =~ s/\([^\(\)]*\)||\[[^\[\]]*\]//g; + $text =~ s/\([^\(\)]*\)||\[[^\[\]]*\]//g; + $text =~ s/\s+/ /g; + $text =~ s/\s([,.\?!])/$1/g; + + if ($text =~ m/.{448}.*/) { + $text =~ s/^(.{448}).*$/$1/; + $text =~ s/^(.*[\.!\?])[^\.!\?]*$/$1 (...)/; + } + + print $text, "\n"; + } else { + for ($count = 0; $count < 3 && $count <= $#$list; $count++) { + print "$$list[$count]\n"; + } + print "For more see $origurl\n"; + } + +} else { +#kein artikel + + $scrap = scraper { + process '//div[@class="searchresult"]', 'text[]' => 'TEXT'; + process '//ul[@class="mw-search-results"]/li/div/a', 'href[]' => '@href'; + }; + $url = URI->new($wikiurl); + + my $res = $scrap->scrape($url); + if (keys(%$res)) { + my $text = $res->{'text'}; + my $href = $res->{'href'}; + my $result = ""; + for ($count = 0; $count < 5 && $count <= $#$text; $count++) { + $result = ($result?"$result || ":"").$$href[$count], "\n"; + } + print "$result\n"; + } else { + print "No matches with $ARGV[0]\n"; + } +} diff --git a/youtube.pl b/youtube.pl new file mode 100644 index 0000000..1291af2 --- /dev/null +++ b/youtube.pl @@ -0,0 +1,26 @@ +#!/usr/bin/perl + +use LWP::Simple; + +if ($#ARGV != 0) +{ + exit; +} + +my ($url, $content, $title); +$url = $ARGV[0]; + +$content = get($url); + +if (!defined $content) +{ + exit; +} + +if ($content =~ m/(.*?)<\/title>/s) +{ + $title = $1; + $title =~ s/^\s+//; + $title =~ s/\s+- YouTube\s+$//; + print "$title"; +} -- cgit v1.2.3