All pastes #1313510 Raw Edit

Miscellany

public text v1 · immutable
#1313510 ·published 2009-01-20 14:39 UTC
rendered paste body
'site find
'ice chat script

Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
	'grab text from irc and parse it
    siteparse message,channel,servernumber
End Sub

function sitetitle(Site)
	'check for for http:// in the url if not there add it
	if instr(ucase(trim(site)),"HTTP://") then 
		sitename = trim(site)
	else
		sitename = "http://"&trim(site)
	end if
	
	'if it does not end with / then add it
	if right(trim(sitename),1)<>"/" then sitename=trim(sitename)+"/"

	'create the object
	set website = CreateObject ( "WinHttp.WinHttpRequest.5.1" )
	website.open "GET", Sitename , false
	website.send
	text = website.responsetext

       	'find the <title>
	for i= 1 to  len(text)-7
		if instr(trim(mid(ucase(text),i,7)),"<TITLE>") then
			z=0
			do
				z=z+1
			loop until right(trim(mid(ucase(text),i,7+z)),8)="</TITLE>"			                        
                        text1 =mid((text),i+7,z-8)
  		end if
	next
	'find the conten type
        content = " || Content: "&website.GetResponseHeader("Content-Type")
        'present the string
        sitetitle = text1&content
 
end function

Sub siteparse(site,channel,servernumber)
		'check the string for a url starting with http://
		if instr(ucase(trim(site)),"HTTP://") then 		'looks for the first url in the string if any
			start=instr(ucase(trim(site)),"HTTP://") 		
			z=0
			do
				z=z+1
			loop until right(mid(site,start,z),1) = " " or z>len(site)					
			if trim(mid(site,start,z))<>"" then SendCommand  "//msg " & channel &" Site Title: "& sitetitle(mid(site,start,z)) ,ServerNumber

			start=start+z
			z=0

			do while start<len(site) 'the loop to find the rest of the urls in the string
				start=start+z
				z=0
				do
					z=z+1
				loop until right(mid(site,start,z),1) = " " or z>len(site)					
				if trim(mid(site,start,z))<>"" then SendCommand  "//msg " & channel &" Site Title: "& sitetitle(mid(site,start,z)) ,ServerNumber
                                
			loop
                    
		end if

end sub