このスクリプトを受け入れることに問題があります。 https://youtu.be/HPP0yB-_blA、https://www.youtube.com/watch?v=HPP0yB-_blAでも動作します。最初の例はinvalid command name ""
になります。無効なコマンド名 ""
# URL title parse script for Eggdrop.
#
# Based on https://github.com/teeli/urltitle by teel.
#
# Version log:
# 0.11 Minor site specific tweaks.
# 0.1 First version.
#
# Usage:
# .chanset #channelname +urltitle ;# Enable script.
namespace eval urltitle {
# Configuration variables.
set delay 1 ;# Minimum number of seconds to wait between uses.
set length 5 ;# Minimum character length of URL to trigger usage.
set timeout 5000 ;# Geturl timeout in milliseconds (1/1000ths of a second).
# Internal variables.
set ignoredSites {apina.biz} ;# Sites to ignore when parsing URLs.
set last 1 ;# Stores time of last usage.
set scriptVersion 0.11 ;# Script version number.
# Binds/Hooks.
bind pubm - "*://*" urltitle::handler
setudef flag urltitle ;# Channel flag to enable script.
# Required packages.
package require http
package require tdom
package require tls
proc socket {args} {
set opts [lrange $args 0 end-2]
set host [lindex $args end-1]
set port [lindex $args end]
::tls::socket -autoservername true {*}$opts $host $port
}
proc handler {nick host user chan text} {
set time [clock seconds]
variable delay
variable ignoredSites
variable last
variable length
if {[channel get $chan urltitle] && ($time - $delay) > $last} {
foreach word [split $text] {
if {[string length $word] >= $length && [regexp {^(f|ht)tp(s|)://} $word] && \
![regexp {://([^/:]*:([^/]*@|\d+(/|$))|.*/\.)} $word]} {
foreach site $ignoredSites {
if {![string match *$site* $word]} {
set last $time
# Enable HTTPS support.
::http::register https 443 [list urltitle::socket]
set title [urltitle::parse $word]
# Disable HTTPS support.
::http::unregister https
# Sends text to the server, like 'putserv', but it uses a different queue intended for sending messages to channels or people.
puthelp "PRIVMSG $chan :$title"
break
}
}
}
}
}
return 1
}
proc parse {url} {
set title ""
variable timeout
if {[info exists url] && [string length $url]} {
if {[catch {set http [::http::geturl $url -timeout $timeout]} results]} {
putlog "Connection to $url failed"
} else {
if {[::http::status $http] == "ok" } {
set data [::http::data $http]
if {[catch {set doc [dom parse -html -simple $data]} results]} {
# Remove HTML comments.
regsub -all {<!--.*?-->} $data {} data
# Remove everything except <head></head> content.
regexp -nocase {<head>.*?</head>} $data match
#regsub -nocase {.*?<head>} $data {} data
#regsub -nocase {</head>.*?} $data {} data
regexp -nocase {<title>(.*?)</title>} $data match title
#set title [regsub -all -nocase {\s+} $title " "]
set title [string trim $title]
} else {
set root [$doc documentElement]
set title [string trim [[$root selectNodes {//head/title[1]/text()}] data]]
$doc delete
}
} else {
putlog "Connection to $url failed"
}
http::cleanup $http
}
}
return $title
}
putlog "URL title parser v$scriptVersion"
}
これは誰でも起こりますか?私は問題がset title [urltitle::parse $word]
だと思うが、私はそれを正しく得ることはできない。
これは有望ですが、明日チェックアウトします。 –
そして、私は必要な修正を加えてPRしました。 –
はい、すべてのウェブサイトに対して書き換えルールを導入するのは間違いありません。私はTCL HTTPリダイレクションの研究を始め、http://wiki.tcl.tk/11831で最初にあなたが作ったコードをいくつか見つけました。今はうまくいっています。助けてくれてありがとう! –