steamid.tcl

steamid.tcl

Post information about a steam user id on irc channel.

Postat de Copyright Categorie Review user Vizualizari Data
btc C.Leonhardt games Cod netestat 469 2023-12-25 12:07:34

# SteamID Counter-Strike Lookup Script for Eggdrop/TCL - Data Source: www.steamid.com
# Copyright C.Leonhardt Nov.24.2006 rosc2112 at yahoo com  http://members.dandy.net/~fbn/steamid.tcl.txt
set sidver "0.1a"
#-----------------------------------------------------------------------------------------------------------

# Usage: Commands typed in channel or privmsg to the bot
#        .steamid help | 
#        .sid help     | show the complete helpfile

# When reporting bugs, PLEASE include the .set errorInfo debug info!
# Read: http://forum.egghelp.org/viewtopic.php?t=10215

# Note: Searching for strings that would return the max results (100 results) does take a minute or two on
#       my decidedly slow P2/266 (for example, searching for 'a' under player names or handles).. YMMV.  
#       Try doing more specific searches to limit this delay.

#-----------------------------------------------------------------------------------------------------------
# Config #
#--------#

# Channels where we allow public use:
set sidchans "#mychan #chan2 #etc"

# Out of the above channels, these channels will send responses to PRIVMSG
set sidquietchans "#chan2 #etc"

# Timeout for the geturl operation (1/1000's of a second)
set sidtimeout "30000"

# Your prefered command prefix (eg, if command is !steamid, the prefix is !)
set sidcmdprefix "."

# The max number of lines you want to return (steamid.com seems to have a limit of 100 lines/matches.)
# Set this to zero for no limit
set sidmaxlines 5

#-----------------------------------------------------------------------------------------------------------
# Code below #
#------------#

package require http

bind pub - ${sidcmdprefix}steamid steamidpub
bind pub - ${sidcmdprefix}sid steamidpub
bind msg - ${sidcmdprefix}steamid steamidmsg
bind msg - ${sidcmdprefix}sid steamidmsg

proc steamidmsg {nick uhost hand text} {
	if {(![onchan $nick]) && (![validuser $nick])} {return}
	steamidpub $nick $uhost $hand privmsg $text
	return
}       

proc steamidpub {nick uhost hand chan text} {
	if {([lsearch -exact $::sidchans $chan] == -1) && ($chan != "privmsg")} {return}
	if {([lsearch -exact $::sidquietchans $chan] != -1) || ($chan == "privmsg")} {set chan $nick}
	set text [split [string trim [string tolower $text]]]
	set sidcmd [lindex $text 0]
	set sidreq [lrange $text 1 end]
	if {$sidcmd == "help"} {
		# show help
		puthelp "PRIVMSG $nick :SteamID Lookup Script by Rosc2112 - Type commands in channel or /msg $::botnick"
		puthelp "PRIVMSG $nick :To lookup by ID Number    : \002${::sidcmdprefix}sid id <steamid number>\002"
		puthelp "PRIVMSG $nick :To lookup by Player Handle: \002${::sidcmdprefix}sid ph <player handle>\002"
		puthelp "PRIVMSG $nick :To lookup by Player Name  : \002${::sidcmdprefix}sid pn <player name>\002"
		puthelp "PRIVMSG $nick :To lookup by IRC Channel  : \002${::sidcmdprefix}sid irc <#channelname>\002"
		puthelp "PRIVMSG $nick :To lookup by Tag          : \002${::sidcmdprefix}sid tag <tag name>\002"
		puthelp "PRIVMSG $nick :To lookup by Clan Name    : \002${::sidcmdprefix}sid clan <clan name>\002"
		return
	} elseif {$sidcmd == "id"} {
		# query steamid
		set sidcmd "steamid"
	} elseif {$sidcmd == "ph"} {
		# query player handle
		set sidcmd "playerhandle"
	} elseif {$sidcmd == "irc"} {
		# query irc
		set sidcmd "irc"
	} elseif {$sidcmd == "clan"} {
		# query clanname
		set sidcmd "clanname"
	} elseif {$sidcmd == "pn"} {
		# query player name
		set sidcmd "playername"
	} elseif {$sidcmd == "tag"} {
		# query tag
		set sidcmd "tag"
	} else {
		puthelp "PRIVMSG $nick :I did not understand your command, try \002${::sidcmdprefix}sid help\002"
		return
	}
	set sidrequ [string map -nocase $::sidmap [join $sidreq]]
	set sidurl "http://www.steamid.com/?sb=$sidcmd&qvalue=$sidrequ"
	catch {set page [::http::geturl $sidurl -timeout $::sidtimeout]} error
	if {[string match -nocase "*couldn't open socket*" $error]} {
		puthelp "PRIVMSG $nick :Error: couldn't connect to SteamID.Com..Try again later"
		::http::cleanup $page
		return
	}
	if { [::http::status $page] == "timeout" } {
		puthelp "PRIVMSG $nick :Error: Connection to SteamID.Com timed out."
		::http::cleanup $page
		return
	}
	set html [::http::data $page]
	::http::cleanup $page
	if {[regexp {>No results found.</td>} $html]} {
		puthelp "PRIVMSG $nick :SteamID.Com: No results found for '\002[join $sidreq]\002'"
		return
	}
	set nummatch 0;set sids 0;set sidup "";set sidmatches "";set sidno "";set sleague "";set slocation ""
	set sdivision "";set sclanurl "";set sclanname "";set srecord "";set sirc "";set stag "";set shandurl ""
	set shandle "";set sname "";set sidtemp "";set linecount 0
	putquick "PRIVMSG $chan :Searching SteamID.com - please wait..."
	regexp {>Your Search Results: (.*?) matches in .*? seconds.</span>} $html match nummatch
	regexp {>Searched (.*?) SteamIDs. Database last updated (.*?)</span>} $html match sids sidup
	if {$sids > 0} {
		regexp {>Name</span>(.*?)>Searched .*?</span>} $html match sidmatches
		putquick "PRIVMSG $chan :SteamID.Com: Found \002$nummatch\002 Matches \[\002$sids\002 ID's Searched\] - DB Updated: \002$sidup\002"
		foreach line [split $sidmatches \n] {
			regsub {</a></td></tr>} $line {} line
			regsub {<tr bgcolor="#4965FF"><td colspan=10><span class="smwn"} $line {} line
			incr linecount
			if {$line != ""} {
				regexp {<tr.*?><td><span.*?>(.*?)</span></td><td><span.*?>(.*?)</span></td><td><span.*?>(.*?)</span></td><td><span.*?>(.*?)</span></td><td><span.*?><a target=\"_blank\" href=\"(.*?)\">(.*?)</a></span></td><td><span.*?>(.*?)</span></td><td><span.*?>(.*?)</span></td><td><span.*?>(.*?)</span></td><td><span.*?><a target=\"_blank\" href=\"(.*?)\">(.*?)</a></span></td><td><span.*?>(.*?)</span></td></tr>} $line match sidno sleague slocation sdivision sclanurl sclanname srecord sirc stag shandurl shandle sname
				set line [format "\002SteamID\002:%s \002League\002:%s \002Loc\002:%s \002Div\002:%s \002Clan\002:%s \002ClanURL\002:%s \002Rec\002:%s \002IRC\002:%s \002Tag\002:%s \002Handle\002:%s \002UserURL\002:%s \002Name\002:%s" $sidno $sleague $slocation $sdivision $sclanname $sclanurl $srecord $sirc $stag $shandle $shandurl $sname]
				if {($::sidmaxlines > 0) && ($linecount > $::sidmaxlines)} {
					puthelp "PRIVMSG $chan :Max number of results shown ($::sidmaxlines max) - Try refining your search to be more specific."
					return
				} else {
					puthelp "PRIVMSG $chan :$line"
				}
			}
		}
		puthelp "PRIVMSG $chan :\[end of SteamID results for '\002[join $sidreq]\002'\]"
	} else {
		puthelp "PRIVMSG $nick :I couldn't find any SteamID matches..sorry.."
		return
	}
}	

set sidmap {
"\ " +  : %3A  \\ %5C  \[ %5B  \] %5D  \# %23  \" %22    \' %27  ! %21  @ %40
$ %24  \( %28  \) %29  ~  %7E  `  %60  %  %25   ^   %5E  \& %26  = %3D  + %2B
| %7C  \{ %7B  \} %7D  /  %2F  \? %3F  ,  %2C   <   %3C   > %3E  ; %3B
}

# Your Search Results: 100 matches in 0.004689 seconds.
# SteamID  League  Location  Division  Clan  Record  IRC   Tag  Handle  Name

putcmdlog "SteamID $sidver Script by Rosc loaded.."