egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

wiki tcl

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
doas
Voice


Joined: 17 May 2021
Posts: 4

PostPosted: Sun Aug 29, 2021 6:43 am    Post subject: wiki tcl Reply with quote

hi

im using this wiki script.

https://paste.ircnow.org/89a7otirkp2v8xq3gd2v/
it was working fine but yesterday i found out its broken and giving me the following error.

!wiki test
<@doas> Error: HTTP query failed (): :

im not sure what went wrong.

can anyone help plz.

regards
Back to top
View user's profile Send private message
mabrook
Halfop


Joined: 14 Jun 2021
Posts: 60

PostPosted: Sun Aug 29, 2021 7:26 am    Post subject: Reply with quote

it seems working but .. need to fix something from the output display..



<users> !wiki test
<Bot> Test(s), testing, or TEST may refer to: Test (assessment), an educational assessment intended to measure the respondents' knowledge or other abilities @media all and (max-width:719px){body.skin-minerva .mw-parser-output .tocright{display:none}}.mw-parser-output .tocright{float:right;clear:right;width:auto;background:none;padding:.5em 0 .8em 1.4em;margin-bottom:.5em}.mw-parser-output
<BOT> Output truncated. https://en.wikipedia.org/wiki/Test



<user> .errorInfo
<BOT> can not find channel named "sock7f6669f50480"
<BOT> while executing
<BOT> "eof $sock"



no idea to fix it.. i hope anyone can help from the community..
Back to top
View user's profile Send private message
doas
Voice


Joined: 17 May 2021
Posts: 4

PostPosted: Mon Sep 06, 2021 9:17 pm    Post subject: Reply with quote

i have mange to get the same reply. have you tried to use any other words? it can be an issue with code or OS ( openbsd). also i have updated all the pkgs but not luck what so ever

here is the code again


Code:

#
# edited Jun 27 2017 for https by genewitch
# ramok on freenode/#tcl knew the fix
#
# Mar 30 2010
# by horgh
#
# Requires Tcl 8.5+ and tcllib
#
# Wikipedia.org fetcher
#
# To enable you must .chanset #channel +wiki
#
# Tests: Whole number (list of possible interpretations)
#

package require http
package require htmlparse
package require tls
::http::register https 443 ::tls::socket


namespace eval wiki {
   variable max_lines 1
   variable max_chars 400
   variable output_cmd "putserv"
   variable url "https://en.wikipedia.org/wiki/"

   #bind pub -|- "!w" wiki::search
   bind pub -|- "!wiki" wiki::search

#   variable parse_regexp {(<table class.*?<p>.*?</p>.*?</table>)??.*?<p>(.*?)</p>\n<table id="toc"}
   variable parse_regexp {(?:</table>)?.*?<p>(.*)((</ul>)|(</p>)).*?((<table id="toc")|(<h2>)|(<table id="disambigbox"))}

   setudef flag wiki
}


proc wiki::fetch {term {url {}}} {
   if {$url != ""} {
      set token [http::geturl $url -timeout 10000]
   } else {
      set query [http::formatQuery [regsub -all -- {\s} $term "_"]]
      set token [http::geturl ${wiki::url}${query} -timeout 10000]
   }
   set data [http::data $token]
   set ncode [http::ncode $token]
   set meta [http::meta $token]
   upvar #0 $token state
   set fetched_url $state(url)
   http::cleanup $token

   # debug
   putlog "Fetch! term: $term url: $url fetched: $fetched_url"
   set fid [open "w-debug.txt" w]
   puts $fid $data
   close $fid

   # Follow redirects
   if {[regexp -- {^3\d{2}$} $ncode]} {
      return [wiki::fetch $term [dict get $meta Location]]
   }

   if {$ncode != 200} {
      error "HTTP query failed ($ncode): $data: $meta"
   }

   # If page returns list of results, choose the first one and fetch that
   #if {[regexp -- {<p>.*?((may refer to:)|(in one of the following senses:))</p>} $data]} {
   #   regexp -- {<ul>.*?<li>.*? title="(.*?)">.*?</li>} $data -> new_query
   #   return [wiki::fetch $new_query]
   #}

   if {![regexp -- $wiki::parse_regexp $data -> out]} {
      error "Parse error"
   }

   return [list url $fetched_url result [wiki::sanitise $out]]
}

proc wiki::sanitise {raw} {
   set raw [::htmlparse::mapEscapes $raw]
   # Remove some help links
   set raw [regsub -- {<small class="metadata">.*?</small>} $raw ""]

   set raw [regsub -all -- {<(.*?)>} $raw ""]
   set raw [regsub -all -- {\[.*?\]} $raw ""]
   set raw [regsub -all -- {\n} $raw " "]
   return $raw
}

proc wiki::search {nick uhost hand chan argv} {
   if {![channel get $chan wiki]} { return }
   if {[string length $argv] == 0} {
      $wiki::output_cmd "PRIVMSG $chan :Please provide a term."
      return
   }

   set argv [string trim $argv]
   # Upper case first character
   set argv [string toupper [string index $argv 0]][string range $argv 1 end]

   if {[catch {wiki::fetch $argv} data]} {
      $wiki::output_cmd "PRIVMSG $chan :Error: $data"
      return
   }

   foreach line [wiki::split_line $wiki::max_chars [dict get $data result]] {
      if {[incr count] > $wiki::max_lines} {
         $wiki::output_cmd "PRIVMSG $chan :Output truncated. [dict get $data url]"
         break
      }
      $wiki::output_cmd "PRIVMSG $chan :$line"
   }
}

# by fedex
proc wiki::split_line {max str} {
   set last [expr {[string length $str] -1}]
   set start 0
   set end [expr {$max -1}]

   set lines []

   while {$start <= $last} {
      if {$last >= $end} {
         set end [string last { } $str $end]
      }

      lappend lines [string trim [string range $str $start $end]]
      set start $end
      set end [expr {$start + $max}]
   }

   return $lines
}

putlog "wiki.tcl loaded"


help!
Back to top
View user's profile Send private message
doas
Voice


Joined: 17 May 2021
Posts: 4

PostPosted: Tue Sep 07, 2021 10:30 am    Post subject: updated all the packages Reply with quote

i have updated all the packages

not its showing
Error: Incorrect number of arguments, must be an even number.

==((LOST))==
Back to top
View user's profile Send private message
mabrook
Halfop


Joined: 14 Jun 2021
Posts: 60

PostPosted: Tue Sep 07, 2021 11:11 am    Post subject: Reply with quote

try this..

https://scripts.eggdrop.fr/details-DictionaryAPI.tcl-s253.html



just giving you another option. if you want to..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber