# Scripts are like children. They grow up to take # on lives of their own, along with all their parents time. # Bots are so obedient, like a wife you never need to slap. #---------------------------------------------------------------# # UNOFFICIAL incith:google v2.0.0c # # # # performs various methods of Google searches # # tested on: # # eggdrop v1.6.17 GNU/LINUX with Tcl 8.4 # # windrop v1.6.17 CYGWIN_NT with Tcl 8.4 (http.tcl v2.5) # # - http.tcl included - Linux/BSD users should NOT need this # # # # UNOFFICIAL NEWS:............................................. # # # # As of 1.9, I (speechless) have rewritten and added several # # pieces of this script, fixing various regexp's, adding # # more search sites to it, added a gamefaqs upcoming list # # for gamers and much much more. # # See the Egghelp forum for info or help you may need: # # http://forum.egghelp.org/viewtopic.php?t=13586 # # # # OFFICIAL NEWS:............................................... # # # # As of v1.6, I (madwoota) have taken over the development of # # incith:google. If you have any feature req's, bugs, ideas, # # etc, please dont hesitate to send them to me. # # My contact details have replaced incith's, but if you wish # # to approach him directly about anything, I can point you # # in the right direction. # # See the Egghelp forum for inciths handover and all the latest# # info on this script: # # http://forum.egghelp.org/viewtopic.php?t=10175 # # # # BASIC USAGE GUIDE:........................................... # # # # .chanset #channel +google # # !google [.google.country.code] [define:|spell:] # # <1+1> <1 cm in ft> # # # # !images [.google.country.code] # # !groups [.google.country.code] # # !news [.google.country.code] # # !local [.google.country.code] near # # !book [.google.country.code] # # !video [.google.country.code] # # !fight vs # # !youtube [.google.country.code] # # !trans region@region # # !gamespot # # !gamefaqs in # # !blog [.google.country.code] # # !ebay [.ebay.country.code] # # !ebayfight vs # # !wikipedia [.2-digit-country-code] [#subtag] # # !wikimedia [.www.wikisite.org[/wiki]] [#subtag] # !locate # # !review [@ ] # # !torrent # # !best # # !worst # # !dailymotion # # !ign # # !myspace # # !trends [.google.country.code] # # # # CHANGE LOG:.................................................. # # # # 1.0: first public release # # 1.1: improved bolding of search terms, compatible with # # chopped descriptions # # supports 'define: ' lookups # # supports calculator. !google (4+3) * 2 - 1 # # - converts, too. !google 1 lb in ounces # # image lookups coded, !images # # 'spell: word1 word2' function added # # - don't rely on this, it's not a dictionary, just # # corrects common typos. # # flood protection added # # 1.2: will wrap long lines (yay, a worthy solution!) # # allowed setting of the seperator instead of a ' | ' by # # default. If you set this to "\n" then you will get # # each result on a seperate line instead of one line # # will display 'did you mean' if no results # # [PDF] links will be parsed/included now # # fixed a bug when no data was returned from google such # # is the case when you search for """""""""""""""""" # # 1.3: can return results in multiple languages now # # fixed quotes being displayed around links # # private messages support added (for /msg !google) # # video.google.com seems impossible, Google Video Viewer # # is required to view videos, etc # # 1.4: bit of a different output, easier to click links now # # local lookups coded, use !local near # # seems google does currency the same way my exchange # # script does (!g 1 usd in cad) # # "patent ##" will return the patent link if it exists # # bugfix in private messages # # sorry to all whom grabbed a borked copy on egghelp :-( # # 1.5: fix for !local returning html on 'Unverified listing's # # "madwoota" has supplied some nice code updates for us! # # - "answer" matches, eg: !g population of japan # # - !g # # - google groups (!gg), google news (!gn) # # - movie: review lookups # # - area code lookups (!g 780) # # - print.google lookups (!gp !print) # # reworked binds to fix horrible bug allowing !g !gi !gp # # case insensitive binds (!gi, !GI, !gI, !Gi, etc) # # .1: fix for double triggers/bad binds # # .2: fix involving "can't read link" error # #-madwoota: # # 1.6: fixed google search returning no results # # fixed descriptions getting cut short on 'answers' # # fixed bug where some urls were returned invalid # # fixed google local searches returning no results # # fixed google print searches returning invalid links # # changed 'did you means' to get returned first as well # # added google weather: !g weather # # - note: US weather only (blame google!) # # added travel info, eg: !g sfo airport | !g united 134 # # added config option to send output via /notice # # added initial attempt at parsing google video (!gv) # # 1.7: added option to force all replies as private (req) # # fixed google groups returning no results # # fixed define: errors on no results # # fixed google print errors on no results/typos # # fixed movie review errors on no results/typos # # fixed some characters not usable as command_chars on # # one of regular eggdrop or windrop+cygwin # # fixed occasional weird response for travel info # # updated requirements to http package 2.4 # # loads of other internal changes # # .1: fixed search parameters not being parsed correctly # # - resulted in some bogus "no results" replies. # # .2: fixed main google search returning rubbish results # # - google changed their source again # # changed all methods of parsing the search results to # # *hopefully* cope better with any source changes # # changed output queue to stop the bot from flooding # # .3: fixed some urls being returned with spaces in them # # - makes them unusable in most irc clients # # fixed google groups occasionally returning junk due to # # changes in 1.7.2 (will revisit this later) # # 1.8: added option to turn on "safe" searches # # added channel user level filtering option (+v/+o only) # # added google fight! !gf or !fight vs # # - inspired by www.googlefight.com # # added ability to do any custom mode to descs & links # # - i'll just apologise now for this one :) # # removed variable underline_links (superseded by above) # # removed use of 'tcl_endOfWord' to stop windrop breaking# # fixed excess %20's appearing in some results # # fixed "translate this" only returns ? (i think) # # stopped local from returning ad spam on first result # #-speechless # # 1.9: updated various regexp's and regsub's in almost all # # procs to fix non functioning html parsing. # # added !localuk option to display United Kingdom. # # added !youtube for searching videos on youtube. # # added !atomfilms for searching videos on atomfilms. # # added !trans for searching videos on trans. # # added !gamespot for searching games, etc. # # added !gamefaqs, it is able to parse multiple systems # # and regions, still a work in progress, all bugs have # # been squashed. # # added !test proc to help debug and dump html for # # future parsing projects. # # .1: added !blog for searching blogsearch.google # # added !ebay for searching ebay auctions. # # added !ebayfight for amusement, same as googlefight. # # fixed various miscellaneous minor annoyances in parts. # # finally fixed !book (aka print) to work with # # books.google # # added !ign for searching movies, games, etc.. # # .2: added support for total_search to show total results # # or not. :) # # added support for link_only (requested). # # added back complete support for desc/link modes # # they will now affect results properly. # # (note: doesn't affect gamefaqs or locate) # # added !locate for dns location information. # # .3: added !wiki for searching wikipedia for things, very # # much a work-in-progress, don't expect it to be # # perfect.. it just reads very top heading so # # sometimes it returns next to nothing.. like I said # # it's WIP so don't bitch, thx. # # added !review for searching gamefaqs and pulling a # # games review, ranking, score, etc.. works similarly # # to the way !wiki does, has same problem, so this # # is also WIP.. thx # # .4: fixed a few regexp parsers to correct broken (no # # results returned) messages in some procs. # # changed google populations to return only 1st desc # # this fixes a small bug where excess html was shown. # # ie. !g population japan || !g population of japan # # fixed google define: links with quick regsub hacks. # # problem with recent ign changing to javascripted html # # so removed their advertising.. too bad for them. # # fixed review and wikipedia to almost perfect. # # note: review does not use forms submittal, instead # # I chose to a single query and field matching on the # # first page returned. I may later use forms submital # # at some later time. # # added two gamerankings triggers (!top/!popular) # # added a mininova torrent search parser. # # fixed parser for !blog by removing quotes. "g" -> g # # beefed up the wikipedia parser so can intelligently # # move to html#subtags to display info. # # removed atomfilms trigger because no one was using. # # added dailymotion trigger for searching tv episodes # # since youtube/google seem to remove those too # # often. # # wikipedia now has ability to properly handle internal # # redirects intelligently as well. # # youtube needed its regexp/regsub parsers tweaked a bit # # to handle new html design. # # google changed format and updated search regexp/sub # # accordingly. # # fixed !local lookups, removed !localuk as it was # # redundant since !local covers UK region now. # # corrected !book to actually produce an output again # # i left broken intentionally earlier because of # # lack of interest, but a guy named Zircon sparked # # my interest again. enjoy. # # gamespot injects paid crap into their html design now # # so found a way to scrape around it.. muahah # # requested by a few people that somehow wikipedia is # # multi-lingual so a fast hack is provided at the # # moment which lacks input checking.. will fix later # # requested by a british friend was the ability as well # # for ebay to work from different countries server. # # this also lacks input checking.. will fix later. # # added error catching for erroneous url's in both # # wikipedia and ebay, this way bad user countries # # will be reported with socket errors. thx rosc2112 # # .5: major modification of script to allow for dynamic # # language selection of _all_ google sites. # # (search,image,news,local,video,book,blog) # # google group is still broken, will fix later :P # # added !trans for google translate. enjoy. # # added stock quotes (supplied by madwoota) # # fixed translation to convertto foreign charsets. # # fixes display of russian and arabic languages. # # corrected google area code map results. # # added google zip code map results. # # corrected google movie review lookups, now works! # # search totals was incorrect on some country google # # lookups. it was using elapsed search time as the # # total results, so now a fallback (else) corrects # # it by replace total results with 'google' in # # those instances. # # youtube undergoing major html changing to keep bots # # from indexing, so changed some parsers to work. # # added back !ign trigger for scraping ign's search # # page for results. # # google answers needed fixing to show correct results. # # added !myspace trigger for searching their video # # content. # # corrected zipcode/areacode/airport. # # corrected all google query possibilities by spending a # # few hours fine tuning everything. Most languages # # should work exactly as planned. Some languages # # "may" display incorrectly, but this is by design # # rather than an error, as the script presently uses # # unicode for everything except google translations. # # major work done to !local fixing it for every possible # # query result in almost every language, try it out # # feeding it nonsense and try to find a flaw. # # small bug concerning !google patent ##### .. wasn't # # being caught as results, now all is well again. # # corrected ebay parser with small change to eliminate # # excess html in 'buy-it-now' parsing. # # UPC codes work again.. yay.. how many use this? 1 guy? # # Ebay, Wikipedia and Google needed minor fixes to # # correct remaining bits that were left untranslated # # now all output will be in language chosen. # # Gamespot changed html design of their page layots for # # reviews, so quick fix to !review proc to handle # # their new design :) # # Corrected 'results' message displayed with totals to # # also be displayed in language searched in, makes # # the output look much more professional. r0x hard. # # All Google triggers are now 100% dialect perfect. # # Fixed small problem with wikipedia's 'no result' # # message being longer than neccessary. # # Added multi-language ability to youtube because it # # now supports it, new default variable for setting # # language default for it as well. enjoy. # # Changed myspace parser query making it less prone to # # breaking. # # Added new trigger !trends to get top search results # # for any date (this is limited by google cache, # # not by the script) and also can be given country # # switches. This is new, at present I cannot go # # back beyond May 2007-05-15 .. # # Added dual results to !ebay trigger for price/bids # # to account for the fact buy-it-now allows bids as # # well... # # Fixed the tiny bug in google answers lookup which # # allowed for cruft to be given as 2nd result. # # Fixed the tiny bug in wikipedia articles that left # # parts of tables in the results. # # Added forced subtagging ability to wikipedia results # # using their standard sub-tag #this so you can now # # force certain sections to being your results and # # it must only begin with the term doesn't need to # # be entire term to force a sub-tag redirect. # # .6: Added !mediawiki trigger following same abilities as # # the wikipedia trigger. This is beta at the moment # # and the reason this script has a revision change. # # Corrected small issue regarding parsing original search# # results which makes this now compatabile with # # every mediawiki page. # # Fixed problem parsers; Groups, News, Book # # Problems with some procs sorted, Gamefaqs modified to # # work with new php site design. # # Fixed issues with stubborn always changing google # # based searches. Now hopefully all triggers work # # again. # # Added prepend ability (Requested) so now each of your # # lines, can be prepended with whatever you desire. # # Added 'time in' feature to google search, allows you # # to find out the time in any region, works like # # population and date. # # Added wiki_line option to expand results. # # .7: Added input/output encoding conversion to better # # realize the multi-language side of this script. # # Corrected mistake in input/output encoding handlers. # # Added a triple lookup for youtube to include all # # possible results and not miss any. # # Corrected issue with wikipedia/wikimedia incorrectly # # removing some elements as page markups. # # Added ability for bold to be seen in wikipedia/wikimedia # results again, removed stripcodes. # # .7a: Expanded Wikimedia and Wikipedia for allowing multi- # # language as well as regional dialects. This also # # allows for expanded custom encoding coverage. # # .7b: Corrected google to return useful results once again. # # broken was define, no_search, did_u_mean, and # # weather. # # Ebay now expanded upon to allow 'store' results to # # appear as well as functional 'did you mean' # # messaging. # # .7c: Added remaining onebox results to google results. # # .8: New features corrected longstanding shortcomings: # # * Wikipedia/Wikimedia now fully decode and encode # # on the fly and translate subtags seamlessly. # # * Main encoding routine now includes a smart URL # # encoder for those using language other than # # english. # # Corrected problem with script handling tcl special # # characters as part of user input. # # .8a: All did you mean messages now report from page exactly # # as they appear. All sites that allow this now # # handle this ability if no results are found. # # .8b: Corrected deficiencies in !translate, it should now # # function better regarding encodings and html # # markups. thx perplexa. # # Corrected minor problem regarding wikipedia's recent # # template change. Now uses similar style as # # wikimedia to prevent issues. # # .8c: Corrected google video as well as added the whois # # onebox to regular google searches. # # Corrected way define: links are handled so encodings # # are dealt with properly. # # .8d: Corrects issue with myspace and regional IP bases. # # .8e: Corrects google video to produce results. # # .8f: Added vocabulary aversion. # # Corrected flaw with wikimedia's encoding process, # # improved overall functionality. # # .8g: Added domain detection for wikimedia domain's which # # aren't using the standard subdomain /wiki. # # .8h: Corrected !torrent # # .8i: Corrected google zipcodes and google video. # # .8j: Corrected youtube and google groups. # # .8k: Corrects some urlencoding problems regarding eggdrops # # complete inability to distinguish between utf-8 # # and iso8859-1. Now requires http 2.5 which allows # # setting the -urlencoding flag. # # Corrects entire script which now uses the -urlencoding # # flag in some way to hopefully force eggdrop to # # understand the differences and force proper # # detections. # # * requirements upped, now requries http 2.5 * # # .8l: Corrects google search (calculations, did_you_mean,etc)# # Corrects google book # # -- experimental version -- # # Adds "automagic" detection to google translations # # Possiblity for more automagic detection in the future # # support procedures in place to allow this already. # # .8m: Adds more "automagic" detection and a more robust # # debugging display. # # Corrected minor display problems. # # .8n: Corrects Googles embolding placement within results, # # can now interpret tags as bold. # # .8o: Added correct support for a true utf-8 workaround. # # .8p: Added proper redirect support. # # Corrected Youtube behavior. # # .8q: Corrected Dailymotion, added multilanguage support to # # it and extended it's capabilities. # # .8r: Corrected minor youtube url inconsitancy. # # .8s: Corrected result totals to appear again for all google # # sites, also corrected other google anamolies. # # Corrected local as well to work with custom locations. # # Added mediawiki customized triggers to allow access # # to mediawiki sites without so much input required. # # .8t: Google template changed,
  • http://forum.egghelp.org/viewtopic.php?t=13586 <-- # # # # LICENSE:..................................................... # # # # This code comes with ABSOLUTELY NO WARRANTY. # # # # This program is free software; you can redistribute it # # and/or modify it under the terms of the GNU General Public # # License as published by the Free Software Foundation; # # either version 2 of the License, or (at your option) any # # later version. # # # # This program is distributed in the hope that it will be # # useful, but WITHOUT ANY WARRANTY; without even the implied # # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR # # PURPOSE. See the GNU General Public License for more # # details. (http://www.gnu.org/copyleft/library.txt) # # # # CREDITS:..................................................... # # # # ..Officially: # # Copyright (C) 2005, Jordan (Incith) # # Currently maintained by madwoota # # google@woota.net # # # # ..Unofficially: # # Copyleft (C) 2006-2010, Speechless # # http://ereader.kiczek.com/scripts # # v2.0.0c - September 9th, 2o11 - speechles <#roms-isos@efnet> # #---------------------------------------------------------------# # EVERYTHING IN THIS SECTION IS USER CUSTOMIZABLE. # BEST SETTINGS ARE DEFAULT, YOU MAY HAVE OTHER IDEAS OF WHAT IS BEST. # # NOTE: some config options won't list how to enable/disable, but # 0 will typically disable an option (turn it off), otherwise a # value 1 or above will enable it (turn it on). # ------ # start of configuration - make your changes in this section # ------ namespace eval incith { namespace eval google { # set this to the command character you want to use for the binds # ------ variable command_char "!" # set these to your preferred binds ("one two three etc etc" - space delimited!) # ------ variable google_binds "g google goog" variable image_binds "i gi image images" variable local_binds "l gl local" variable group_binds "gg group groups" variable news_binds "n gn news" variable print_binds "gb book books" variable video_binds "v gv video" variable scholar_binds "s sc scholar" variable fight_binds "f fight googlefight" variable youtube_binds "y youtube" variable locate_binds "geo loc locate" variable gamespot_binds "gs game gamespot" variable trans_binds "tr trans translate" variable daily_binds "dm daily dailymotion" variable gamefaq_binds "gf gamefaq gamefaqs" variable blog_binds "b blog blogsearch" variable ebay_binds "e ebay" variable efight_binds "ef ebayfight" variable popular_binds "best great bestest" variable rev_binds "r review" variable wiki_binds "w wiki wikipedia" variable wikimedia_binds "wm wikim wikimedia" variable recent_binds "worst crap" variable mininova_binds "t torrent mininova" variable ign_binds "ign igame" variable myspacevids_binds "m myspace myvids" variable trends_binds "gtr trends" variable helpbot_binds "help bot" # to restrict input queries to Ops (+o), Halfops (+h) or Voiced (+v) users on # any +google channel, use this setting. # set the variable to one of the following to achieve the desired filtering: # at least Op -> 3 (obvious) # at least Halfop -> 2 (will also allow ops) # at least Voice -> 1 (will also allow halfops and ops) # everyone -> 0 (no filtering) # # note: this does NOT apply to private messages, use the below setting for them. # ------ variable chan_user_level 0 # if you want to allow users to search via private /msg, enable this # ------ variable private_messages 1 # as per emailed & forum requests, use the next two variables together # to determine the output type like so: # notice_reply 1 & force_private 1 = private notice reply only (this is as requested) # notice_reply 0 & force_private 1 = private msg reply only # notice_reply 1 & force_private 0 = regular channel OR private NOTICE # notice_reply 0 & force_private 0 = regular channel OR private MSG (default) # set to 1 to enable a /notice reply instead, 0 for normal text # ------ variable notice_reply 0 # set to 1 to force all replies to be private # ------ variable force_private 0 # set this to the language you want results in! use 2 letter form. # "all" is the default/standard google.com search. # see http://www.google.com/advanced_search for a list. You have to use # the 'Language' dropdown box, perform a search, and find a line in the URL # that looks like "&lr=lang_en" (for English). "en" is your language code. # popular Ones: it (italian), da (danish), de (german), es (spanish), fr (french) # please note, this does not 'translate', it searches Google in a # language of choice, which means you can still get English results. # ------ # NOTE: Changing this from "all" will effectively disable some of the # multi-language features of this script, doing so is not advised. # ------ variable language "all" # set this to "on" to let google filter "adult content" from any of your search results # "off" means results will not be filtered at all # note: this is only applicable to !google, !images and !groups # ------ variable safe_search "off" # number of search results/image links to return, 'define:' is always 1 as some defs are huge # ------ variable search_results 3 variable image_results 4 variable local_results 4 variable group_results 3 variable news_results 3 variable print_results 3 variable video_results 4 variable scholar_results 4 variable youtube_results 0 variable locate_results 1 variable gamespot_results 3 variable trans_results 1 variable daily_results 4 variable gamefaq_results 20 variable blog_results 3 variable ebay_results 3 variable popular_results 10 variable rev_results 1 variable wiki_results 1 variable wikimedia_results 1 variable recent_results 10 variable mininova_results 3 variable ign_results 3 variable myspacevids_results 3 variable trends_results 25 variable helpbot_results 1 # This part was requested to be added so now here it is, it has # various prepends you may wish to have preceed each function. # To use this, just change what you see below from nothing to # something...ie, if you want [ GOOGLE ] to prepend google # search results change the search_prepend to "\[GOOGLE\]". You # can do the same with all of the following prepends, they will # start the output for each line. If you don't wish to use this, # leave them as "". Keep in mind tcl special characters MUST be # escaped or will cause tcl errors, and/or crash your bot. This # is your own problem, just be aware. Read about them if possible. # # Note 1: Prepends will increase your line length, and won't be # accommodated for in the max line length setting, so you may # find you need to lower your max line length setting if your # prepends are lengthy or contain lots of escape sequences. If # you don't you may find the bots replys may get cut short or # cut completely by the ircd your using. # # Note 2: To use color, bold, etc.. simply use the proper escape # sequence to generate it here, make sure to properly CLOSE your # sequence (\003 for color, \002 for bold, etc) or you will see # the effect of the prepend bleed thru into your output as well. # ------ variable search_prepend "" variable image_prepend "" variable local_prepend "" variable group_prepend "" variable news_prepend "" variable print_prepend "" variable video_prepend "" variable scholar_prepend "" variable youtube_prepend "" variable locate_prepend "" variable gamespot_prepend "" variable fight_prepend "" variable ebayfight_prepend "" variable trans_prepend "" variable dailymotion_prepend "" variable gamefaqs_prepend "" variable blog_prepend "" variable ebay_prepend "" variable popular_prepend "" variable rev_prepend "" variable wiki_prepend "" variable wikimedia_prepend "" variable recent_prepend "" variable mininova_prepend "" variable ign_prepend "" variable myspacevids_prepend "" variable trends_prepend "" # set this to 0 to turn google fight off (it is a tad slow after all ...) # this also disables or enables ebay fights (it's even slower ...) # ------ variable google_fight 1 # ** this is not an optional setting, if a string is too long to send, it won't be sent! ** # it should be set to the max amount of characters that will be received in a public # message by your IRC server. If you find you aren't receiving results, try lowering this. # ------ variable split_length 410 # trimmed length of returned descriptions, only for standard searches. # ------ variable description_length 80 # amount of lines you want your wiki* results to span, the more lines the more # of the wiki article or section you will see, some get cut short if so raise this. # this affects both wikipedia and wikimedia results. # ------ variable wiki_lines 2 # short answers? when google search encounters an answer this # option will make only it show, no other results. this also skips # showing image/news/etc results from other google sites as results. # ------ variable short_answers 1 # skip links to self? google sometimes uses links to it's own # services within normal google searches. This will skip _any_ google # links from appearing within google search results. For some # queries this will omit obvious replies which is normal. # ------ variable skip_self 0 # replace search terms appearing in the description as bolded words? # -> does not bold entire description, just the matching search words # -> this is ignored if desc_modes contains the Bold mode below. # ------ variable bold_descriptions 1 # set this to 0 to turn off total results appearing with searches. # ------ variable total_results 1 # set this to 1 to remove descriptions and set only links to show # ------ variable link_only 0 # set this to the default country you would like *.wikipedia to use when # no country is specified. default is "en". country is 2-letter wiki code. # http://*.wikipedia.org/ - en, de, it, es, fr, these are examples. # ------ variable wiki_country "en" # set this to the default website you would like wikimedia to use when # no website is specified. # ------ variable wikimedia_site "wiki.gbatemp.net/wiki" # Wikimedia URL detection # remove double entries from urls? would remove a '/wikisite' from this # type of url @ http://yoursite.com/wikisite/wikisite/search_term # if you have issues regarding url capture with wikimedia, enable this. # /wiki/wiki/ problems are naturally averted, a setting of 0 already # stops these type. # -------- variable wiki_domain_detect 1 # Customized Trigger Phrasing? # allow customized triggers to be attached to custom phrasing # Anything other than 0 will enable and will use the list below. variable my_custom 1 # Custom Trigger Phrasing # This is used to customize triggers and for # constructing phrases to pass, format is: # "custom-trigger:trigger-to-associate-with:phrase-to-pass" # within the phrase-to-pass, %search% = the users input.. but, # if this is passed onto another custom trigger it will become # the enitre phrase which was passed from the trigger before it. # hopefully people understand how to use these, and remember # to read the lines below this at least twice before # constructiong your phrasing... # DO NOT USE YOUR COMMAND CHAR IN THESE IT IS ASSUMED. # special tcl characters MUST be escaped for you to acheive greatness. variable my_customs { "ch:g:%search% +site:computerhope.com" "eh:g:%search% +site:egghelp.org" "mi:g:%search% +site:mircscripts.org" "rw:wm:.wiki.roms-isos.com %search%" "gw:wm:.wiki.gbatemp.net/wiki %search%" "ed:wm:.encyclopediadramatica.ch %search%" "un:wm:.uncyclopedia.wikia.com %search%" "wq:wm:.en.wikiquote.org/wiki %search%" "lw:wm:.lyricwiki.org %search%" "wk:wm:.en.wiktionary.org/wiki %search%" "bible:wm:.biblewiki.be/wiki %search%" "znc:wm:.en.znc.in/wiki %search%" "gbr:g:.com.br %search%" "got:g:%search% +ext:torrent" "rs:g:%search% +inurl:rapidshare" "rsmp3 r3 rs3:rs:%search% inurl:mp3" "kiczek:gf:%search% in usa" "mysite:g:+site:%%1%% +ext:%%2%% %%3-end%%" "cg:g:+inurl:%%1%%.craigslist +%%2-end%%" "kt:g:%search% +site:kotaku.com" "gay:f:%search% +ass +gay vs %search% +vagina -gay" "yt:g:%search% site:youtube.com" "ts:g:%search% site:twitter.com" "ft:wm:.futurama.wikia.com %search%" "fg:wm:.familyguy.wikia.com %search%" "ad:wm:.americandad.wikia.com %search%" "sp:wm:.southpark.wikia.com %search%" "sw:wm:.starwars.wikia.com %search%" "na:wm:.naruto.wikia.com %search%" "in:wm:.inuyasha.wikia.com %search%" "gr:wm:.gremlins.wikia.com %search%" "wow:wm:.wowwiki.com %search%" "smf:wm:.smurfs.wikia.com %search%" "sm:wm:.sailormoon.wikia.com %search%" "pk:wm:.pokemon.wikia.com %search%" "ss:wm:.strawberryshortcake.wikia.com %search%" "mlp:wm:.mlp.wikia.com %search%" "lps:wm:.lps.wikia.com %search%" "ant:wm:.ants.wikia.com %search%" "gm:wm:.gaming.wikia.com %search%" "nt:wm:.nothing.wikia.com %search%" "ff:wm:.finalfantasy.wikia.com %search%" "ok:wm:.openkinect.org/wiki %search%" "bl:wm:.borderlands.wikia.com %search%" } # this controls custom trigger phrasing query control. # with this you can split the users search into individual # words, and use these with your custom trigger above. # suppose the user types your custom trigger # !rsmp3 tupac mama # you can reference this in your custom trigger as: # %search% to get the entire text: tupac mama # but, suppose you want individual words, tupac and mama # well now you can reference these too as %%1%% and %%2%%. # you can also use ranges %%1-4%% %%1-end%%. Unlike eggdrop # 1 is the starting index of the users input, not 0. # this works in combination with %search%, but for indexes # you _MUST_ reference within %%'s (double percents).. # hopefully you understand how this functions.. ;) # any setting 1 or higher enables, 0 or lower disables # ------ # NOTE: Leaving this enabled is advised if you use any double # percent variables (%%1%% %%etc%%) in your my_customs list above. # ------ variable custom_words 1 # set this to the proxy you wish the main html fetching procedure to # use. set both proxy_host and proxy_port. if you don't wish to use # a proxy. set proxy_host "" # ------ variable proxy_host "" variable proxy_port "" # set this to the default country you would like ebay.* to use when no # country is specified. default is "com". country is ebay extension # http://ebay.*/ - co.uk, de, es, com, com.au, these are examples. # ------ variable ebay_country "com" # set this to the default country you would like *.google.* sites to use when # no country is specified. default is "com". country is google extension. # http://google.*/ - co.uk, de, es, com, com.au, these are examples. # ------ variable google_country "com" # set this to the default country you would like dailymotion to use when # no country is specified. default is "en" for international. # http://dailymotion.com/*/ - en, us, es, fr, nl, pt, da, el, it, pl, ro, sv, tr, ja, ko, zh, these are examples. # ------ variable daily_country "en" # set this to the default country you would like *.youtube to use when # no country is specified. default is "com". country is youtube code. # http://*.youtube.com/ - com, us, ie, fr, it, nl, br, gb, jp, de, es, pl, these are examples. # ------ variable youtube_country "com" # enable this to allow youtube links to lead to higher definition videos # rather than their stream optimized lower quality setting. # to disable use 0, anything else enables. # ------ variable youtube_highquality 1 # set this to the switch you want to use for youtube to filter content # and display only high-definition videos. # ------ variable youtube_highdef "@hd" # set your default translation language here, this is what will be assumed # if the user omits the 'translate to' portion of their input. # en, es, it, nl, de, etc.. these are merely some examples, there are more available. # ------ variable trans "en" # Google translation input/output encodings # set these below to either: # 0 for automatic encoding # 1 for utf-8 # You may use switches to inverse this behavior on-the-fly. Set them # below as well. # ------ variable trans_input 1 variable trans_output 0 variable trans_input_t "--swapi" variable trans_output_t "--swapo" # Channel filter # this is for users who already have a google script running, but would # like to use the other functions of this script. You can filter out google # requests in any of the channels listed below. # default is "". To add them use: "#chan1 #CHAN2 #cHaN3 #EtC", case is irrelevant. # ------ variable filtered "" # COLOR THEME - THESE CAN BE SHARED WITH OTHERS ON EGGHELP! :P # use these settings below to set your preferred color theme. # the following modes apply and you can use any combination of them: (NO SPACES!) # # Bold = \002 # Underline = \037 # Reverse = \026 # Colours: #RGB/Html code: # White = \00300 #FFFFFF # Black = \00301 #000000 # Blue = \00302 #00007F # Green = \00303 #008F00 # Light Red = \00304 #FF0000 # Brown = \00305 #7F0000 # Purple = \00306 #9F009F # Orange = \00307 #FF7F00 # Yellow = \00308 #F0FF00 # Light Green = \00309 #00F700 # Cyan = \00310 #008F8F # Light Cyan = \00311 #00F7FF # Light Blue = \00312 #0000FF # Pink = \00313 #FF00FF # Grey = \00314 #7F7F7F # Light Grey = \00315 #CFCFCF # # this example will do Bold, Underline and Light Blue: "\002\037\00312" # note: this will affect *ALL* descs, links, totals and errors. also # don't forget to use the \ too ! note: abusing this will heavily increase # the number of characters per line, so your output lines will increase accordingly. # # COLOR CODES MUST CONSIST OF 2 DIGITS, IF YOU WISH TO USE 0-9 PREFIX # IT WITH 0 ACCORDINGLY. IE, \00304 for red... # IF YOU WISH TO USE BACKGROUNDS, THIS IS ALLOWED; IE, \00304,02... # TO DEMODE A COLOR YOU MUST USE \00399 RATHER THAN SIMPLY \003 # # use *_modes to enable each color, bold, underline. # use *_demodes to undo this back to plain text. # if you do not use the proper modes/demodes here your color theme will look # horrible... # ------ # description mode/demode variable desc_modes "" variable desc_demodes "" # link mode/demode variable link_modes "" variable link_demodes "" # totals mode/demode variable total_modes "" variable total_demodes "" # error mode/demode variable error_modes "" variable error_demodes "" # break, seperator and split_char need more than modes # you also enter the appropriate character you wish used. variable break " @ " variable seperator " | " # if using "\n" within the seperator above, you may want to change # the below setting to possibly to ", " or "; " variable split_char " | " # number of minute(s) to ignore flooders, 0 to disable flood protection # ------ variable ignore 1 # how many requests in how many seconds is considered flooding? # by default, this allows 3 queries in 10 seconds, the 4th being ignored # and ignoring the flooder for 'variable ignore' minutes # ------ variable flood 4:10 # would you like to use vocabulary aversion? # this will replace swear words with more appropriate words # and the query returned will be aversion free. # 0 disables, anything else enables #---------- variable aversion_vocabulary 0 # set your aversion vocabulary below if desired: # remember to enable, keep the setting above at 1. #---------- variable aversion { cunt:cock cock:cunt anal:internet "hell:a hot place" sex:troll "fred:wasn't he a flintstone?" *fuck*:nice bitches:women bitch:woman "analsex:true love" "supergear:licorice and pancakes" "tecra:I LIKE LARGE POSTERIORS AND I CANNOT PREVARICATE!" {word:"fuck you"} } #---> NOTE: #---> IF YOUR PRIMARY LANGUAGE ISN'T ENGLISH YOU MUST CHANGE THIS SECTION BELOW POSSIBLY # this is the help list generated by the bot to help users become familiar with the script. # you can change these here to affect the language used when help is asked for. # there MUST be 28 entries in this list, the first must be the word for ALL. # this list MUST be kept entirely lowercase. # ------ variable helplist "all google images groups news local book video fight youtube translate gamespot gamefaqs blog ebay ebayfight wikipedia wikimedia locate review torrent top popular dailymotion ign myspace trends scholar" # english words within the help phrases, spacing must be kept as it is below. # ------ variable helpmsg1 "Help is only available for the following:" variable helpmsg2 "is disabled." variable helpmsg3 "with " variable helpmsg4 " results." # the help messages given. # ------ variable help1 "\[.google.country.code\] \[define:|spell:\] <1+1> <1 cm in ft> " ;#google variable help2 "\[.google.country.code\] " ;#images variable help3 "\[.google.country.code\] " ;#groups variable help4 "\[.google.country.code\] " ;#news variable help5 "\[.google.country.code\] near " ;#local variable help6 "\[.google.country.code\] " ;#book variable help7 "\[.google.country.code\] " ;#video variable help8 " vs " ;#fight variable help9 "\[.youtube.country.code\] " ;#youtube variable help10 "region@region " ;#translate variable help11 "" ;#gamespot variable help12 " in " ;#gamefaqs variable help13 "\[.google.country.code\] " ;#blog variable help14 "\[.ebay.country.code\] " ;#ebay variable help15 " vs " ;#ebayfight variable help16 "\[.wiki-country-code\] \[#subtag\]" ;#wikipedia variable help17 "\[.www.wikisite.org\[/wiki\]\] \[#subtag\]" ;#wikimedia variable help18 "" ;#locate variable help19 " \[@ \]" ;#review variable help20 "" ;#torrent variable help21 "" ;#top variable help22 "" ;#popular variable help23 "" ;#dailymotion variable help24 "" ;#ign variable help25 "" ;#myspace variable help26 "\[.google.country.code\] " ;#trends variable help27 "\[.google.country.code\] " ;#scholar #---> END OF NOTE: # enable encoding conversion, set this to 1 to enable. # with this enabled it will follow the format of encoding conversions listed # below. these will affect both input and output and will follow country switch. # ------ variable encoding_conversion_input 0 variable encoding_conversion_output 1 # enable dirty decoding? This attempts to use the regular "dirty" method # of rendering html elements which works well with iso8859-1 and other # latin variants. This does not work well at all with russian, japanese, # and any other non-latin variants. So keep this at 0 if you want a truly # multi-language bot, but keep in mind you may see unrendered &x12345; html # elements. This is because I don't know of a method to transcode these # to proper utf-8 characters yet.. :P # ------ # NOTE: If you bot is properly utf-8 patched, setting this to 1 is recommened. # ------ variable dirty_decode 1 # enable gzip compression for bandwidth savings? Keep in mind # this semi-breaks some of the present utf-8 work-arounds and # eggdrop may mangle encodings when gzip compression that it # doesn't when uncompressed html it used (default). A setting # of 0 defaults to uncompressed html, a 1 or higher gzip. # ------ # NOTE: If you do not have Trf or zlib packages setting this # to 0 is recommened. Leaving it at 1 is fine as well, as the # script will attempt to find these commands or packages every # rehash or restart. But to keep gzip from ever being used it # is best to set the below variable to 0. # NOTE2: If you have Trf or zlib packages present, then this # should always be set to 1. You save enormous bandwidth and # time using this. If your bot is patched and you have Trf/zlib # then you should definitely leave this at 1 and you will never # suffer issues. # ------ variable use_gzip 0 # THIS IS TO BE USED TO DEVELOP A BETTER LIST FOR USE BELOW. # To work-around certain encodings, it is now necessary to allow # the public a way to trouble shoot some parts of the script on # their own. To use these features involves the two settings below. # -- DEBUG INFORMATION GOES BELOW -- # set debug and administrator here # this is used for debugging purposes # ------ variable debug 1 variable debugnick speechles # AUTOMAGIC # with this set to 1, the bottom encode_strings setting will become # irrelevant. This will make the script follow the charset encoding # the site is telling the bot it is. # This DOES NOT affect wiki(media/pedia), it will not encode automatic. # Wiki(media/pedia) still requires using the encode_strings section below. # ------ # NOTE: If your bot is utf-8 pathced, leave this option at 1, the only # time to change this to 0 is if your having rendering problems. # ------ variable automagic 1 # UTF-8 Work-Around (for eggdrop, this helps automagic) # If you use automagic above, you may find that any utf-8 charsets are # being mangled. To keep the ability to use automagic, yet when utf-8 # is the charset defined by automagic, this will make the script instead # follow the settings for that country in the encode_strings section below. # ------ # NOTE: If you bot is utf-8 patched, set this to 0. Everyone else, use 1. # ------ variable utf8workaround 1 # encoding conversion lookups # here is where you can correct language encoding problems by pointing their # abbreviation towards an encoding. if you want more, feel free to add more. # this is a somewhat poor example below, there are possibly hundreds of additions # that need to be added to this section, this is just something to see if this # indeed is a work around, enjoy and merry christmas ;P # ------ # NOTE: If your bot is utf-8 patched, the below list is irrevelevant. # NOTE2: If your bot isn't utf-8 patched and Trf/zlib are found and used, the below # list is used to correct latin encodings, this is how the list starts by default. # NOTE3: If your bot isn't utf-8 patched, and Trf/zlib are NOT found, the below # list is to correct utf-8 encodings, as well as various latin encodings. You # may need to add things to this list possibly to correct rendering problems. # ------ variable encode_strings { } } } # ------ # end of configuration, script begins - changes beyond this section aren't advised. # ------ # *** DO NOT CHANGE THINGS BEYOND THIS POINT UNLESS YOU KNOW WHAT YOUR DOING *** # If you know what your doing, well by all means, change anything and everything, # but do so with the understanding that all modifications are bound by the # GNU General Public license agreement found above regarding credit for authors # and general copyrights. # ------ # requires http package package require http 2.5 # if gzip requested, Trf or zlib required. if {$::incith::google::use_gzip > 0} { if {([lsearch [info commands] zlib] == -1) && ([catch {package require zlib} error] !=0)} { if {([catch {package require Trf} error] == 0) || ([lsearch [info commands] zip] != -1)} { putlog "Incith:Google compression test successful, found Trf package! Gzip enabled." set incith_trf 1 set incith_hdr "Accept-Encoding gzip,deflate" } else { putlog "Incith:Google unable to find zlib or trf package! Gzip disabled." putlog "Incith:Google requires gzip decompression with wikipedia and Wikimedia. As a result, every article will not work for you." set incith_nozlib 1 set incith_hdr "" } } else { putlog "Incith:Google compression test successful, found zlib package! Gzip enabled." set incith_hdr "Accept-Encoding gzip,deflate" } } else { set incith_nozlib 1 set incith_hdr "" } # set flag per channel use setudef flag google # initialize namespace eval incith { namespace eval google { variable version "incith:google-2.0.0c" variable encode_strings [split $encode_strings] } } # bind the public binds bind pubm -|- "*" incith::google::public_message # bind the private message binds, if wanted if {$incith::google::private_messages >= 1} { bind msgm -|- "*" incith::google::private_message } namespace eval incith { namespace eval google { # GOOGLE # performs a search on google. # proc google {input} { # local variable initialization set results 0 ; set calc 0 ; set break 0 ; set spell 0 ; set output ""; set match "" set populate 0 ; set titem "" ; set no_search "" ; set did_you_mean "" ; set titen "" # can't be moved to fetch_html since $spell isn't global if {[string match -nocase "*spell:*" $input] == 1} { set spell 1 } # fetch the html set html [fetch_html $input 1] # this isn't global, so we need to keep ctry (country) here regexp -nocase -- {^\.(.+?)\s(.+?)$} $input - titen input if {$titen == ""} { set titen "${incith::google::google_country}" } else { set titen [lindex [split $titen /] 0] } # standard fetch_html error catcher if {[string match -nocase "*socketerrorabort*" $html]} { regsub {(.+?)\|} $html {} html return "${::incith::google::error_modes}Socket Error accessing '${html}' .. Does it exist?${::incith::google::error_demodes}" } if {[string match -nocase "*timeouterrorabort*" $html]} { return "${::incith::google::error_modes}Connection has timed out...${::incith::google::error_demodes}" } regsub -- {
    .*?
    } $html {} html # strip out 'did you mean?' first # what do we call 'no search results in any language?' if {![regexp -nocase -- {
    (.+?)

    (.+?)

    (.+?)

    } $html - no_search]} { if {![regexp -nocase -- {
    .*?

    (.+?)

    (.*?)\.

    } $html - no_search]} { if {![regexp -nocase -- {

    (.*?)

    (.*?)} $no_search "" no_search regsub -- {.*?

    } $no_search "" no_search regexp -- {^(.+?)} $no_search - no_search regsub -- {} $no_search "? " no_search regsub -all -- {<(.+?)>} $no_search { } no_search while {[string match "* *" $no_search]} { regsub -all -- { } $no_search " " no_search } if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $no_search {} no_search } set no_search [string trim $no_search] } # give results an output header with result tally. if {![regexp -- {
    .*?

    (.+?)\s\002(.+?)\(\002} $html - titem match]} { if {![regexp -- {

    (.*?) (.*?)\(\002} $html - titem match]} { if {[regexp -- {

    (.*?)\(} $html - match]} { set match [split [string trim $match]] set titem [lindex $match end] set match [lindex $match end-1] } else { set match "Google" set titem "" } } } regsub -all -- {<(.+?)>} $match {} match regsub -all -- {<(.+?)>} $titem {} titem # format output according to variables. if {$incith::google::total_results != 0 && $spell == 0} { set output "${::incith::google::total_modes}\002[string trim ${match}]\002 [descdecode [string trim $titem]]${::incith::google::total_demodes}${incith::google::seperator}" if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } } # parse the html while {$results < $incith::google::search_results} { # the regexp grabs the data and stores them into their variables, while # the regsub removes the data, for the next loop to grab something new. # check if there was an alternate spelling first if {([string match "*

    *" $html] || [string match "*

    *" $html] || [string match "*

    *" $html] || [string match "*

    *
  • *" $html])&& [string match "define:*" $input] == 0 && [string match "*&nocalc=1\">*" $html] == 0} { if {[regexp -nocase -- {

  • (.+?)(.+?)} $html - titem did_you_mean]} { regsub -all -nocase -- {

    (.+?)} $html {} html regexp -- {^(.*?)} $titem - titem } elseif {[regexp -nocase -- {

    .*?

    (.+?)(.+?)} $html - titem did_you_mean]} { regsub -all -nocase -- {

    .*?

    .+?.+?} $html {} html } elseif {[regexp -nocase -- {

    .*?

    (.*?)(.+?)} $html - titem did_you_mean]} { regsub -all -nocase -- {

    .*?} $html {} html } elseif {[regexp -nocase -- {

    (.+?)(.+?)} $html - titem did_you_mean]} { regsub -all -nocase -- {

    .+?.+?} $html {} html } elseif {[regexp -nocase {

    (.*?)(.*?)} $html - titem did_you_mean]} { regsub -all -nocase -- {

    } $html {} html } elseif {[regexp -nocase {

    (.*?)(.*?)} $html - titem did_you_mean]} { regsub -all -nocase -- {

    } $html {} html } # sometimes calculator results are mixed into our alternate spelling. # we want to show these like we do our 'did you mean' if {[string match "*(.+?)} $titem - titem set desc $titem if {$::incith::google::short_answers > 0 } { regsub -all -- {<(.+?)>} $desc "" desc return "${::incith::google::desc_modes}$desc" } } else { set desc "$::incith::google::total_modes$titem$incith::google::total_demodes$incith::google::desc_modes$did_you_mean$incith::google::desc_demodes" } if {$incith::google::bold_descriptions == 0 && [string match "\002" $incith::google::desc_modes] == 1} { regsub -all -- "\002" $desc {} desc } regexp -- {^(.+?)} $desc - desc regsub -all -- {<(.+?)>} $desc "" desc # did you mean and calculate have no link set link "" ### ONEBOX RESULTS ### # answers # } elseif {[string match "*

    (.*?)

    (.*?)} $html - link desc]} { set url "www.google.${titen}" } } set link "http://$url$link" } regsub -- {

    } $desc "" desc if {$::incith::google::short_answers > 0 } { if {[info exists link]} { return "${::incith::google::desc_modes}[descdecode $desc]$incith::google::desc_demodes$::incith::google::break${::incith::google::link_modes}$link${::incith::google::link_demodes}" } else { return "${::incith::google::desc_modes}[descdecode $desc]$incith::google::desc_demodes" } } } # more answers } elseif {[string match "*\{google.rrep('answersrep'*" $html]} { regexp -- {
    .*?

    (.*?)

    } $html - desc regsub -all -- {google.rrep\('answersrep'} $html {} html if {$::incith::google::short_answers > 0 } { return "${::incith::google::desc_modes}[descdecode [string map {\002 ""} $desc]]$incith::google::desc_demodes" } # area codes } elseif {[string match "*/images/map_icon2.gif*" $html] == 1} { regexp -- {
    .+?(.+?)} $html - link desc regsub -- {/images/map_icon2.gif} $html {} html if {[info exists link] == 1 && $link != ""} { set link [urldecode $link] if {[string match "/url?q=http*" $link] == 1} { regexp -- {/url\?q=(.+?q=.+?)&} $link - link } } if {$::incith::google::short_answers > 0 } { return "$::incith::google::desc_modes[descdecode $desc]$::incith::google::desc_demodes$::incith::google::break${::incith::google::link_modes}$link${::incith::google::link_demodes}" } # zip codes } elseif {[string match "*&oi=geocode_result*" $html] == 1} { if {![regexp -nocase -- {oi=geocode_result.*?">(.*?).*?(.+?)} $html - link desc } regsub -all {\&oi=geocode_result} $html {} html if {[info exists link] == 1 && $link != ""} { set link "[urldecode $link]" if {[string match "/url?q=http*" $link] == 1} { regexp -- {/url\?q=(.+?q=.+?)&} $link - link } } if {[string equal [string index $link 0] "/"]} { set link "http://maps.google.$titen$link" } if {$::incith::google::short_answers > 0 } { return "$::incith::google::desc_modes[descdecode $desc]$::incith::google::desc_demodes$::incith::google::break${::incith::google::link_modes}$link${::incith::google::link_demodes}" } # music } elseif {[string match "*&oi=music&ct=result*" $html] == 1} { regexp -- {

    (.+?)\002(.+?)\002} $html - link desc regsub -- {\&oi=music\&ct=result} $html {} html if {[info exists link] == 1 && $link != ""} { set link "[urldecode $link]" if {[string match "/url?q=http*" $link] == 1} { regexp -- {/url\?q=(.+?q=.+?)&} $link - link } } if {$::incith::google::short_answers > 0} { return "$::incith::google::desc_modes[descdecode $desc]$::incith::google::desc_demodes$::incith::google::break${::incith::google::link_modes}$link${::incith::google::link_demodes}" } # travel info } elseif {[string match "*/images/airplane.gif*" $html] ==1} { regexp -- {
    .*?/images/airplane.gif.*?(.*?)(.+?)} $html - d1 link d2 regsub -- {
    .*?/images/airplane.gif.*?} $html "" html set desc "$d1 $d2" # UPC codes } elseif {[string match "*/images/barcode.gif*" $html] ==1} { regexp -- {

    (.+?)} $html - link desc regsub -- {
    .*?/images/barcode.gif.*?} $html "" html # time } elseif {[regexp -- {

    (.*?)
    } $html - desc]} { regsub -- {

    .*?
    } $html "" html regsub -all -- {} [string trim $desc] "; " desc regsub -all -- {<.*?>} [string trim $desc] "" desc if {$::incith::google::short_answers > 0} { return "$::incith::google::desc_modes[descdecode $desc]$::incith::google::desc_demodes" } # weather! } elseif {[string match "*/onebox/weather*" $html] == 1} { regexp -- {

    (.+?)

    .+?(.+?)(.+?)(.+?)(.+?)(.+?)<.+?>(.+?)<.+?>(.+?)<.+?>(.+?)<.+?>(.+?)<.+?>(.+?)<.+?>(.+?)<.+?>(.+?)} $html - f1 f2 f3 f4 f5 f6 f7 f8 regsub -- {

    (.*?) 0 } { return "$::incith::google::desc_modes[descdecode $desc]" } # time: } elseif {[string match "*src=\"http://www.google.com/chart*chc=localtime*" $html] == 1} { regexp -nocase -- {src="http://www.google.com/chart\?chs=.*?chc=localtime.*?>(.+?)} $html - desc regsub -- {
    } $desc ". " desc regsub -all {<.*?>} $desc "" desc regsub -- {chc=localtime} $html {} html if {$::incith::google::short_answers > 0 } { return "$::incith::google::desc_modes[descdecode $desc]" } set link "" # public_data: } elseif {[string match "*/publicdata

    *" $html]} { regexp -nocase -- {valign=top>

    (.*?).*?(.*?)
    } $html - tit link des regsub -all {<.*?>} $des "" des regsub -- {/publicdata

    } $html "" html set desc "$tit: $des" if {[info exists link] == 1 && $link != ""} { if {[string match "*\&sa\=X*" $link]} { regexp -- {(^.+?)&sa\=} [urldecode $link] - link } if {[string match "\/url\?q=*" $link]} { regexp -- {\/url\?q=(.*?)$} $link - link } regexp -- {(.+?)\&ei=} $link - link } if {$::incith::google::short_answers > 0 } { return "${::incith::google::desc_modes}[descdecode ${desc}]${::incith::google::desc_demodes}" } # define: } elseif {[string match "*

    (.+?)\.

    } $html - no_def]} { if {![regexp -- {


    (.+?)

    } $html - no_def]} { if {![regexp -- {

    (.*?)
    } $html - no_def]} { set no_def "Houston, we have a problem. Aborting lift-off!" } } } regsub -- {
    } $no_def "." no_def regsub -all -- {<(.+?)>} $no_def "" no_def return "${::incith::google::desc_modes}${no_def}${::incith::google::desc_demodes}" } } elseif {[string match "*oi=define*" $html]} { if {[string match "*oi=spell*" $html]} { regexp -- {

    (.*?)

    (.*?)

    } $html - desc link regsub -- {} $desc "?" desc regsub -all -- {<.*?>} $desc "" desc regsub -all -- {<.*?>} $link "" link return "${::incith::google::desc_modes}${desc} ${link}${::incith::google::desc_demodes}" } regexp -- {

    (.*?)
    .*?(.*?)} $html - desc link regsub -- {

    .*?
    .*?.*?} $html "" html regsub -all -- {<(.+?)>} [string map {"

  • " " "} $desc] "" desc if {![string match "http*" $link]} { set link "http://$link" } regsub -all -- {\+} $input {%2B} define_input regsub -all -- { } $define_input {+} define_input set link "${link} ( http://www.google.${titen}/search?q=${define_input} )" return "${::incith::google::desc_modes}${desc}${incith::google::break}${link}${::incith::google::desc_demodes}" # finance / stock quotes } elseif {[string match "*(.*?)(.*?)<.*?(.+?).*?Mkt Cap:.*?(.+?)} $html - tick name price mktcap regsub -- {
    (.*?)(.*?)<.*?(.+?).*?Mkt Cap:.*?(.+?)} $html {} html if {[info exists tick] == 1 && [info exists name] == 1 && [info exists price] == 1} { set desc "$tick: $name = $$price" set link "http://finance.google.com/finance?q=$tick" regsub -all -- "\002" $link {} link if {[info exists mktcap] == 1} { append desc " Mkt Cap: $mktcap" } unset tick ; unset name ; unset price ; unset mktcap } if {$::incith::google::short_answers > 0 } { return "$::incith::google::desc_modes[descdecode $desc]" } # patents } elseif {[string match "*/images/magnifier.gif*" $html] ==1} { regexp -- {(.+?)} $html - link desc regsub -- {/images/magnifier.gif} $html {} html # calculator } elseif {[string match "*(.+?)
  • } $html - desc regsub -all -- {<(.+?)>} $desc "" desc if {$::incith::google::short_answers > 0 } { return "$::incith::google::desc_modes[descdecode $desc]" } set link "" # conversion } elseif {[string match "*oi=currency_onebox*" $html] == 1} { set calc 1 regexp -nocase -- {

    (.*?)<} $html - desc regsub -nocase -- {oi=currency_onebox} $html {} html if {$::incith::google::short_answers > 0 } { return "$::incith::google::desc_modes[descdecode $desc]" } set link "" # whois } elseif {[string match "*\002Whois\002 record for*" $html] == 1} { if {[regexp -- {

    (.*?).*?(.*?)} $html - link desc descwho]} { regsub -- {

    .+?.*?.*?} $html "" html append desc " \(${descwho}\)" } if {[info exists link] == 1 && $link != ""} { if {[string match "*\&sa\=X*" $link]} { regexp -- {(^.+?)&} $link - link } if {[string match "\/url\?q=*" $link]} { regexp -- {\/url\?q=(.*?)$} $link - link } } if {$::incith::google::short_answers > 0 } { return "$::incith::google::desc_modes[descdecode $desc]$::incith::google::desc_demodes$::incith::google::break${::incith::google::link_modes}$link${::incith::google::link_demodes}" } ### END ONEBOX ### # spell: # special query - not onebox } elseif {$spell == 1} { if {[regexp {

    (.*?)} $html - titem]} { regsub -all {<.*?>} $titem "" titem set desc "$incith::google::total_modes${titem}$incith::google::total_demodes$incith::google::desc_modes${did_you_mean}$incith::google::desc_demodes" } else { if {$match != "Google"} { return "${::incith::google::total_modes}\002${match}\002 ${titem}" } else { return "$incith::google::total_modes$did_you_mean$incith::google::total_demodes$incith::google::desc_modes$no_search" } } if {[string len $desc] < 2} { set desc "$incith::google::desc_modes$no_search$incith::google::desc_demodes" } set link "" # regular search } else { if {![regexp -- {class=g(?!b).*?((?!<).+?)} $html - link desc]} { if {[regexp -- {class=r.*?((?!<).+?)} $html - link desc ]} { regsub -- {class=r.*?(?!<).+?} $html "" html } } else { regsub -- {class=g(?!b).*?.+?} $html "" html } if {[info exists link] == 1} { if {[string match "*\&sa\=X*" $link]} { regexp -- {(^.+?)&} $link - link } } if {[info exists link] == 1} { if {[string match "*http*" $link] == 0} { set link "" } elseif {[string match *.pdf $link] == 1} { set desc "\[PDF\] $desc" } } if {($::incith::google::skip_self > 0) && ([info exists link])} { if {[string match "*.google.*" $link]} { unset link ; unset desc ; set spell 0 ; set calc 0 ; set break 0 continue } } # trim the description if {[info exists desc] == 1 && $incith::google::description_length > 0} { set desc [string range $desc 0 [expr $incith::google::description_length - 1]] } } # make sure we have something to send if {[info exists desc] == 0} { if {$match == "Google"} { if {[string match "*(.+?)} $desc - desc set reply "${desc}" } else { set reply "${no_search}" } return "$incith::google::desc_modes$reply" } return $output } if {[info exists link] == 1} { if {[string match "*http*" $link] == 0} { set link "" } } set desc [string trim $desc] regsub -all "%20" $desc " " desc regsub -all "
    " $desc " " desc # add the search result if {$calc == 0 && $spell == 0 && $populate == 0} { if {[info exists link] && $link != ""} { if {![string match "*define:*" $input]} { set link [urldecode $link] regsub -all " " $link "%20" link } # added because of recent google changes, needed to clean-up *.google.* links if {[string match "*url\?*" $link]} { regexp -- {url\?q=(.+?)$} $link - link regexp -- {(.+?)\&sig=} $link - link regexp -- {(.+?)\&usg=} $link - link regexp -- {\?url=(.+?)$} $link - link } # top result may be news, at the moment it is too close to regular # search results to cull this out.. so in the meantime, this hack # will at least remove the 10,000 google tags at the end of the url # to keep it from spanning 2 lines of results. if {[string match "http://news.google*" $link]} { regexp -- {^(.+?)&hl=} $link - link } regsub -all "(?:\x93|\x94|"|\")" $link {} link if {[info exists desc]} { set desc "$incith::google::desc_modes[string trim $desc]$incith::google::desc_demodes" } if {[info exists link]} { set link "$incith::google::link_modes[string trim $link]$incith::google::link_demodes" } if {$incith::google::link_only == 1} { append output "${link}${incith::google::seperator}" } else { append output "[descdecode $desc]$::incith::google::break${link}${incith::google::seperator}" } } else { append output "[descdecode $desc]${incith::google::seperator}" } } else { set output "[descdecode $desc]" } # I've hard-coded it to only fetch one result for define lookups, and # spell shouldn't ever have to loop. if {[string match "define:*" $input] == 1 || $spell == 1 || $calc == 1 || $break == 1 } { break } # increase the results, clear the variables for the next loop unset link ; unset desc ; set spell 0 ; set calc 0 ; set break 0 incr results } # make sure we have something to send if {$output == "" && ![string match "*:*" $input] && ![string match "*

    (.+?)

    } $html - no_search]} { if {![regexp -- {

    (.+?)

    } $html - no_search]} { regexp -- {

    (.+?)

    } $html - no_search } } if {$no_search != ""} { regsub -- {} $no_search "? " no_search regsub -all -- {<(.+?)>} $no_search { } no_search while {[string match "* *" $no_search]} { regsub -all -- { } $no_search " " no_search } set no_search [string trim $no_search] } # give results an output header with result tally. regexp -- {align=right nowrap id=.*?>(.+?)\s\002(.+?)\(} $html - titem match if {![regexp -- {1\002\s-\s\002.+?\002.+?\002(.+?)\002} $match - match]} { set match "Google" set titem "" } regsub -all -- {<(.+?)>} $match {} match # format output according to variables. if {$incith::google::total_results != 0 && $match > 0} { set output "${::incith::google::total_modes}\002[string trim ${match}]\002 [descdecode [string trim $titem]]${::incith::google::total_demodes}${incith::google::seperator}" if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } } # parse the html while {$results < $incith::google::image_results} { if {[regexp -- {\["/imgres\?imgurl\\x3d(.*?)\\x26imgrefurl\\x3d.*?\\x26h\\x3d(.*?)\\x26w\\x3d(.*?)\\x26sz\\x3d(.*?)\\x26.*?",.*?,.*?,.*?,.*?,.*?,"(.*?)","(.*?)"} $html - link h w size desc d2]} { regsub -- {\["/imgres\?imgurl\\x3d(.+?)\\x26imgrefurl\\x3d.*?\\x26h\\x3d.*?\\x26w\\x3d.*?\\x26sz\\x3d.*?\\x26} $html {} html # google now makes it very hard to parse titles out, this solves the dilemma. if {[string is integer -strict $desc]} { set desc $d2 } #set desc [string map [list "\]" "\\\]" "\[" "\\\[" "\$" "\\\$" "\\" "\\\\"] $desc] regsub -all -- {\\x([[:xdigit:]]{1,2})} $desc {[format %c [scan "\1" %x]]} desc set desc [descdecode [subst $desc]] regsub -all -- {(?:|)} $desc "\002" desc } # if there's no link, return or stop looping, depending if {[info exists link] == 0} { if {$results == 0} { set reply $no_search return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } else { break } } # prevent duplicate results is mostly useless here, but will at least # ensure that we don't get the exact same picture. if {[string match "*$link*" $output] == 1} { break } append desc " ($h x $w - ${size}k)" if {$incith::google::desc_modes != ""} { set desc "$incith::google::desc_modes${desc}$incith::google::desc_demodes" } if {$incith::google::link_modes != ""} { set link "$incith::google::link_modes${link}$incith::google::link_demodes" } # add the search result append output "[descdecode $desc]$::incith::google::break${link}${incith::google::seperator}" # increase the results, clear the variables for the next loop just in case unset link incr results } # make sure we have something to send if {$match == ""} { set reply "${no_search}" return "$::incith:google::desc_modes$reply$::incith::google::desc_demodes" } return $output } # LOCAL # fetches a list of address & phone numbers from local.google. # -speechless updated proc local {input} { ; set results 0 ; set output ""; set match "" ; set titem "" ; set no_search "" ; set did_you_mean "" ; set titen "" # fetch the html set html [fetch_html $input 3] regsub -all {‎} $html "" html # this isn't global, so we need to keep ctry (country) here regexp -nocase -- {^\.(.+?)\s(.+?)$} $input - titen input if {$titen == ""} { set titen "${incith::google::google_country}" } # user input causing errors? if {[string match -nocase "*socketerrorabort*" $html]} { regsub {(.+?)\|} $html {} html return "${::incith::google::error_modes}Socket Error accessing '${html}' .. Does it exist?${::incith::google::error_demodes}" } if {[string match -nocase "*timeouterrorabort*" $html]} { return "${::incith::google::error_modes}Connection has timed out...${::incith::google::error_demodes}" } # strip out 'did you mean?' first # what do we call 'no search results in any language?' if {![regexp -- {

    (.+?)

    } $html - no_search]} { if {[regexp -- {
    (.+?)

    } $html - no_search]} { set no_search [string map {"
    " "; "} $no_search] regsub -all -- {<.*?>} $no_search "" no_search set no_search [string trim $no_search "; "] } elseif {[regexp -- {
    (.*?)} $html - no_search]} { regsub -all -- {<.*?>} $no_search "" no_search } elseif {[regexp -- {
    (.*?)
    (.*?)
    (.*?)} $extra] { lappend matches $m } set no_search "$did [join $matches "; "]" } } if {[regexp -- {
    .*?

    (.*?)

    } $html - more]} { append no_search "$more" } # give results an output header with result tally. if {![regexp -- {
    (.+?)\s\002(.+?)
    } $html - titem match]} { if {![regexp -- {
    (.+?)\s\002(.+?)
    } $html - titem match]} { if {![regexp -- {
    .*?
    (.+?)\s\002(.+?)
    } $html - match titem]} { if {[regexp -- {
    (.*?)
    } $html - match]} { regsub -all -- {<.*?>} $match "" match set match [split [string trim $match]] ; set titem [lindex $match end] ; set match [lindex $match end-1] if {![string length [string trim $match]]} { set match "Google" ; set titem "" } } else { set match "Google" set titem "" } } } } regsub -all -- {<(.+?)>} $match {} match # format output according to variables. if {$incith::google::total_results != 0} { set output "${::incith::google::total_modes}[string trim ${match}] [descdecode [string trim $titem]]${::incith::google::total_demodes}${incith::google::seperator}" if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } } # parse the html while {$results < $incith::google::local_results} { if {[regexp -nocase {class="name lname.*?(.*?).*?href=".*?cid=(.*?)\&q.*?.*?
    (.*?)
    } $html - loc url add1 desc]} { regsub -nocase {class="name lname.*?.*?.*?href=".*?cid=.*?\&q.*?.*?
    .*?
    } $html "" html } elseif {[regexp -nocase {
    .*?href=(.*?) .*?">(.*?)
    (.*?)
    (.*?)<} $html - url loc add1 desc]} { regsub {
    .*?href=(.*?) .*?">(.*?)
    (.*?)
    } $html "" html } #regsub -nocase {
    " $add1 {} add1 regsub -all -- "‎" $add1 {} add1 if {$incith::google::desc_modes != ""} { set loc "$incith::google::desc_modes${loc}$incith::google::desc_demodes" } if {$incith::google::link_modes != ""} { set link "$incith::google::link_modes${add1}$incith::google::link_demodes" } { set link $add1 } # add the search result if {$incith::google::link_only == 1} { append output "${link} ${incith::google::seperator}" } else { append output "[descdecode ${loc}]$::incith::google::break${link}${incith::google::seperator}" } # increase the results, clear the variables for the next loop just in case unset loc ; unset link ; unset desc incr results } return $output } # GROUPS # fetches a list of threads from groups.google. # -speechless updated proc groups {input} { ; set results 0 ; set output "" ; set match "" ; set no_search "" ; set titem "" ; set titen "" # this isn't global, so we need to keep ctry (country) here regexp -nocase -- {^\.(.+?)\s(.+?)$} $input - titen dummy if {$titen == ""} { set titen "${incith::google::google_country}" } # fetch the html set html [fetch_html $input 4] # user input causing errors? if {[string match -nocase "*socketerrorabort*" $html]} { regsub {(.+?)\|} $html {} html return "${::incith::google::error_modes}Socket Error accessing '${html}' .. Does it exist?${::incith::google::error_demodes}" } if {[string match -nocase "*timeouterrorabort*" $html]} { return "${::incith::google::error_modes}Connection has timed out...${::incith::google::error_demodes}" } # strip out 'did you mean?' first # what do we call 'no search results in any language?' regexp -- {

    (.+?)

    } $html - no_search if {$no_search != ""} { regsub -- {} $no_search "? " no_search regsub -all -- {<(.+?)>} $no_search { } no_search while {[string match "* *" $no_search]} { regsub -all -- { } $no_search " " no_search } set no_search [string trim $no_search] } # give results an output header with result tally. regexp -- {
    (.+?)\s\002(.+?)(\[|<)} $html - titem match if {![regexp -- {1\002\s-\s.+?\002.+?\002(.+?)\002} $match - match]} { set match "Google" set titem "" } regsub -all -- {<(.+?)>} $match {} match # format output according to variables. if {$incith::google::total_results != 0 && $match > 0} { set output "${::incith::google::total_modes}\002[string trim ${match}]\002 [descdecode [string trim $titem]]${::incith::google::total_demodes}${incith::google::seperator}" if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } } # parse the html while {$results < $incith::google::group_results} { # this grabs a google group if one exists # this grabs a usenet group if one exists if {[regexp -- {
    (.+?).+?
    } $html {} thread desc]} { regsub -- {
    (.+?)
    } $html "" html if {[regexp -- {url\?(?:url|q)=(.+?)\&} $thread - thread]} { regexp -- {^(.+?)&(?:sa|ie|ei)=} $thread - thread set thread [urldecode $thread] if {[regexp -- {url\?(?:url|q)=(.+?)\&} $thread - thread]} { regexp -- {^(.+?)&(?:sa|ie|ei)=} $thread - thread set thread [urldecode $thread] } } } elseif {[regexp -- {

    (.+?)} $html - thread desc]} { regsub -- {div class="g".*?href=".+?".*?>(.+?)} $html "" html if {[regexp -- {url\?(?:url|q)=(.+?)\&} $thread - thread]} { regexp -- {^(.+?)&(?:sa|ie|ei)=} $thread - thread set thread [urldecode $thread] if {[regexp -- {url\?(?:url|q)=(.+?)\&} $thread - thread]} { regexp -- {^(.+?)&(?:sa|ie|ei)=} $thread - thread set thread [urldecode $thread] } } } # if there's no desc, return or stop looping, depending if {[info exists desc] == 0} { if {$results == 0} { set reply $no_search return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } else { break } } if {[info exists desc] == 1 && $incith::google::description_length > 0} { set desc [string range $desc 0 [expr $incith::google::description_length - 1]] set desc [string trim $desc] } # make the link valid because we only got a partial href result, not a full url set link $thread if {[info exists desc]} { set desc "$incith::google::desc_modes[string trim $desc]$incith::google::desc_demodes" } if {[info exists link]} { set link "$incith::google::link_modes[string trim $link]$incith::google::link_demodes" } # add the search result if {$incith::google::link_only == 1} { append output "${link}${incith::google::seperator}" } else { append output "[descdecode $desc] $::incith::google::break${link}${incith::google::seperator}" } # increase the results, clear the variables for the next loop just in case unset link; unset desc incr results } # make sure we have something to send if {$match == ""} { set reply $no_search return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } return $output } # NEWS # fetches the news from news.google. # -madwoota supplied, speechless updated # proc news {input} { ; set results 0 ; set output ""; set match "" ; set no_search "" ; set titem "" # fetch the html set html [fetch_html $input 5] # user input causing errors? if {[string match -nocase "*socketerrorabort*" $html]} { regsub {(.+?)\|} $html {} html return "${::incith::google::error_modes}Socket Error accessing '${html}' .. Does it exist?${::incith::google::error_demodes}" } if {[string match -nocase "*timeouterrorabort*" $html]} { return "${::incith::google::error_modes}Connection has timed out...${::incith::google::error_demodes}" } # strip out 'did you mean?' first # what do we call 'no search results in any language?' if {![regexp -- {
    (.+?)

    } $html - no_search]} { regexp -- {

    (.+?)

    } $html - no_search } if {$no_search != ""} { regsub -- {} $no_search "? " no_search regsub -all -- {<(.+?)>} $no_search { } no_search while {[string match "* *" $no_search]} { regsub -all -- { } $no_search " " no_search } set no_search [string trim $no_search] } # give results an output header with result tally. regexp -- {
    (.+?)\s\002(.+?)\(\002} $html - titem match if {![regexp -- {1\002\s–\s\002.+?\002.+?\002(.+?)\002} $match - match]} { set match "Google" set titem "" } regsub -all -- {<(.+?)>} $match {} match # format output according to variables. if {$incith::google::total_results != 0 && $match > 0} { set output "${::incith::google::total_modes}\002[string trim ${match}]\002 [descdecode [string trim $titem]]${::incith::google::total_demodes}${incith::google::seperator}" if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } } # We have to do a single regsub first to get down to the rough area in the html we need because # its just *not* very elegant attempting doing this in a single regexp. (Read: unreliable) #regsub -- {(.+?)
    } $html {} html # parse the html while {$results < $incith::google::news_results} { # somewhat extenuated regexp due to allowing that there *might* be # an image next to the story #

    .*?.*?(.+?).+?
    (.+?)
    if {[regexp -- {

    .*?(.+?).+?
    (.+?)
    } $html {} link desc time]} { regsub -all -- {<.*?>} $time "" time } regsub -- {

    .*?.+?.+?
    .+?
    } $html {} html # if there's no desc, return or stop looping, depending if {[info exists desc] == 0} { if {$results == 0} { set reply $no_search return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } else { break } } if {[info exists desc] == 1 && $incith::google::description_length > 0} { set desc [string range $desc 0 [expr $incith::google::description_length - 1]] set desc [descdecode [string trim $desc]] } # prevent duplicate results is mostly useless here, but will at least # ensure that we don't get the exact same article. if {[string match "*$link*" $output] == 1} { break } if {[info exists desc]} { set desc "$incith::google::desc_modes$desc$incith::google::desc_demodes" } if {[info exists time]} { set time "$incith::google::desc_modes[descdecode [string trim $time]]$incith::google::desc_demodes" } if {[info exists link]} { set link "$incith::google::link_modes[string trim $link]$incith::google::link_demodes" } # add the search result if {$incith::google::link_only == 1} { append output "${link}${incith::google::seperator}" } else { append output "$desc \($time\)$::incith::google::break${link}${incith::google::seperator}" } # increase the results, clear the variables for the next loop just in case unset link; unset desc incr results } # make sure we have something to send if {$match == ""} { set reply $no_search return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } return $output } # PRINT # fetches book titles from books.google. # -madwoota supplied, -broken- # -speechless updated, fixed no longer using print.google # proc print {input} { ; set results 0 ; set output "" ; set titem "" ; set no_search "" ; set did_you_mean "" ; set titen "" ; set match "" # this isn't global, so we need to keep ctry (country) here regexp -nocase -- {^\.(.+?)\s(.+?)$} $input - titen dummy if {$titen == ""} { set titen "${incith::google::google_country}" } # fetch the html set html [fetch_html $input 6] # user input causing errors? if {[string match -nocase "*socketerrorabort*" $html]} { regsub {(.+?)\|} $html {} html return "${::incith::google::error_modes}Socket Error accessing '${html}' .. Does it exist?${::incith::google::error_demodes}" } if {[string match -nocase "*timeouterrorabort*" $html]} { return "${::incith::google::error_modes}Connection has timed out...${::incith::google::error_demodes}" } # strip out 'did you mean?' first # what do we call 'no search results in any language?' regexp -- {(.*?)

    } $html - no_search # if we have a no search results message, let's format it for displaying possibly. if {$no_search != ""} { #regsub -all -- {\002\002} $no_search "\002" no_search regsub -- {

    } $no_search "? " no_search regsub -all -- {<(.+?)>} $no_search { } no_search while {[string match "* *" $no_search]} { regsub -all -- { } $no_search " " no_search } set no_search [string trim $no_search] } # give results an output header with result tally. regexp -- {(.+?)\s\002(.+?)\(\002} $html - titem match if {![regexp -- {1\002\s-\s\002.+?\002.+?\002(.+?)\002} $match - match]} { set match "Google" set titem "" } regsub -all -- {<(.+?)>} $match {} match # format output according to variables. if {$incith::google::total_results != 0 && $match > 0} { set output "${::incith::google::total_modes}\002[string trim ${match}]\002 [descdecode [string trim $titem]]${::incith::google::total_demodes}${incith::google::seperator}" if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } } while {$results < $incith::google::print_results} { if {[regexp -- {

    (.*?)} $html - snippet]} { if {![regexp -- {(.+?)

    (.+?)(.+?)

    (.+?)

    } $html "" html } # if there's no desc, return or stop looping, depending if {![info exists desc]} { if {$results == 0} { set reply $no_search return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } else { break } } # this cleans up perhaps bad html cuts if {[info exists desc]} { regsub -all -- {<(.+?)>} $desc "" desc set desc [string trim $desc] } if {[info exists desc]} { regsub -all -- {<(.+?)>} $author "" author set author [string trim $author] } # make link by appending book id if {[info exists page]} { set page "&pg=$page" } { set page "" } set link "http://books.google.${titen}?id=${id}${page}" # prevent duplicate results is mostly useless here, but will at least # ensure that we don't get the exact same article. #if {[string match "*$link*" $output] == 1} { # break #} append desc " (${author})" if {[info exists desc]} { set desc "$incith::google::desc_modes[string trim $desc]$incith::google::desc_demodes" } if {[info exists link]} { set link "$incith::google::link_modes[string trim $link]$incith::google::link_demodes" } # add the search result if {$incith::google::link_only == 1} { append output "${link}${incith::google::seperator}" } else { append output "[descdecode $desc]$::incith::google::break${link}${incith::google::seperator}" } # increase the results, clear the variables for the next loop just in case unset link ; unset desc ; unset page incr results } # make sure we have something to send if {![info exists output]} { set reply $no_search return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } return $output } # GeoBytes # Fetches IP Location information # -speechless supplied # proc locate {input} { ; set results 0 ; set output "" ; set city "" ; set region "" ; set country "" ; set certainty "" ; set timezone "" ; set population "" ; set currency "" ; set proxy "" ; set curr "" ; # fetch the html set ua "Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.7e" set http [::http::config -useragent $ua] set url "http://www.geobytes.com/IpLocator.htm?GetLocation" set query [::http::formatQuery ipaddress $input] set http [::http::geturl $url -query $query -headers $::incith_hdr -timeout [expr 1000 * 10]] upvar #0 $http state set html [ungzip [::http::data $http] $state(meta)] ::http::cleanup $http # is site broken? if it is, say so if {![string match "**" $html]} { return "$::incith::google::error_modes\002 GeoBytes Error:\002 Unable to access site. www.geobytes.com seems to be down.$::incith::google::error_demodes" } #strip html tags regsub -all "\t" $html "" html regsub -all "\n" $html "" html regsub -all "\r" $html "" html regsub -all "\v" $html "" html regsub -all "'" $html "'" html #parse html regexp -- {input.+?name="ro-no_bots_pls13".+?value="(.+?)".+?size} $html {} country regexp -- {input.+?name="ro-no_bots_pls15".+?value="(.+?)".+?size} $html {} region regexp -- {input.+?name="ro-no_bots_pls17".+?value="(.+?)".+?size} $html {} city regexp -- {input.+?name="ro-no_bots_pls18".+?value="(.+?)".+?size} $html {} certainty regexp -- {input.+?name="ro-no_bots_pls9".+?value="(.+?)".+?size} $html {} timezone regexp -- {input.+?name="ro-no_bots_pls3".+?value="(.+?)".+?size} $html {} population regexp -- {input.+?name="ro-no_bots_pls1".+?value="(.+?)".+?size} $html {} currency #currency sometimes has a trailing space, let's fix that with a dirty hack. set currency [string trim $currency] regexp -- {input.+?name="ro-no_bots_pls11".+?value="(.+?)".+?size} $html {} proxy regexp -- {input.+?name="ro-no_bots_pls".+?value="(.+?)".+?size} $html {} curr #in case we get blocked, say we did if {[string match "*temporarily blocked*" $html] == 1} { set output "$::incith::google::error_modes\002GeoBytes Error:\002 (${input}) Reasonable usage limit has been exceeded. This bot has been temporarily blocked from accessing services. Please try back again later.$::incith::google::error_demodes" } #if we can't read a country, assume there was nothing to lookup. if {$country == "" && $output == ""} { set output "$::incith::google::error_modes\002GeoBytes Error:\002 (${input}) Undefined IP. Nothing to LookUp.$::incith::google::error_demodes" } elseif {$output == ""} { set output "$::incith::google::total_modes\002GeoBytes Location:\002$::incith::google::total_demodes$::incith::google::desc_modes (${input})$::incith::google::desc_demodes$::incith::google::break$incith::google::link_modes${city}, ${region}, ${country} (${certainty}%) \[\002GMT:\002${timezone}\|\002Proxy:\002${proxy}\|${currency}\|${curr}\]$incith::google::link_demodes" } if {$incith::google::bold_descriptions != 1 && [string match "\002" $incith::google::desc_modes] != 1} { regsub -all -- "\002" $output {} output } return $output } # VIDEO # fetches links to video with search data in it (video.google.com) # -madwoota supplied, speechless updated # proc video {input} { ; set results 0 ; set output ""; set match ""; set ded "" ; set titen "" ; set titem "" ; set no_search "" ; set did_you_mean "" # this isn't global, so we need to keep ctry (country) here regexp -nocase -- {^\.(.+?)\s(.+?)$} $input - titen dummy if {$titen == ""} { set titen "${incith::google::google_country}" } # fetch the html set html [fetch_html $input 7] # user input causing errors? if {[string match -nocase "*socketerrorabort*" $html]} { regsub {(.+?)\|} $html {} html return "${::incith::google::error_modes}Socket Error accessing '${html}' .. Does it exist?${::incith::google::error_demodes}" } if {[string match -nocase "*timeouterrorabort*" $html]} { return "${::incith::google::error_modes}Connection has timed out...${::incith::google::error_demodes}" } # strip out 'did you mean?' first # what do we call 'no search results in any language?' if {[regexp -- {

    (.*?)

    |)} $no_search "\002" no_search #regsub -- {} $no_search "? " no_search #regsub -- {} $no_search ". " no_search regsub -all -- {<(.+?)>} $no_search "" no_search set no_search [string trim $no_search] } # give results an output header with result tally. if {![regexp -- {

    (.+?)} $html - match]} { set match "Google" set titem "" } else { regsub -all -- {<(.+?)>} $match {} match regexp -- {([0-9].*?)$} $match - match set match "\002[join [lrange [split $match] 0 end-1]]\002 [lindex [split $match] end]" } # format output according to variables. if {$incith::google::total_results != 0} { set output "${::incith::google::total_modes}[string trim ${match}]${::incith::google::total_demodes}${incith::google::seperator}" if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } } # parse the html while {$results < $incith::google::video_results} { # somewhat extenuated regexp due to allowing that there might be an image next to the title regexp -- {

    .*?href="(.*?)".*?>(.*?).*?(.*?)
    (.*?)
    } $html {} link desc ded ded2 regsub -- {

    .*?href=".*?".*?>.*?.*?.*?
    .*?
    } $html "" html # if there's no desc, return or stop looping, depending if {[info exists desc] == 0} { if {$results == 0} { set reply $no_search return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } else { break } } set desc [string trim [string range $desc 0 [expr $incith::google::description_length - 1]]] # append narration to description for more detail unless its identical # keep description from becoming too lengthy and clean up trailing spaces regsub -all {
    } $ded "" ded regexp {(.+?)\)--} $ded - ded regsub { -} $ded " - " ded regsub {} $ded " - " ded regsub -all {<(.*?)>} $ded "" ded if {[string length $ded2]} { set ded2 "\([descdecode [string range $ded2 0 [expr $incith::google::description_length - 1]]]\)" } set desc "[descdecode $desc] $ded2\([descdecode [string trim $ded]]\)" # make the link valid because we were only given a partial href result, not a full url if {[string match [string range $link 0 0] "/"]} { regsub -- {&.+?$} $link "" link set link "http://video.google.${titen}${link}" } # prevent duplicate results is mostly useless here, but will at least # ensure that we don't get the exact same article. if {[string match "*$link*" $output] == 1} { break } # quick and dirty double-space remover while {[string match "* *" $desc]} { regsub -all -- { } $desc " " desc } set desc [string trim $desc] if {[info exists desc]} { set desc "$incith::google::desc_modes[string trim $desc]$incith::google::desc_demodes" } if {[info exists link]} { set link "$incith::google::link_modes[string trim $link]$incith::google::link_demodes" } # add the search result if {$incith::google::link_only == 1} { append output "${link}${incith::google::seperator}" } else { append output "[descdecode $desc]$::incith::google::break${link}${incith::google::seperator}" } # increase the results, clear the variables for the next loop just in case unset link; unset desc incr results } # make sure we have something to send if {$match == ""} { set reply $no_search return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } return $output } # FIGHT # google fight ! # proc fight {input} { set output ""; set winner 0; set match1 0; set match2 0 if {![regexp -nocase -- {^\.(.+?)\s(.+?)$} $input - country input]} { set country "${incith::google::google_country}" } regexp -nocase -- {^(.+?) vs (.+?)$} $input - word1 word2 if {![regexp -nocase -- {^\.(.+?)\s(.+?)$} $word2 - country2 word2]} { set country2 "${incith::google::google_country}" } # fetch the first result set html [fetch_html ".$country $word1" 8] # parse the html if {![regexp -nocase {
    .*?

    (.+?)(?:\(\002|\[)} $html - matches1]} { if {![regexp -- {

    (.*?) (.*?)\(\002} $html - titem matches1]} { if {[regexp -- {
    (.*?)\(} $html - match]} { set matches1 [lindex [split [string trim $match]] end-1] } } } if {[info exists matches1]} { regsub -- {(?:\002|\s)1\002 - \0021\002} $matches1 "" matches1 regsub -- {(?:\002|\s)1\002-\0021\002} $matches1 "" matches1 regsub -nocase { of about } $matches1 "" matches1 regsub -nocase -all {} $matches1 "" matches1 regsub -nocase -all {} $matches1 "" matches1 set match1 $matches1 regsub -all -- {[\., ]} $match1 "" match1 } else { set matches1 "0" } if {![string is digit $match1]} { regexp -- {\002(.+?)\002.*?\002(.+?)\002} $matches1 - dummy match1 if {[string match $match1 $word1]} { regexp -- {\002(.+?)\002} $matches1 - match1 } } # fetch the second result set html [fetch_html ".$country2 $word2" 8] # parse the html if {![regexp -nocase {
    .*?

    (.+?)(?:\(\002|\[)} $html - matches2]} { if {![regexp -- {

    (.*?) (.*?)\(\002} $html - titem matches2]} { if {[regexp -- {
    (.*?)\(} $html - match]} { set matches2 [lindex [split [string trim $match]] end-1] } } } if {[info exists matches2]} { regsub -- {(?:\002|\s)1\002 - \0021\002} $matches2 "" matches2 regsub -- {(?:\002|\s)1\002-\0021\002} $matches2 "" matches2 regsub -nocase { of about } $matches2 "" matches2 regsub -nocase -all {} $matches2 "" matches2 regsub -nocase -all {} $matches2 "" matches2 set match2 $matches2 } else { set matches2 "0" } if {![string is digit $match2]} { regexp -- {\002(.+?)\002.*?\002(.+?)\002} $matches2 - dummy match2 if {[string match $match2 $word2]} { regexp -- {\002(.+?)\002} $matches2 - match2 } } if {![string match $country $country2]} { set country "$country and Google.$country2" } if {![info exists match1]} { set match1 "0" set match1expr "0" } else { regsub -all {(?:\.|,| )} $match1 "" match1expr } if {![info exists match2]} { set match2 "0" set match2expr "0" } else { regsub -all {(?:\.|,| )} $match2 "" match2expr } if {[expr $match2expr < $match1expr]} { set winner 1 } elseif {[string match $match2expr $match1expr]} { set winner 3 } else { set winner 2 } if {$incith::google::bold_descriptions > 0 && $incith::google::desc_modes == ""} { set word1 "\002$word1\002"; set word2 "\002$word2\002" set match1 "\002 $matches1\002"; set match2 "\002 $matches2\002" } elseif {$incith::google::desc_modes != ""} { set word1 "\002$word1\002"; set word2 "\002$word2\002" set match1 " $matches1"; set match2 " $matches2" } else { set match1 " $matches1"; set match2 " $matches2" } if {$winner == 1} { set output "${::incith::google::total_modes}By results on Google.$country:$::incith::google::total_demodes$::incith::google::desc_modes $word1 beats $word2 by$match1 to$match2!$::incith::google::desc_demodes" } elseif {$winner == 2} { set output "${::incith::google::total_modes}By results on Google.$country:$::incith::google::total_demodes$::incith::google::desc_modes $word2 beats $word1 by$match2 to$match1!$::incith::google::desc_demodes" } else { set output "${::incith::google::total_modes}Google.$country could not determine the winner.$::incith::google::total_demodes$::incith::google::desc_modes $word2 ties $word1 with$match1 results.$::incith::google::desc_demodes" } # make sure we have something to send if {[info exists output] == 0} { set reply "${::incith::google::desc_modes}Sorry, no search results were found. Something is wrong...$::incith::google::desc_demodes" return $reply } return $output } # YOUTUBE # fetches links to video with search data in it (youtube.com) # -speechless supplied # proc youtube {input} { ; set results 0 ; set output "" ; set ded ""; set match "" ; set titem "" ; set titen "" if {[regsub -nocase -all -- "$::incith::google::youtube_highdef" $input "" dummy]} { set hd 1 } # this isn't global, so we need to keep ctry (country) here regexp -nocase -- {^\.(.+?)\s(.+?)$} $input - titem dummy if {$titem == ""} { set titem "${incith::google::youtube_country}" } # fetch the html set html [fetch_html $input 9] # user input causing errors? if {[string match -nocase "*socketerrorabort*" $html]} { regsub {(.+?)\|} $html {} html return "${::incith::google::error_modes}Socket Error accessing '${html}' .. Does it exist?${::incith::google::error_demodes}" } if {[string match -nocase "*timeouterrorabort*" $html]} { return "${::incith::google::error_modes}Connection has timed out...${::incith::google::error_demodes}" } # give results an output header with result tally. if {![regexp -- {
    (.*?)(.+?)(
    |
    |
    |<\!--)} $html - reply]} { regsub -all -nocase {
    .+?(
    |
    |
    |<\!--)} $html "" html regsub -all {} $reply ". " reply regsub -all -- {<.*?>} $reply "" reply } elseif {[regexp -nocase {id="search-no-results-message">(.*?)
    } $html - reply]} { regsub -all -- {<.*?>} $reply "" reply } elseif {[regexp -nocase {id="results-main-.*?>.*?(.*?)
    } $html - reply]} { regsub -all -- {<.*?>} $reply "" reply } else { set reply "" } # parse the html while {$results < $incith::google::youtube_results} { # somewhat extenuated regexp due to allowing that there might be an image next to the title if {[regexp -nocase {(.*?)(.+?).*?id="video\-description.*?">(.*?)(.+?)(.+?)*" $desc]} { regexp -nocase {(.*?).*?id="video\-description.*?">(.*?)(.+?)(.+?).*?.*?.*?1-.*?\s.*?\s(.*?)\s(.*?)\s} $html - match videos # format output according to variables. if {$incith::google::total_results != 0 && $match != ""} { set output "${::incith::google::total_modes}\002[string trim ${match}]\002 [descdecode [string trim $videos]]${::incith::google::total_demodes}${incith::google::seperator}" if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } } # parse the html while {$results < $incith::google::myspacevids_results} { # somewhat extenuated regexp due to allowing that there might be an image next to the title regexp -nocase -- {a class="taggedlink.*?href=.*?videoid=(.*?)\&.*?>(.*?).*?(.*?).*?
      (.*?)
    } $html - cid desc ded rating regsub -nocase -- {a class="taggedlink.*?href=.*?videoid=.*?\&.*?>.*?.*?.*?.*?
      .*?
    } $html {} html # if there's no desc, return or stop looping, depending if {![info exists desc]} { if {$results == 0} { if {[regexp -- {class="displayingSummary">(.+?)

    } $html - reply]} { return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } elseif {[regexp -- {

    (.*?)

    } $html - reply]} { return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } } else { break } } # duplicate link filter, clumsy indeed.. will remove soon and fix properly if {[string match "*${cid}*" $output] == 1} { break } if {[info exists rating]} { regsub -all {} [string map {" " "" "\002" ""} $rating] ";" rating regsub -all {<.*?>} $rating "" rating regsub -all {\s+} $rating " " rating regsub -all { ;} $rating ";" rating } if {[info exists ded]} { regsub -all {<.*?>} [string trim $ded] "" ded if {[string length $ded]} { set ded "(by $ded)" } } # keep description from becoming too lengthy and clean up trailing spaces if {[info exists desc]} { set desc [string trim [string range $desc 0 [expr $incith::google::description_length - 1]]] set desc "${desc} ${ded}([string trim ${rating} "; "])" } # make the link valid because we were only given a partial href result, not a full url set link "http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=${cid}" if {[info exists desc]} { set desc "$incith::google::desc_modes[string trim $desc]$incith::google::desc_demodes" } if {[info exists link]} { set link "$incith::google::link_modes[string trim $link]$incith::google::link_demodes" } # add the search result if {$incith::google::link_only == 1} { append output "${link}${incith::google::seperator}" } else { append output "[descdecode $desc]$::incith::google::break${link}${incith::google::seperator}" } # increase the results, clear the variables for the next loop just in case unset link; unset desc incr results } # make sure we have something to send if {$match == ""} { regexp -- {class="displayingSummary">(.+?)
    } $html - reply return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } if {$incith::google::bold_descriptions != 0} { regsub -all -- "(|)" $output "\002" output } else { regsub -all -- "(|)" $output "" output } return $output } # trans # google translation -(www.google.com\translate_t?) # -speechless supplied # proc trans {input where} { global incithcharset ; set results 0 ; set output ""; set match "" ; set titem "" if {[regsub -nocase -all -- $incith::google::trans_input_t $input "" input]} { set y 0 } if {[regsub -nocase -all -- $incith::google::trans_output_t $input "" input]} { set z 0 } # split up stuff regexp -nocase -- {^(.+?)@(.+?)\s(.+?)$} $input - link desc titem # fetch the html set ua "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3" if {$::incith::google::trans_input > 0} { set http [::http::config -useragent $ua -urlencoding "utf-8"] } else { set http [::http::config -useragent $ua -urlencoding ""] } set url "http://translate.google.com/translate_t?" if {$::incith::google::trans_input > 0} { if {![info exists y]} { set ie "&ie=utf-8" } else { set ie "" } } else { if {![info exists y]} { set ie "" } else { set ie "&ie=utf-8" } } if {$::incith::google::trans_output > 0} { if {![info exists z]} { set oe "&oe=utf-8" } else { set oe "" } } else { if {![info exists z]} { set oe "" } else { set oe "&oe=utf-8" } } if {![info exists y]} { set query "text=[urlencode $titem 0 "utf-8"]&sl=${link}&tl=${desc}$ie$oe" } else { set query "text=[urlencode $titem 0]&sl=${link}&tl=${desc}$ie$oe" } catch {set http [::http::geturl "$url" -query $query -headers $::incith_hdr -timeout [expr 1000 * 10]]} error # CHECK CHECK upvar #0 $http state set incithcharset [string map -nocase {"UTF-" "utf-" "iso-" "iso" "windows-" "cp" "shift_jis" "shiftjis"} $state(charset)] if {$incith::google::debug > 0} { putserv "privmsg $incith::google::debugnick :\002url:\002 $url$query \002\037charset:\002\037 [string map -nocase {"iso-" "iso" "windows-" "cp" "shift_jis" "shiftjis"} $incithcharset]" } if {[string match -nocase "*couldn't open socket*" $error]} { return "${::incith::google::error_modes}Socket Error accessing '${url}' .. Does it exist?${::incith::google::error_demodes}" } if { [::http::status $http] == "timeout" } { return "${::incith::google::error_modes}Connection has timed out...${::incith::google::error_demodes}" } set html [ungzip [::http::data $http] $state(meta)] if {[info exists z]} { set html [incithencode $html] } ::http::cleanup $http regsub -all -nocase {(.+?)} $html {^\1} html regsub -all -nocase {} $html "" html regsub -all -nocase {} $html "" html regsub -all -nocase {} $html "" html regsub -all -nocase {} $html "" html regsub -all -nocase {} $html "" html regsub -all -nocase {(?:|)} $html "" html regsub -all -nocase {} $html "" html regsub -all "\t" $html " " html regsub -all "\n" $html " " html regsub -all "\r" $html " " html regsub -all "\v" $html " " html regsub -all "" $html ". " html regsub -all ";;>" $html "" html # make sure everything is lowercase. # make sure everything is lowercase. set desc [string tolower $desc] set link [string tolower $link] if {![regexp -- {

    (.+?)

    } $html {} detect]} {set detect ""} { regsub -all {<.*?>} $detect "" detect} if {[regexp -- {

    .*?
    (.+?)
    } $html - match]} { regsub -all {<.*?>} $match "" match } if {[string length $match]} { put_output $where "${::incith::google::total_modes}Google\:$::incith::google::total_demodes$::incith::google::desc_modes \(${link}\-\>${desc}\)\ [descdecode $detect]" put_output $where [descdecode [descdecode ${match}]] } else { put_output $where "${::incith::google::error_modes}Translation error\:$::incith::google::error_demodes$::incith::google::desc_modes \(${link}\-\>${desc}\)\ [descdecode "$detect."]$::incith::google::desc_demodes" } } # MININOVA TORRENT HUNT # fetches torrent links from mininova. (mininova.com) # -speechless supplied # proc mininova {input} { ; set results 0 ; set output ""; set match "" ; set ebcSP "" ; set match2 "" #regsub -all {-} $input { } input # fetch the html set html [fetch_html $input 51] # give results an output header with result tally. regexp -- {

    (?!No).*?\((.+?)\s(.+?)\)} $html - match match2 # format output according to variables. if {$incith::google::total_results != 0} { set output "${::incith::google::total_modes}\002[string trim ${match}]\002 [descdecode [string trim $match2]]${::incith::google::total_demodes}${incith::google::seperator}" if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } } regsub {(.+?)} $html "" html # parse the html while {$results < $incith::google::mininova_results && $match != ""} { # this could break any second, its cumbersome and long..i know, but for now it works. regexp -nocase {(.+?)} $html - htm regsub {(.+?)} $html "" html regexp -nocase {(.+?).+?(.+?)} $htm - ebcU ebcI ebcBid ebcPR regexp -nocase {(.+?)(.+?)(.+?)} $htm - ebcShpNew ebcTim ebcCheck regexp -nocase {title="Tracker URL: (.+?)"} $htm - ebcSP if {$ebcSP != ""} { set ebcSP "\037${ebcSP}\037 " } # keep torrent name from becoming too lengthy if {[info exists ebcPR]} { set ebcPR [string range $ebcPR 0 [expr $incith::google::description_length - 1]] set ebcPR [string trim $ebcPR] } # check results are more than 0, return or stop looping, depending if {$match < 1 } { if {$results == 0} { regexp -nocase {

    (.+?)

    } $html - reply if {![regexp -nocase {

    (.+?)

    } $html - reply2]} { set reply2 "" } { if {![string match *Didn't* $reply2]} { regsub -all -- {<(.+?)>} $reply2 "" reply2 ; set reply2 ". $reply2" } { set reply2 "" } } regsub -all -- {<(.+?)>} $reply "" reply return "$::incith::google::desc_modes$reply$reply2$::incith::google::desc_demodes" } else { break } } # make the link valid because we were only given a partial href result, not a full url set link "http://mininova.org/get/${ebcBid}" # prevent duplicate results is mostly useless here, but will at least # ensure that we don't get the exact same article. if {[string match "*$link*" $output] == 1} { break } # fix up our variables so the output looks purdy. set desc "${ebcU}/${ebcI} ${ebcSP}\002${ebcPR}\002 (${ebcShpNew}, ${ebcTim}s, ${ebcCheck}p)" if {[info exists desc]} { set desc "$incith::google::desc_modes[string trim $desc]$incith::google::desc_demodes" } if {[info exists link]} { set link "$incith::google::link_modes[string trim $link]$incith::google::link_demodes" } # add the search result if {$incith::google::link_only == 1} { append output "${link}${incith::google::seperator}" } else { append output "$desc$::incith::google::break${link}${incith::google::seperator}" } # increase the results, clear the variables for the next loop just in case unset link ; set ebcCheck "" ; set ebcU "" ; set ebcSP "" incr results } # make sure we have something to send if {$match == ""} { regexp -nocase {

    (.+?)

    } $html - reply if {![regexp -nocase {

    (.+?)

    } $html - reply2]} { set reply2 "" } { if {![string match *Didn't* $reply2]} { regsub -all -- {<(.+?)>} $reply2 "" reply2 ; set reply2 ". $reply2" } { set reply2 "" } } regsub -all -- {<(.+?)>} $reply "" reply return "$::incith::google::desc_modes$reply$reply2$::incith::google::desc_demodes" } regsub -all -- " " $input "+" input append output "www.mininova.org/search/${input}/seeds" #append output "www.mininova.org/search/?search=${input}" return $output } # DAILYMOTION # fetches links to video with search data in it (dailymotion.com) # -speechless supplied # proc dailymotion {input} { ; set results 0 ; set output "" ; set titem "" # this isn't global, so we need to keep ctry (country) here regexp -nocase -- {^\.(.+?)\s(.+?)$} $input - titem dummy if {$titem == ""} { set titem "${incith::google::daily_country}" } # fetch the html set html [fetch_html $input 14] # user input causing errors? if {[string match -nocase "*socketerrorabort*" $html]} { regsub {(.+?)\|} $html {} html return "${::incith::google::error_modes}Socket Error accessing '${html}' .. Does it exist?${::incith::google::error_demodes}" } if {[string match -nocase "*timeouterrorabort*" $html]} { return "${::incith::google::error_modes}Connection has timed out...${::incith::google::error_demodes}" } if {[regexp -- {
    (.*?)
    } $html - nope]} { regsub -all -- {} $nope "." nope regsub -all -- {
    } $nope " " nope regsub -all -- {<.*?>} $nope "" nope set reply "${::incith::google::desc_modes}$nope$::incith::google::desc_demodes" return $reply } set output "DailyMotion${incith::google::seperator}" if {$incith::google::bold_descriptions != 0} { set output "$::incith::google::total_modes\002DailyMotion\002$::incith::google::total_demodes${incith::google::seperator}" } # parse the html while {$results < $incith::google::daily_results} { # somewhat extenuated regexp due to allowing that there might be an image next to the title regexp -nocase -- {
    (.*?)<.*?(.*?)<.*?
    .*?

    .*?div class="dmco_date">(.*?)<} $html "" html # if there's no desc, return or stop looping, depending if {[info exists desc] == 0} { if {$results == 0} { set reply "Sorry, no search results were found." return "${::incith::google::desc_modes}$reply$::incith::google::desc_demodes" } else { break } } set desc [string trim [string range $desc 0 [expr $incith::google::description_length - 1]]] set vote [string trim [string range $vote 0 [expr $incith::google::description_length - 1]]] set desc "${desc} (${snatch}) ([string trim $vote])" # make the link valid because we were only given a partial href result, not a full url set link "http://www.dailymotion.com/${titem}/video/${cid}" # prevent duplicate results is mostly useless here, but will at least # ensure that we don't get the exact same article. if {[string match "*$link*" $output] == 1} { break } if {[info exists desc]} { set desc "$incith::google::desc_modes[string trim $desc]$incith::google::desc_demodes" } if {[info exists link]} { set link "$incith::google::link_modes[string trim $link]$incith::google::link_demodes" } # add the search result if {$incith::google::link_only == 1} { append output "${link}${incith::google::seperator}" } else { append output "[descdecode $desc]$::incith::google::break${link}${incith::google::seperator}" } # increase the results, clear the variables for the next loop just in case unset link; unset desc ; unset cid incr results } # make sure we have something to send if {[info exists output] == 0} { set reply "Sorry, no search results were found." return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } return $output } # GAMEFAQS # fetches upcoming game list variable by system and region (gamefaqs.com) # this is far better than any gamefaqs procedure you've seen before, this is looooong, but very simple # in it's approach. I learned alot coding it. # -speechless supplied # proc gamefaqs {system region} { ; set results 0 ; set output "" ; set html "" ; set match 0 ; set game "" ; set date "" # strip excessive spaces from region and system desired. regsub -all " " $system "" system regsub -all " " $region "" region # this is where most of the work is done # parsing systems and regions to create an output header # and cut the html down to the specified region if {[string match -nocase "nds" $system] == 1} { if {[string match -nocase "usa" $region] == 1} { set html [fetch_html "/region-1" 15] set output "\002NDS North America (USA)\002" } if {[string match -nocase "jap" $region] == 1} { set html [fetch_html "/region-2" 15] set output "\002NDS Asia (JAPAN)\002" } if {[string match -nocase "eur" $region] == 1} { set html [fetch_html "/region-3" 15] set output "\002NDS Europe (UK)\002" } if {[string match -nocase "aus" $region] == 1} { set html [fetch_html "/region-4" 15] set output "\002NDS Australia (AUS)\002" } } if {[string match -nocase "3ds" $system] == 1} { if {[string match -nocase "usa" $region] == 1} { set html [fetch_html "/region-1" 56] set output "\0023DS North America (USA)\002" } if {[string match -nocase "jap" $region] == 1} { set html [fetch_html "/region-2" 56] set output "\0023DS Asia (JAPAN)\002" } if {[string match -nocase "eur" $region] == 1} { set html [fetch_html "/region-3" 56] set output "\0023DS Europe (UK)\002" } if {[string match -nocase "aus" $region] == 1} { set html [fetch_html "/region-4" 56] set output "\002NDS Australia (AUS)\002" } } if {[string match -nocase "iphone" $system] == 1} { if {[string match -nocase "usa" $region] == 1} { set html [fetch_html "/region-1" 16] set output "\002iPhone North America (USA)\002" } if {[string match -nocase "jap" $region] == 1} { set html [fetch_html "/region-2" 16] set output "\002iPhone Asia (JAPAN)\002" } if {[string match -nocase "eur" $region] == 1} { set html [fetch_html "/region-3" 16] set output "\002iPhone Europe (UK)\002" } if {[string match -nocase "aus" $region] == 1} { set html [fetch_html "/region-4" 16] set output "\002iPhone Australia (AUS)\002" } } if {[string match -nocase "psp" $system] == 1} { if {[string match -nocase "usa" $region] == 1} { set html [fetch_html "/region-1" 17] set output "\002PSP North America (USA)\002" } if {[string match -nocase "jap" $region] == 1} { set html [fetch_html "/region-2" 17] set output "\002PSP Asia (JAPAN)\002" } if {[string match -nocase "eur" $region] == 1} { set html [fetch_html "/region-3" 17] set output "\002PSP Europe (UK)\002" } if {[string match -nocase "aus" $region] == 1} { set html [fetch_html "/region-4" 17] set output "\002PSP Australia (AUS)\002" } } if {[string match -nocase "x360" $system] == 1} { if {[string match -nocase "usa" $region] == 1} { set html [fetch_html "/region-1" 18] set output "\002XBOX360 North America (USA)\002" } if {[string match -nocase "jap" $region] == 1} { set html [fetch_html "/region-2" 18] set output "\002XBOX360 Asia (JAPAN)\002" } if {[string match -nocase "eur" $region] == 1} { set html [fetch_html "/region-3" 18] set output "\002XBOX360 Europe (UK)\002" } if {[string match -nocase "aus" $region] == 1} { set html [fetch_html "/region-4" 18] set output "\002XBOX360 Australia (AUS)\002" } } if {[string match -nocase "xbox" $system] == 1} { if {[string match -nocase "usa" $region] == 1} { set html [fetch_html "/region-1" 19] set output "\002XBOX North America (USA)\002" } if {[string match -nocase "jap" $region] == 1} { set html [fetch_html "/region-2" 19] set output "\002XBOX Asia (JAPAN)\002" } if {[string match -nocase "eur" $region] == 1} { set html [fetch_html "/region-3" 19] set output "\002XBOX Europe (UK)\002" } if {[string match -nocase "aus" $region] == 1} { set html [fetch_html "/region-4" 19] set output "\002XBOX Australia (AUS)\002" } } if {[string match -nocase "gc" $system] == 1} { if {[string match -nocase "usa" $region] == 1} { set html [fetch_html "/region-1" 20] set output "\002GAMECUBE North America (USA)\002" } if {[string match -nocase "jap" $region] == 1} { set html [fetch_html "/region-2" 20] set output "\002GAMECUBE Asia (JAPAN)\002" } if {[string match -nocase "eur" $region] == 1} { set html [fetch_html "/region-3" 20] set output "\002GAMECUBE Europe (UK)\002" } if {[string match -nocase "aus" $region] == 1} { set html [fetch_html "/region-4" 20] set output "\002GAMECUBE Australia (AUS)\002" } } if {[string match -nocase "ps2" $system] == 1} { if {[string match -nocase "usa" $region] == 1} { set html [fetch_html "/region-1" 21] set output "\002PS2 North America (USA)\002" } if {[string match -nocase "jap" $region] == 1} { set html [fetch_html "/region-2" 21] set output "\002PS2 Asia (JAPAN)\002" } if {[string match -nocase "eur" $region] == 1} { set html [fetch_html "/region-3" 21] set output "\002PS2 Europe (UK)\002" } if {[string match -nocase "aus" $region] == 1} { set html [fetch_html "/region-4" 21] set output "\002PS2 Australia (AUS)\002" } } if {[string match -nocase "pc" $system] == 1} { if {[string match -nocase "usa" $region] == 1} { set html [fetch_html "/region-1" 22] set output "\002PC North America (USA)\002" } if {[string match -nocase "jap" $region] == 1} { set html [fetch_html "/region-2" 22] set output "\002PC Asia (JAPAN)\002" } if {[string match -nocase "eur" $region] == 1} { set html [fetch_html "/region-3" 22] set output "\002PC Europe (UK)\002" } if {[string match -nocase "aus" $region] == 1} { set html [fetch_html "/region-4" 22] set output "\002PC Australia (AUS)\002" } } if {[string match -nocase "ps3" $system] == 1} { if {[string match -nocase "usa" $region] == 1} { set html [fetch_html "/region-1" 23] set output "\002PS3 North America (USA)\002" } if {[string match -nocase "jap" $region] == 1} { set html [fetch_html "/region-2" 23] set output "\002PS3 Asia (JAPAN)\002" } if {[string match -nocase "eur" $region] == 1} { set html [fetch_html "/region-3" 23] set output "\002PS3 Europe (UK)\002" } if {[string match -nocase "aus" $region] == 1} { set html [fetch_html "/region-4" 23] set output "\002PS3 Australia (AUS)\002" } } if {[string match -nocase "wii" $system] == 1} { if {[string match -nocase "usa" $region] == 1} { set html [fetch_html "/region-1" 28] set output "\002Wii North America (USA)\002" } if {[string match -nocase "jap" $region] == 1} { set html [fetch_html "/region-2" 28] set output "\002Wii Asia (JAPAN)\002" } if {[string match -nocase "eur" $region] == 1} { set html [fetch_html "/region-3" 28] set output "\002Wii Europe (UK)\002" } if {[string match -nocase "aus" $region] == 1} { set html [fetch_html "/region-4" 28] set output "\002Wii Australia (AUS)\002" } } if {[string match -nocase "dc" $system] == 1} { if {[string match -nocase "jap" $region] == 1} { set html [fetch_html "/region-2" 29] set output "\002Dreamcast Asia (JAPAN)\002" } } if {[string match -nocase "mac" $system] == 1} { if {[string match -nocase "usa" $region] == 1} { set html [fetch_html "/region-1" 59] set output "\002MAC America (USA)\002" } if {[string match -nocase "jap" $region] == 1} { set html [fetch_html "/region-2" 59] set output "\002MAC Asia (JAPAN)\002" } if {[string match -nocase "eur" $region] == 1} { set html [fetch_html "/region-3" 59] set output "\002MAC Europe (UK)\002" } if {[string match -nocase "aus" $region] == 1} { set html [fetch_html "/region-4" 59] set output "\002MAC Australia (AUS)\002" } } if {[string length $output]} { set output "$::incith::google::total_modes$output$::incith::google::total_demodes" } # remove the bold if it isn't desired. if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } # parse for results and loop until desired amount of results # is attempted to be reached if possible. while {$results < $incith::google::gamefaq_results && $output != ""} { # grab date and game title and clear future html of it for looping regexp -nocase {(.*?)<.+?td>.*?.+?<.+?a><.+?td>} $html {} date game regsub {(.+?)<.+?a><.+?td>} $html "" html # add the search result # if there is a date, add date in bold and game to $output if {[string len $date] > 3} { if {$incith::google::bold_descriptions == 0} { append output "${incith::google::seperator}$::incith::google::desc_modes${date} ${game}$::incith::google::desc_demodes" } else { append output "${incith::google::seperator}$::incith::google::desc_modes\002${date}\002 ${game}$::incith::google::desc_demodes" } # otherwise just add name of game } elseif {[string len $game] > 1} { append output "${incith::google::split_char}$::incith::google::desc_modes${game}$::incith::google::desc_demodes" #append output ",${game}" } # increase the results, clear the variables for the next loop just in case incr results ; set date "" ; set game "" } # if we have nothing to send, we have no results :( if {$output == ""} { set output "${::incith::google::desc_modes}Sorry, found no results! \[system = 3ds/nds/gc/wii/ps2/psp/ps3/xbox/x360/pc/mac/iphone; region = usa/jap/eur/aus\] usage: !gamefaqs system in region$::incith::google::desc_demodes" } return $output } # BLOGSEARCH # fetches the news from blogsearch.google. # -madwoota supplied (uses news.google engine), speechless updated # proc blog {input} { ; set results 0 ; set output "" ; set match "" ; set titem "" ; set no_search "" ; set did_you_mean "" # fetch the html set html [fetch_html $input 24] # user input causing errors? if {[string match -nocase "*socketerrorabort*" $html]} { regsub {(.+?)\|} $html {} html return "${::incith::google::error_modes}Socket Error accessing '${html}' .. Does it exist?${::incith::google::error_demodes}" } if {[string match -nocase "*timeouterrorabort*" $html]} { return "${::incith::google::error_modes}Connection has timed out...${::incith::google::error_demodes}" } # strip out 'did you mean?' first # what do we call 'no search results in any language?' regexp -- {

    (.+?)

    } $html - no_search if {$no_search != ""} { regsub -- {
    } $no_search "? " no_search regsub -all -- {<(.+?)>} $no_search { } no_search while {[string match "* *" $no_search]} { regsub -all -- { } $no_search " " no_search } set no_search [string trim $no_search] } # give results an output header with result tally. regexp -- {(.+?)\s\002(.+?)\(\002} $html - titem match if {![regexp -- {1\002\s-\s\002.+?\002.+?\002(.+?)\002} $match - match]} { set match "Google" set titem "" } regsub -all -- {<(.+?)>} $match {} match # format output according to variables. if {$incith::google::total_results != 0 && $match > 0} { set output "${::incith::google::total_modes}\002[string trim ${match}]\002 [descdecode [string trim $titem]]${::incith::google::total_demodes}${incith::google::seperator}" if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } } # parse the html while {$results < $incith::google::news_results} { # somewhat extenuated regexp due to allowing that there *might* be # an image next to the story regexp -- {

    (.+?).+?(.+?)
    } $html {} link desc time regsub -- {

    } $html {} html # if there's no desc, return or stop looping, depending if {[info exists desc] == 0} { if {$results == 0} { set reply $no_search return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } else { break } } # clean up desc if {[info exists desc] == 1 && $incith::google::description_length > 0} { set desc [string range $desc 0 [expr $incith::google::description_length - 1]] set desc "[descdecode [string trim $desc]] ([descdecode [string trim $time]])" } # prevent duplicate results is mostly useless here, but will at least # ensure that we don't get the exact same article. if {[string match "*$link*" $output] == 1} { break } if {[info exists desc]} { set desc "$incith::google::desc_modes[string trim $desc]$incith::google::desc_demodes" } if {[info exists link]} { set link "$incith::google::link_modes[string trim $link]$incith::google::link_demodes" } # add the search result if {$incith::google::link_only == 1} { append output "${link}${incith::google::seperator}" } else { append output "[descdecode $desc]$::incith::google::break${link}${incith::google::seperator}" } # increase the results, clear the variables for the next loop just in case unset link; unset desc incr results } # make sure we have something to send if {$match == ""} { set reply $no_search return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } return $output } # SCHOLAR SEARCH # fetches the news from scholar.google. # -madwoota supplied (uses news.google engine), speechless updated # proc scholar {input} { ; set results 0 ; set output "" ; set match "" ; set titem "" ; set no_search "" ; set did_you_mean "" ; set titen "" # this isn't global, so we need to keep ctry (country) here regexp -nocase -- {^\.(.+?)\s(.+?)$} $input - titen dummy if {$titen == ""} { set titen "${incith::google::google_country}" } # fetch the html set html [fetch_html $input 10] # user input causing errors? if {[string match -nocase "*socketerrorabort*" $html]} { regsub {(.+?)\|} $html {} html return "${::incith::google::error_modes}Socket Error accessing '${html}' .. Does it exist?${::incith::google::error_demodes}" } if {[string match -nocase "*timeouterrorabort*" $html]} { return "${::incith::google::error_modes}Connection has timed out...${::incith::google::error_demodes}" } # strip out 'did you mean?' first # what do we call 'no search results in any language?' if {![regexp -- {

    (.+?)\.
    } $html - no_search]} { regexp -- {

    (.+?)

    } $html - no_search } if {$no_search != ""} { regsub -- {
    } $no_search "? " no_search regsub -all -- {<(.*?)>} $no_search { } no_search while {[string match "* *" $no_search]} { regsub -all -- { } $no_search " " no_search } set no_search [string trim $no_search] } # give results an output header with result tally. regexp -- {align=right nowrap>(.+?)\s\002(.+?)\(\002} $html - titem match if {![regexp -- {1\002\s-\s\002.+?\002.+?\002(.+?)\002} $match - match]} { set match "Google" set titem "" } regsub -all -- {<(.+?)>} $match {} match # format output according to variables. if {$incith::google::total_results != 0 && $match > 0} { set output "${::incith::google::total_modes}\002[string trim ${match}]\002 [descdecode [string trim $titem]]${::incith::google::total_demodes}${incith::google::seperator}" if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } } # parse the html while {$results < $incith::google::news_results} { # somewhat extenuated regexp due to allowing that there *might* be # an image next to the story if {[regexp -- {

    (.+?) } $html - ps]} { regsub -- {

    (.+?) } $html {} html if {![regexp -- {} $ps "" ps } if {[regexp -- {(.+?)

    .*?
    (.*?)
    } $ps - desc time]} { regsub {
    } $desc "" desc } } # if there's no desc, return or stop looping, depending if {[info exists desc] == 0} { if {$results == 0} { set reply $no_search return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } else { break } } # clean up desc if {[info exists desc] == 1 && $incith::google::description_length > 0} { set desc [string range $desc 0 [expr $incith::google::description_length - 1]] set desc "[string trim $desc] ([string trim $time])" } # prevent duplicate results is mostly useless here, but will at least # ensure that we don't get the exact same article. if {[string match "*$link*" $output] == 1} { break } if {[info exists desc]} { set desc "$incith::google::desc_modes[string trim $desc]$incith::google::desc_demodes" } if {[info exists link]} { set link "$incith::google::link_modes[string trim $link]$incith::google::link_demodes" } # add the search result if {$incith::google::link_only == 1} { append output "${link}${incith::google::seperator}" } else { if {![string equal $link "none"]} { if {![string match "http*" $link]} { set link "http://scholar.google.${titen}/$link" } append output "[descdecode $desc]$::incith::google::break${link}${incith::google::seperator}" } else { append output "[descdecode $desc]${incith::google::seperator}" } } # increase the results, clear the variables for the next loop just in case unset link; unset desc incr results } # make sure we have something to send if {$match == ""} { set reply $no_search return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } return $output } # WIKI # fetches wiki info from *.wikipedia.org # -speechless supplied # proc wiki {input} { global incithcharset ; set output "" ; set ded "" ; set match "" ; set redir "" ; set country "" ; set dec "" ; set query "" ; set titem "" ; set ebcPR "" ; set results "" ; set tresult "" ; set red 0 ; set subtag "" ; set region "" ; set regional "" # make it so people can search their country regexp -nocase -- {^\.(.+?)\s(.+?)$} $input - country input if {$country == ""} { set country "${incith::google::wiki_country}" } regexp -nocase -- {(.*)\@(.*)} $country - country region # this is my input encoding hack, this will convert input before it goes # out to be queried. if {$incith::google::encoding_conversion_input > 0 && $region != ""} { set encoding_found [lindex [split [lindex $incith::google::encode_strings [lsearch -glob $incith::google::encode_strings "${region}:*"]] :] 1] } elseif {$incith::google::encoding_conversion_input > 0 && $country != ""} { set encoding_found [lindex [split [lindex $incith::google::encode_strings [lsearch -glob $incith::google::encode_strings "${country}:*"]] :] 1] } else { set encoding_found "" } if {$encoding_found != "" && [lsearch -exact [encoding names] $encoding_found] != -1} { set input [encoding convertfrom $encoding_found $input] } regsub -all -- {_} $input { } input regexp -- {^(.+?)\#(.+?)$} $input - input results regsub -all -- {_} $results { } results set input [urlencode $input 0 "utf-8"] set results [string map {.20 _} [urlencode [string trim $results] 1 "utf-8"]] # 1st load of webpage - this is the only part which has error control # this is where we load the search page to find an exact match or most relevant. # we will also be able to detect bad user input in the form of socket errors. # beware, changing the useragent will result in differently formatted html from Google. set query "http://${country}.wikipedia.org/wiki/index.php?title=Special%3ASearch&search=${input}&fulltext=Search" set ua "Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.7e" set http [::http::config -useragent $ua -urlencoding "utf-8"] # stole this bit from rosc2112 on egghelp forums # borrowed is a better term, all procs eventually need this error handler. catch {set http [::http::geturl "$query" -headers $::incith_hdr -timeout [expr 1000 * 5]]} error if {[string match -nocase "*couldn't open socket*" $error]} { return "${::incith::google::error_modes}Socket Error accessing '${country}.wikipedia.org' .. Does it exist?${::incith::google::error_demodes}" } if { [::http::status $http] == "timeout" } { return "${::incith::google::error_modes}Connection has timed out...${::incith::google::error_demodes}" } # CHECK CHECK upvar #0 $http state set incithcharset [string map -nocase {"UTF-" "utf-" "iso-" "iso" "windows-" "cp" "shift_jis" "shiftjis"} $state(charset)] set html [ungzip [::http::data $http] $state(meta)] set redir [::http::ncode $http] # REDIRECT if {[string match "*${redir}*" "302|301" ]} { foreach {name value} $state(meta) { if {[regexp -nocase ^location$ $name]} { catch {set http [::http::geturl "$value" -query "" -headers $::incith_hdr -timeout [expr 1000 * 10]]} error if { $::incith::google::debug > 0 } { putserv "privmsg $::incith::google::debugnick :\002redirected:\002 $query -> $value" } if {[string match -nocase "*couldn't open socket*" $error]} { return "${::incith::google::error_modes}Socket Error accessing '${country}.wikipedia.org' .. Does it exist?${::incith::google::error_demodes}" } if { [::http::status $http] == "timeout" } { return "${::incith::google::error_modes}Connection has timed out...${::incith::google::error_demodes}" } upvar #0 $http state set html [ungzip [::http::data $http] $state(meta)] set query $value } } } ::http::cleanup $http # generic pre-parsing regsub -all -nocase {(.+?)} $html {^\1} html regsub -all -nocase {} $html "" html regsub -all -nocase {} $html "" html regsub -all -nocase {} $html "" html regsub -all -nocase {(?:|)} $html "" html regsub -all "\t" $html " " html regsub -all "\n" $html " " html regsub -all "\r" $html " " html regsub -all "\v" $html " " html regsub -all "" $html ". " html regsub -all ";;>" $html "" html regsub {
    .*?
    } $html "" html if {$html == ""} { return "$::incith::google::error_modes\002Wikipedia Error:\002 No html to parse.$::incith::google::error_demodes" } # see if our direct result is available and if so, lets take it if {![regexp -- {} $match "?" match regsub -all {
    } $match "" match regsub -all {\[Index\]} $match "" match regsub -all {} $match "" match regsub -all {|
    )} $html - no_search]} { if {![regexp -- {
    (.+?)
    } $html - no_search]} { regexp -- {
    (.*?)
    } $html - no_search } } } } # santize our no_search results found error message # may need to use it very shortly if we have no results if {$no_search != ""} { #if {[regexp -- {
  • (.+?)
  • } $html - ebcStr]} { # regsub -all -- {<(.+?)>} $ebcStr {} ebcStr # set ebcStr "${ebcStr}. " #} #regexp {(^.+?)document.write} $no_search - no_search #regsub -all -- {<(.+?)>} $no_search {} no_search #set no_search "${ebcStr}[string trim $no_search]" } else { if {$tresult == 0 && $no_search == ""} { set no_search "eBay error." } } # bids in any language if {![regexp -- {(.+?)} $html {} ebcSP]} {set ebcsp ""} # format output according to variables. if {$incith::google::total_results != 0} { regexp -- {} $html - auctions set output "$::incith::google::total_modes\002[string trim ${tresult}]\002 [string trim $auctions]$::incith::google::total_demodes${incith::google::seperator}" if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } } # parse the html while {$results < $incith::google::ebay_results} { # these CANNOT be tied together, some results appear in different # order, so always leave these spread out in a mess... if {![regexp -nocase {
    (.*?)} $html - line]} { if {![regexp -nocase {.*?class="details.*?">(.+?)
    } $html - line]} { if {![regexp -nocase {.*?class="details.*?">(.+?)
    } $html - line]} { if {![regexp -nocase {

    (.+?)class="ebRight"} $html - line]} { if {![regexp -nocase {(.*?)} $html - line]} { set line "" } else { regsub -nocase {.*?} $html {} html } } else { regsub {

    .+?class="ebRight"} $html {} html } } else { regsub {.+?
    } $html {} html } } else { regsub {.+?
    } $html {} html } } else { regsub -nocase {
    .*?} $html {} html } # name & url if {![regexp -nocase {href=".*?ebay.*?/.*?/(.*?)\?pt.*?>(.*?)} $line - ebcU ebcI]} { if {![regexp -nocase {.+?(.+?)} $line - ebcU ebcI]} { regexp -nocase {(.+?)} $line - ebcBid]} { if {[regexp {(.+?)
    (.*?)} $ebcBid "" ebcBid if {$ebcBid == "-"} { set ebcBid "0" } if {$ebcBid != ""} { regsub -all -- {<(.+?)>} $ebcSP "" ebcSP append ebcBid " ${ebcSP}" } if {$ebcBid == ""} { set ebcBid "??" } } } # if our buy-it-now has a bid too, prepend bid to it. if {![string match "*${ebcBid2}*" $ebcBid]} { if {$ebcBid2 == "-"} { set ebcBid2 "0" } regsub -all -- {<(.+?)>} $ebcSP "" ebcSP set ebcBid "${ebcBid2} ${ebcSP}/[string trim $ebcBid]" } } regsub -nocase {

    } $ebcBid "/" ebcBid regsub -all {<.*?>} $ebcBid "" ebcBid # prices if {[regexp -nocase {(.*?)
    } $ebcPR "/" ebcPR regexp -- {^(.+)
    (.*?)$} $ebcPR - ebcPR ebcShpNew regsub -all {<.*?>} $ebcPR "" ebcPR } # shipping if {![string length $ebcShpNew]} { if {[regexp -nocase {td class=".*?(?:ship|fshp).*?">(.+?)} $line - ebcShpNew]} { if {[string match "<" [string index $ebcShpNew 0]]} { set ebcShpNew "Calculate" } } else { regexp -nocase {class="ebcShpNew">(.+?)<} $line - ebcShpNew if {[info exists ebcShpNew]} { regexp -- {;;">(.+?)} $ebcShpNew {} ebcCheck if {$ebcCheck == ""} { regexp -- {$(.+?)<} $ebcShpNew {} ebcShpNew if {$ebcShpNew == ""} { set ebcTim "store" regexp -nocase {class="ebcStr">.+?http://stores.ebay.com/.+?">(.+?)
    } $html - ebcStr } } else { if {![regexp -- {(.*?)
    (.*?)
    } $ebcPR - ebcPR ebcShpNew]} { set ebcShpNew "Calculate" } } } # remove pesky trailing spaces regsub -all -- {<(.+?)>} $ebcShpNew {} ebcShpNew regsub -all " " $ebcShpNew "" ebcShpNew } } # time left if {![regexp -nocase {td class="time.*?rt">(.+?)} $line - ebcTim]} { if {![regexp -nocase {class="ebcTim">(.+?)<} $line - ebcTim]} { regexp -nocase {class="hidlb">(.+?)<} $line - ebcTim } } if {[info exists ebcTim]} { regsub -all -- {<.*?>} [string map {\002 ""} $ebcTim] {} ebcTim if {[string match *:* $ebcTim]} { set ebcTim [join [lrange [split $ebcTim :] 1 end]] } } # keep ebay Item from becoming too lengthy if {[info exists ebcI]} { #ebay has these odd tags, removing them cleans up results. regsub -all -nocase "" $ebcI "" ebcI set ebcI [string range $ebcI 0 [expr $incith::google::description_length - 1]] set ebcI [string trim $ebcI] } # check results are more than 0, return or stop looping, depending if {$tresult < 1 } { if {$results == 0} { set reply $no_search return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } else { break } } # make the link valid because we were only given a partial href result, not a full url set link "http://cgi.ebay.${titem}/_W0QQItemZ[lindex [split ${ebcU} "/"] end]" # fix up our variables so the output looks purdy. if {$ebcPR == ""} { set ebcPR "--" } if {$ebcTim == ""} { set ebcTim "--" } elseif {$ebcTim == "store"} { set desc "\037${ebcStr}\037 ${ebcI}, ${ebcPR}(${ebcShpNew}), ${ebcBid}" } elseif {$ebcI != ""} { set desc "${ebcI}, ${ebcPR}(${ebcShpNew}), ${ebcBid}, ${ebcTim}" } else { set link "" ; set desc "" } # add the search result if {$link != ""} { if {[info exists desc] == 1 && $ebcI != ""} { if {[info exists desc]} { set desc "$incith::google::desc_modes[string trim $desc]$incith::google::desc_demodes" } if {[info exists link]} { set link "$incith::google::link_modes[string trim $link]$incith::google::link_demodes" } if {$incith::google::link_only == 1} { append output "${link}${incith::google::seperator}" } else { append output [descdecode "${desc}$::incith::google::break${link}${incith::google::seperator}"] } } } # increase the results, clear the variables for the next loop just in case unset link ; set ebcCheck "" ; set ebcU "" ; set ebcBid2 "" set ebcI "" ; set ebcPR "" ; set ebcShpNew "" incr results } # make sure we have something to send if {$tresult < 1} { set reply $no_search return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } return $output } # EBAYFIGHT # ebay fight ! # proc ebayfight {input} { set output ""; set winner 0 ; set match1 0; set match2 0 regexp -nocase -- {^(.+?) vs (.+?)$} $input - word1 word2 # fetch the first result set html [fetch_html $word1 25] if {![regexp -- {class="sectiontitle">([0-9  .,]+)\002.*?

    ([0-9  .,]+) } $html - match1]} { if {![regexp -- {var.*?getCustomAdConfig.*?,"items=(.+?)"} $html - match1]} { if {![regexp -nocase {

    (.*?)\s(.*?)\s} $html - match1]} { if {![regexp -nocase {
    (.*?)\s(.*?)\s} $html - match1]} { regexp -nocase {
    .*?\s.+?\s.*?\:\s*(.+?)\s} $html - auctions match1 set match1 "[join [scan $match1 "%d%d"] ""]" } } } } } # fetch the second result set html [fetch_html $word2 25] regexp -- {
    (.+?)\s} $html - match2 if {![regexp -- {class="sectiontitle">([0-9  .,]+)\002.*?

    ([0-9  .,]+) } $html - match2]} { if {![regexp -- {var.*?getCustomAdConfig.*?,"items=(.+?)"} $html - match2]} { if {![regexp -nocase {

    (.*?)\s(.*?)\s} $html - match2]} { if {![regexp -nocase {
    (.*?)\s(.*?)\s} $html - match2]} { regexp -nocase {
    .*?\s.+?\s.*?\:\s*(.+?)\s} $html - auctions match2 set match2 "[join [scan $match2 "%d%d"] ""]" } } } } } # clean up our matches, so it looks all tidy and neat. regsub -all "\002" $match1 " " match1 regsub -all "\002" $match2 " " match2 if {![info exists match1]} { set match1 "0" set match1expr "0" } else { regsub -all {,} $match1 {} match1expr } if {![info exists match2]} { set match2 "0" set match2expr "0" } else { regsub -all {,} $match2 {} match2expr } if {[expr $match2expr < $match1expr]} { set winner 1 } else { set winner 2 } if {[expr $match2expr == $match1expr]} { set winner 1 set troll1 { Pissing Shitting SpillingPez DrippingCum Trolling } set troll2 { YourFace YourSister YourMama } set match1 "[lindex $troll1 [rand [llength $troll1]]]" set match2 "[lindex $troll2 [rand [llength $troll2]]]" } if {$incith::google::bold_descriptions > 0 && $incith::google::desc_modes == ""} { set word1 "\002$word1\002"; set word2 "\002$word2\002" set match1 "\002 $match1\002"; set match2 "\002 $match2\002" } elseif {$incith::google::desc_modes != ""} { set word1 "$incith::google::desc_modes$word1$incith::google::desc_demodes"; set word2 "$incith::google::desc_modes$word2$incith::google::desc_demodes" set match1 " $incith::google::desc_modes$match1$incith::google::desc_demodes"; set match2 " $incith::google::desc_modes$match2$incith::google::desc_demodes" } else { set match1 " $match1"; set match2 " $match2" } regsub -all " " $match1 "" match1 regsub -all " " $match2 "" match2 if {$winner == 1} { set output "${::incith::google::total_modes}By results on ebay:$::incith::google::total_demodes$incith::google::desc_modes $word1 beats $word2 by $match1 to $match2!$::incith::google::desc_demodes" } elseif {$winner == 2} { set output "${::incith::google::total_modes}By results on ebay:$::incith::google::total_demodes$incith::google::desc_modes $word2 beats $word1 by $match2 to $match1!$::incith::google::desc_demodes" } else { set output "${::incith::google::total_modes}Could not determine the winner." } # make sure we have something to send if {[info exists output] == 0} { set reply "Sorry, no search results were found." if {[info exists did_you_mean] == 1} { append reply " Did you mean: ${did_you_mean}?" } return "$incith::google::desc_modes$reply$::incith::google::desc_demodes" } return $output } # Popular # fetches games results from gamerankings. # -speechless supplied # proc popular {input} { # lots of variables, keeping them clean is important. # borrowed mostly from my ebay proc above. ; set results 0 ; set output "" ; set tresult "" ; set ebcU "" ; set ebcI "" ; set ebcBid "" ; set ebcPR "" ; set ebcCheck "" ; set html "" # redundant and messy, yes i know.. but it works, k # parses the query and reads html according to system desired. if {[string match -nocase "gc" $input] == 1} { set html [fetch_html "0" 30] set output "\002GameRankings BEST GameCube\002" } if {[string match -nocase "pc" $input] == 1} { set html [fetch_html "0" 31] set output "\002GameRankings BEST PC\002" } if {[string match -nocase "ps2" $input] == 1} { set html [fetch_html "0" 32] set output "\002GameRankings BEST PlayStation2\002" } if {[string match -nocase "ps3" $input] == 1} { set html [fetch_html "0" 33] set output "\002GameRankings BEST PlayStation3\002" } if {[string match -nocase "wii" $input] == 1} { set html [fetch_html "0" 34] set output "\002GameRankings BEST Wii\002" } if {[string match -nocase "xbox" $input] == 1} { set html [fetch_html "0" 35] set output "\002GameRankings BEST Xbox\002" } if {[string match -nocase "x360" $input] == 1} { set html [fetch_html "0" 36] set output "\002GameRankings BEST Xbox360\002" } if {[string match -nocase "ds" $input] == 1} { set html [fetch_html "0" 37] set output "\002GameRankings BEST NDS\002" } if {[string match -nocase "gba" $input] == 1} { set html [fetch_html "0" 38] set output "\002GameRankings BEST GBA\002" } if {[string match -nocase "psp" $input] == 1} { set html [fetch_html "0" 39] set output "\002GameRankings BEST PSP\002" } if {[string match -nocase "mobile" $input] == 1} { set html [fetch_html "0" 40] set output "\002GameRankings BEST Mobile\002" } if {[string match -nocase "ngage" $input] == 1} { set html [fetch_html "0" 41] set output "\002GameRankings BEST N-Gage\002" } if {[string match -nocase "3do" $input] == 1} { set html [fetch_html "0" 42] set output "\002GameRankings BEST 3DO\002" } if {[string match -nocase "dc" $input] == 1} { set html [fetch_html "0" 43] set output "\002GameRankings BEST Dreamcast\002" } if {[string match -nocase "gen" $input] == 1} { set html [fetch_html "0" 44] set output "\002GameRankings BEST Genesis\002" } if {[string match -nocase "jag" $input] == 1} { set html [fetch_html "0" 45] set output "\002GameRankings BEST Jaguar\002" } if {[string match -nocase "n64" $input] == 1} { set html [fetch_html "0" 46] set output "\002GameRankings BEST N64\002" } if {[string match -nocase "neo" $input] == 1} { set html [fetch_html "0" 47] set output "\002GameRankings BEST Neo-Geo\002" } if {[string match -nocase "ps1" $input] == 1} { set html [fetch_html "0" 48] set output "\002GameRankings BEST Playstation\002" } if {[string match -nocase "sat" $input] == 1} { set html [fetch_html "0" 49] set output "\002GameRankings BEST Saturn\002" } if {[string match -nocase "snes" $input] == 1} { set html [fetch_html "0" 50] set output "\002GameRankings BEST Snes\002" } if {[string match -nocase "segacd" $input] == 1} { set html [fetch_html "0" 52] set output "\002GameRankings BEST Sega-CD\002" } if {[string match -nocase "gameboy" $input] == 1} { set html [fetch_html "0" 53] set output "\002GameRankings BEST GameBoy\002" } if {[string match -nocase "gbc" $input] == 1} { set html [fetch_html "0" 54] set output "\002GameRankings BEST GameBoy Color\002" } if {[string match -nocase "all" $input] == 1} { set html [fetch_html "0" 55] set output "\002GameRankings BEST -ALL-\002" } if {[string match -nocase "3ds" $input] == 1} { set html [fetch_html "0" 57] set output "\002GameRankings BEST 3DS\002" } if {[string match -nocase "mac" $input] == 1} { set html [fetch_html "1" 58] set output "\002GameRankings WORST MAC\002" } if {[string match -nocase "*http://www.gamespot.com/gamerankings/offline.html*" $html]} { append output "${incith::google::seperator}${::incith::google::error_modes}We're sorry, we are temporarily offline. We'll be back as soon as possible." return $output } if {[string match -nocase "*Temporarily Unavailable*" $html]} { append output "${incith::google::seperator}${::incith::google::error_modes}GameRankings is Temporarily Unavailable." return $output } if {$output == ""} { return "${::incith::google::desc_modes}Sorry, that system is not supported! \[system = gc/pc/mac/ps2/ps3/wii/xbox/x360/3ds/ds/gba/psp/mobile/ngage/3d0/dc/gen/jag/n64/neo/ps1/sat/snes\] usage: $::lastbind system" } else { set output "$::incith::google::total_modes$output$::incith::google::total_demodes" } regsub -all "(?:\t|\n|\r|\v)" $html "" html # remove the bold if it isn't desired. if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } # parse for results and loop until desired amount of results # is attempted to be reached if possible. while {$results < $incith::google::popular_results && $output != ""} { # grab date and game title and clear future html of it for looping if {[regexp -- {.*?.*?(.*?).*?(.+?).*?
    (.+?)(.+?)<} $html - sys game pub date]} { regsub -- {>.*?} $date "" date } # if there's no desc, return or stop looping, depending if {![info exists game]} { if {$results == 0} { set reply "Sorry, no search results were found." return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } else { break } } # add the search result # add game to output if there is one if {[info exists game]} { if {[string match -nocase "all" $input] == 1} { append output "${incith::google::seperator}$::incith::google::desc_modes\002${game}\002 ($sys) by $pub (${date})$::incith::google::desc_demodes" } else { append output "${incith::google::seperator}$::incith::google::desc_modes\002${game}\002 by $pub (${date})$::incith::google::desc_demodes" } unset game; unset date } # increase the results, clear the variables for the next loop just in case incr results } # if we have nothing to send, we have no results :( if {$output == ""} { set output "${::incith::google::desc_modes}Sorry, found no results! \[system = gc/pc/ps2/ps3/wii/xbox/x360/ds/gba/psp/mobile/ngage/3do/dc/gen/jag/n64/neo/ps1/sat/snes\] usage: !popular system" } return $output } # Recent Games # fetches games results from Gamerankings. # -speechless supplied # proc recent {input} { # lots of variables, keeping them clean is important. # borrowed mostly from my ebay proc above. ; set results 0 ; set output "" ; set tresult "" ; set ebcU "" ; set ebcI "" ; set ebcBid "" ; set ebcPR "" ; set ebcCheck "" ; set html "" # redundant and messy, yes i know.. but it works, k # parses the query and reads html according to system desired. if {[string match -nocase "gc" $input] == 1} { set html [fetch_html "1" 30] set output "\002GameRankings WORST GameCube\002" } if {[string match -nocase "pc" $input] == 1} { set html [fetch_html "1" 31] set output "\002GameRankings WORST PC\002" } if {[string match -nocase "ps2" $input] == 1} { set html [fetch_html "1" 32] set output "\002GameRankings WORST PlayStation2\002" } if {[string match -nocase "ps3" $input] == 1} { set html [fetch_html "1" 33] set output "\002GameRankings WORST PlayStation3\002" } if {[string match -nocase "wii" $input] == 1} { set html [fetch_html "1" 34] set output "\002GameRankings WORST Wii\002" } if {[string match -nocase "xbox" $input] == 1} { set html [fetch_html "1" 35] set output "\002GameRankings WORST Xbox\002" } if {[string match -nocase "x360" $input] == 1} { set html [fetch_html "1" 36] set output "\002GameRankings WORST Xbox360\002" } if {[string match -nocase "ds" $input] == 1} { set html [fetch_html "1" 37] set output "\002GameRankings WORST NDS\002" } if {[string match -nocase "gba" $input] == 1} { set html [fetch_html "1" 38] set output "\002GameRankings WORST GBA\002" } if {[string match -nocase "psp" $input] == 1} { set html [fetch_html "1" 39] set output "\002GameRankings WORST PSP\002" } if {[string match -nocase "mobile" $input] == 1} { set html [fetch_html "1" 40] set output "\002GameRankings WORST Mobile\002" } if {[string match -nocase "ngage" $input] == 1} { set html [fetch_html "1" 41] set output "\002GameRankings WORST N-Gage\002" } if {[string match -nocase "3do" $input] == 1} { set html [fetch_html "1" 42] set output "\002GameRankings WORST 3D0\002" } if {[string match -nocase "dc" $input] == 1} { set html [fetch_html "1" 43] set output "\002GameRankings WORST Dreamcast\002" } if {[string match -nocase "gen" $input] == 1} { set html [fetch_html "1" 44] set output "\002GameRankings WORST Genesis\002" } if {[string match -nocase "jag" $input] == 1} { set html [fetch_html "1" 45] set output "\002GameRankings WORST Jaguar\002" } if {[string match -nocase "n64" $input] == 1} { set html [fetch_html "1" 46] set output "\002GameRankings WORST N64\002" } if {[string match -nocase "neo" $input] == 1} { set html [fetch_html "1" 47] set output "\002GameRankings WORST Neo-Geo\002" } if {[string match -nocase "ps1" $input] == 1} { set html [fetch_html "1" 48] set output "\002GameRankings WORST Playstation\002" } if {[string match -nocase "sat" $input] == 1} { set html [fetch_html "1" 49] set output "\002GameRankings WORST Saturn\002" } if {[string match -nocase "snes" $input] == 1} { set html [fetch_html "1" 50] set output "\002GameRankings WORST Snes\002" } if {[string match -nocase "segacd" $input] == 1} { set html [fetch_html "1" 52] set output "\002GameRankings WORST Sega-CD\002" } if {[string match -nocase "gameboy" $input] == 1} { set html [fetch_html "1" 53] set output "\002GameRankings WORST GameBoy\002" } if {[string match -nocase "gbc" $input] == 1} { set html [fetch_html "1" 54] set output "\002GameRankings WORST GameBoy Color\002" } if {[string match -nocase "all" $input] == 1} { set html [fetch_html "1" 55] set output "\002GameRankings WORST -ALL-\002" } if {[string match -nocase "3ds" $input] == 1} { set html [fetch_html "1" 57] set output "\002GameRankings WORST 3DS\002" } if {[string match -nocase "mac" $input] == 1} { set html [fetch_html "1" 58] set output "\002GameRankings WORST MAC\002" } if {[string match -nocase "*http://www.gamespot.com/gamerankings/offline.html*" $html]} { append output "${incith::google::seperator}${::incith::google::error_modes}We're sorry, we are temporarily offline. We'll be back as soon as possible." return $output } if {[string match -nocase "*Temporarily Unavailable*" $html]} { append output "${incith::google::seperator}${::incith::google::error_modes}GameRankings is Temporarily Unavailable." return $output } if {$output == ""} { return "${::incith::google::desc_modes}Sorry, that system is not supported! \[system = gc/pc/mac/ps2/ps3/wii/xbox/x360/3ds/ds/gba/psp/mobile/ngage/3do/dc/gen/jag/n64/neo/ps1/sat/snes\] usage: $::lastbind system" } else { set output "$::incith::google::total_modes$output$::incith::google::total_demodes" } regsub -all "(?:\t|\n|\r|\v)" $html "" html # remove the bold if it isn't desired. if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } # parse for results and loop until desired amount of results # is attempted to be reached if possible. while {$results < $incith::google::popular_results && $output != ""} { # grab date and game title and clear future html of it for looping if {[regexp -- {.*?.*?(.*?).*?(.+?).*?
    (.+?)(.+?)<} $html - sys game pub date]} { regsub -- {>.*?} $date "" date } # if there's no desc, return or stop looping, depending if {![info exists game]} { if {$results == 0} { set reply "Sorry, no search results were found." return "$::incith::google::desc_modes$reply$::incith::google::desc_modes" } else { break } } # add the search result # add game to output if there is one if {[info exists game]} { if {[string match -nocase "all" $input] == 1} { append output "${incith::google::seperator}$::incith::google::desc_modes\002${game}\002 ($sys) by $pub (${date})$::incith::google::desc_demodes" } else { append output "${incith::google::seperator}$::incith::google::desc_modes\002${game}\002 by $pub (${date})$::incith::google::desc_demodes" } unset game; unset date } # increase the results, clear the variables for the next loop just in case incr results } # if we have nothing to send, we have no results :( if {$output == ""} { set output "${::incith::google::desc_modes}Sorry, found no results! \[system = gc/pc/ps2/ps3/wii/xbox/x360/ds/gba/psp/mobile/ngage/3d0/dc/gen/jag/n64/neo/ps1/sat/snes\] usage: !top system" } return "$output" } # Google Trends # fetches top search terms from google # -speechless supplied # proc trends {input} { # lots of variables, keeping them clean is important. ; set results 0 ; set output "" ; set tresult "" ; set no_results "" ; set no_search "" set html [fetch_html $input 13] # user input causing errors? if {[string match -nocase "*socketerrorabort*" $html]} { regsub {(.+?)\|} $html {} html return "${::incith::google::error_modes}Socket Error accessing '${html}' .. Does it exist?${::incith::google::error_demodes}" } if {[string match -nocase "*timeouterrorabort*" $html]} { return "${::incith::google::error_modes}Connection has timed out...${::incith::google::error_demodes}" } # give location results we are displaying. regexp -- {} $html - tresult if {$tresult != ""} { set output "$::incith::google::total_modes${tresult}$::incith::google::total_demodes${incith::google::seperator}" } # get what we call the no_search for any language. if {[string match "*system_down.html*" $html]} { set no_search "$::incith::google::error_modes\002Trends Error:\002 System appears to be down, try again later.$::incith::google::error_demodes" } else { if {[regexp -- {

    (.+?)

    } $html - no_search]} { regsub -- {

    } $no_search { } no_search } else { if {![regexp -- {

    • (.+?)
    } $html - no_search]} { regexp -- {
    (.+?)

    (.+?)

    } $html - no_search } } } # remove the bold if it isn't desired. if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } # parse for results and loop until desired amount of results # is attempted to be reached if possible. while {$results < $incith::google::trends_results} { set link "$::incith::google::total_modes\002[expr $results + 1]\002$::incith::google::total_demodes" # grab our trend and cut it out regexp -- {.+?(.+?)} $html {} desc regsub -- {.+?(.+?)} $html "" html if {[info exists desc]} { append link " $incith::google::desc_modes$desc$::incith::google::desc_demodes" } else { if {$results == 0} { set reply "${no_search}" return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } else { break } } # add the search result # add game to output if there is one if {[info exists desc]} { append output "${link}${incith::google::split_char}" } # increase the results, clear the variables for the next loop just in case unset desc; unset link incr results } # if we have nothing to send, we have no results :( if {$output == ""} { set output "$::incith::google::desc_modes${no_search}$::incith::google::desc_demodes" } return [string trim $output $incith::google::split_char] } # Gamespot Game Review # fetches review results from gamespot searches. # -speechless supplied # proc rev {input} { global incithcookie # lots of variables, keeping them clean is important.. ; set results "" ; set output "" ; set tresult ""; set inputb "" ; set ebcU "" ; set ebcI "" ; set ebcPR "" ; set review "" ; set us "?" ; set them "?" ; set you "?" ; set stats "" ; set vid "" regexp -nocase -- {^(.+?) @ (.+?)$} $input - input inputb # fetch the html set html [fetch_html $input 12] regsub -all {\\n} $html "" html if {[string match "*NO RESULTS RETURNED*" $html]} { set reply "${::incith::google::desc_modes}Sorry, no search results were found." return $reply } if {$inputb != ""} { while {$results == ""} { # this could break any second, its cumbersome and long..i know, but for now it works. regexp -- {
    .*?(.+?)<\\/a>} $html - ebcU ebcI set ebcU [string map {"\\" ""} $ebcU] if {[string match -nocase "*\(${inputb}\)*" $ebcI] == 1} { set results "true" } if {$ebcU == $ebcPR} { regsub -all { } $input {%20} input return "${::incith::google::desc_modes}Sorry, game does not appear for that console when searching first page results. See for yourself @ http://www.gamespot.com/pages/search/index.php?qs=${input}#game" } regsub -- {
    .*?.+?<\\/a>} $html "" html set ebcPR $ebcU } } # get url snippet where game review can be pulled if {$inputb == ""} { if {[regexp -- {} $html - name]} { regexp -- {(.+?) \- } $html {} name # sometimes our game and system cut isn't pretty this cleans it up regexp -- {(.+?)<.+?title} $name - name set name [string trim $name] } else { regsub -- {</h1>} $name " " name regsub -all -- {<.*?>} $name "" name } if {[regexp -- {\&tag=scoresummary%3Bgs-score">(.+?)<} $html - us]} { regsub -- {<.*?>} $us "" us } if {[regexp -- {\&tag=scoresummary%3Bcritic-score">(.+?)<} $html - them]} { regsub -- {<.*?>} $them "" them } regexp -- {\?tag=scoresummary%3Buser-score">(.+?)<} $html - you if {[regexp -- {<ul class="stats">(.+?)<div class="actions">} $html - stats]} { regsub {<div class="label">Top 5 User Tags\:.+?</ol>} $stats "" stats regsub {<div class="desc">.+?</ul>} $stats "" stats regsub {<li class="stat universe">.+?</ul>} $stats "" stats regsub -all {<.+?>} $stats "" stats while {[string match "* *" $stats]} { regsub -all -- { } $stats " " stats } regsub {More Info Game Stats} $stats "» «" stats regsub {Tracking\:.+?Wish It»} $stats "» «" stats regsub -all {»} $stats "» «" stats regsub -all {/\s»} $stats "»" stats regsub -all {«\s/} $stats "«" stats } if {[regexp {<p class="review deck".*?>(.+?)</p>} $html - review]} { regsub -all -- {<.*?>} $review "" review set review " « $review »" } elseif {[regexp {<p class="product deck".*?>(.+?)</p>} $html - review]} { regsub -all -- {<.*?>} $review "" review set review " « $review »" } if {[regexp -- {<ul class="videos">.+?<a href="(.+?)".*?">(.+?)</a>} $html - vurl vid]} { if {[regexp -nocase -- {a href=""} $vid]} { if {[regexp -- {<div class="module videos">.*?<div class="head">.*?href="(.*?)">(.*?)</a>} $html - vurl vid]} { set vurl "http://www.gamespot.com$vurl" } } else { regexp -- {^(.+?)?tag=;} $vurl - vurl } if {[string match "/" [string index $vurl 0]]} { set vurl "http://www.gamespot.com$vurl" } set vid "$incith::google::desc_modes ... \002Video:\002 $vid$::incith::google::desc_demodes$::incith::google::break$::incith::google::link_modes$vurl$::incith::google::link_demodes" } set desc "[descdecode "${name} \(us\002$us\002 them\002$them\002 you\002$you\002\) «$stats»$review"]" # make sure we have something to send set output "$::incith::google::desc_modes${desc}$::incith::google::desc_demodes$::incith::google::break$::incith::google::link_modes${query}$::incith::google::link_demodes$vid" return $output } # IGN # fetches games results from ign searches. # -speechless supplied # proc ign {input} { # lots of variables, keeping them clean is important. # borrowed mostly from my ebay proc above. ; set results 0 ; set output "" ; set tresult "" ; set ebcU "" ; set ebcI "" ; set ebcBid "" ; set ebcPR "" ; set ebcCheck "" ; set match "" # fetch the html set html [fetch_html $input 26] if {$html == ""} { return "${::incith::google::error_modes}IGN search page appears to be blank... No results maybe?!" } # give results an output header with result tally. # regexp -- {All Products \(([,0-9]{1,})\)<br/>} $html - match set match "iGN" # format output according to variables. if {$match != ""} { set output "$::incith::google::total_modes\002${match}\002 results$::incith::google::total_demodes${incith::google::seperator}" if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } } else { regexp -- {<p.*?class="searchResultTitle">(.+?)</p>} $html - match set output "${match}$::incith::google::seperator" } if {[regexp -- {<p class="searchResultTitle".+?<strong>(.+?)<br} $html - no_search]} { return $no_search } # parse the html while {$results < $incith::google::ign_results} { # this could break any second, its cumbersome and long..i know, but for now it works. regexp -- {<h3 class="game-title"><a href="(.*?)">(.*?)</h3>} $html - ebcU ebcI if {![regexp -- {class="publisherLink">(.*?)</a>(.*?)</p>} $html - ebcBid desc]} { regexp -- {<div id="articleType"><strong>(.+?)</strong>} $html - ebcBid set desc "" } else { set desc [string trim $desc "- "] regsub -all -- {\s+} $desc " " desc if {[string length $desc]} { set desc " - $desc" } } regsub -- {<h3 class="game-title">(.+?)</div>} $html "" html # check results are more than 0, return or stop looping, depending if {![string length $ebcU]} { if {$results == 0} { regexp -nocase -- {<p class="searchFail">(.*?)</p>} $html - reply return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } else { break } } # this needs to be done for user formatting of links and descriptions. set link "${ebcU}" # prevent duplicate results is mostly useless here, but will at least # ensure that we don't get the exact same article. if {[string match "*$link*" $output] == 1} { break } # ign clutters with excess spacing to make parsing hard # this is a quick and dirty way to get through the mud. #clean up messy parsing. regsub -all {<script type=.+?script>} $ebcBid {} ebcBid regsub -all -- {<(.+?)>} $ebcBid {} ebcBid while {[string match "* *" $ebcBid]} { regsub -all -- { } $ebcBid " " ebcBid } set ebcBid [string trim $ebcBid] regexp -- {^(.*?)</a>(.*?)$} $ebcI - ebcI plat regexp -- {<span class="platform default">(.*?)</span>} $ebcI - plat regexp -- {^(.*?)</a>} $ebcI - ebcI regsub -all -- {\s+} $plat { } plat # set formatting. set desc "${ebcI} ([string totitle $plat] by ${ebcBid})$desc" if {[info exists desc]} { set desc "$incith::google::desc_modes[string trim $desc]$incith::google::desc_demodes" } if {[info exists link]} { set link "$incith::google::link_modes[string trim $link]$incith::google::link_demodes" } # add the search result if {$incith::google::link_only == 1} { append output "${link}${incith::google::seperator}" } else { append output "[descdecode ${desc}]$::incith::google::break${link}${incith::google::seperator}" } # increase the results, clear the variables for the next loop just in case unset link ; set ebcCheck "" incr results } # make sure we have something to send if {[info exists output] == 0} { set reply "Sorry, no search results were found." return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } return $output } # GameSpot # fetches games results from gamespot searches. # -speechless supplied # proc gamespot {input} { # lots of variables, keeping them clean is important. # borrowed mostly from my ebay proc above. ; set results 0 ; set output "" ; set tresult "" ; set type "" ; set name "" ; set details "" ; set deck "" # fetch the html set html [fetch_html $input 12] regsub -all {\\n} $html "" html # set up gamespot results header so results can be appended to it. regexp -- {,"num_results"\:"(.+?)"} $html {} tresult set tresult [string trim $tresult] # format output according to variables. if {$incith::google::total_results != 0} { set output "$::incith::google::total_modes\002[string trim ${tresult}]\002 games$::incith::google::total_demodes${incith::google::seperator}" if {$incith::google::bold_descriptions == 0} { regsub -all -- "\002" $output {} output } } # parse the html while {$results < $incith::google::gamespot_results} { # this could break any second, its cumbersome and long..i know, but for now it works. if {[regexp -- {<div class=\\"result_title\\">(.*?)<a href=\\"(.+?)\\">(.*?)<\\/a>.*?<div class=\\"details\\">(.*?)<\\/div>.+?<div class=\\"deck\\">(.*?)<\\/div>} $html - type link name details deck]} { regexp -- {^(.+?)\?tag=result} $link - link if {[string length $deck] > 0} {set deck " - [string trim $deck]"} regsub -- {<div class=\\"result_title\\">.+?<div class=\\"deck\\">.+?<\\/div>} $html "" html set details [string map {" | " "/"} $details] set link [string map {"\\" ""} $link] set desc "\002[string trim $type] [string trim $name]\002 \([string trim $details]\)$deck" } # check results are more than 0, return or stop looping, depending if {![info exists link]} { if {$results == 0} { set reply "Sorry, no search results were found." return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } else { break } } regsub -all {<.+?>} $desc "" desc # prevent duplicate results is mostly useless here, but will at least # ensure that we don't get the exact same article. if {[string match "*$link*" $output] == 1} { break } if {[info exists desc]} { set desc "$incith::google::desc_modes[string trim $desc]$incith::google::desc_demodes" } if {[info exists link]} { set link "$incith::google::link_modes[string trim $link]$incith::google::link_demodes" } # add the search result if {$incith::google::link_only == 1} { append output "${link}${incith::google::seperator}" } else { append output "${desc}$::incith::google::break${link}${incith::google::seperator}" } # increase the results, clear the variables for the next loop just in case unset link ; set name "" ; set deck "" ; set type "" ; set details "" incr results } # make sure we have something to send if {[info exists output] == 0} { set reply "Sorry, no search results were found." return "$::incith::google::desc_modes$reply$::incith::google::desc_demodes" } return $output } # TriggerBot # Displays all the triggers this scripts is capable of # explaining syntax, and also will let user know if trigger # is disabled or how many results are available. # -speechless supplied # proc helpbot {nick input} { set temp "" ; set output "" ; set num 0 ; set all 0 set item "" ; set found "" if {[string tolower $input] == [lindex [split $incith::google::helplist " "] 0]} { set all 1 ; set found "all" } if {$all == 0} { foreach item [split $incith::google::helplist] { if {[string tolower $input] == $item} { set found $item } } if {$found == ""} { foreach item [split $incith::google::helplist " "] { append temp "${item}," } set temp [string trimright $temp ","] return "${incith::google::helpmsg1} ${temp}" } } puthelp "NOTICE $nick :--> Bot triggers available:" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 1]} { foreach trig [split $incith::google::google_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::search_results > 0} { set item "${incith::google::helpmsg3}${incith::google::search_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help1} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 2]} { foreach trig [split $incith::google::image_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::image_results > 0} { set item "${incith::google::helpmsg3}${incith::google::image_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help2} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 3]} { foreach trig [split $incith::google::group_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::group_results > 0} { set item "${incith::google::helpmsg3}${incith::google::group_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help3} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 4]} { foreach trig [split $incith::google::news_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::news_results > 0} { set item "${incith::google::helpmsg3}${incith::google::news_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help4} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 5]} { foreach trig [split $incith::google::local_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::local_results > 0} { set item "${incith::google::helpmsg3}${incith::google::local_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help5} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 6]} { foreach trig [split $incith::google::print_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::print_results > 0} { set item "${incith::google::helpmsg3}${incith::google::print_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help6} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 7]} { foreach trig [split $incith::google::video_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::video_results > 0} { set item "${incith::google::helpmsg3}${incith::google::video_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help7} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 8]} { foreach trig [split $incith::google::fight_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::google_fight > 0} { set item "${incith::google::helpmsg3}${incith::google::google_fight}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help8} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 9]} { foreach trig [split $incith::google::youtube_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::youtube_results > 0} { set item "${incith::google::helpmsg3}${incith::google::youtube_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help9} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 10]} { foreach trig [split $incith::google::trans_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::trans_results > 0} { set item "${incith::google::helpmsg3}${incith::google::trans_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help10} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 11]} { foreach trig [split $incith::google::gamespot_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::gamespot_results > 0} { set item "${incith::google::helpmsg3}${incith::google::gamespot_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help11} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 12]} { foreach trig [split $incith::google::gamefaq_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::gamefaq_results > 0} { set item "${incith::google::helpmsg3}${incith::google::gamefaq_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help12} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 13]} { foreach trig [split $incith::google::blog_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::blog_results > 0} { set item "${incith::google::helpmsg3}${incith::google::blog_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help13} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 14]} { foreach trig [split $incith::google::ebay_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::ebay_results > 0} { set item "${incith::google::helpmsg3}${incith::google::ebay_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help14} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 15]} { foreach trig [split $incith::google::efight_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::google_fight > 0} { set item "${incith::google::helpmsg3}${incith::google::google_fight}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help15} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 16]} { foreach trig [split $incith::google::wiki_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::wiki_results > 0} { set item "${incith::google::helpmsg3}${incith::google::wiki_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help16} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 17]} { foreach trig [split $incith::google::wikimedia_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::wikimedia_results > 0} { set item "${incith::google::helpmsg3}${incith::google::wikimedia_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help17} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 18]} { foreach trig [split $incith::google::locate_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::locate_results > 0} { set item "${incith::google::helpmsg3}${incith::google::locate_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help18} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 19]} { foreach trig [split $incith::google::rev_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::rev_results > 0} { set item "${incith::google::helpmsg3}${incith::google::rev_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help19} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 20]} { foreach trig [split $incith::google::mininova_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::mininova_results > 0} { set item "${incith::google::helpmsg3}${incith::google::mininova_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help20} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 21]} { foreach trig [split $incith::google::recent_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::recent_results > 0} { set item "${incith::google::helpmsg3}${incith::google::recent_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help21} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 22]} { foreach trig [split $incith::google::popular_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::popular_results > 0} { set item "${incith::google::helpmsg3}${incith::google::popular_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help22} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 23]} { foreach trig [split $incith::google::daily_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::daily_results > 0} { set item "${incith::google::helpmsg3}${incith::google::daily_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help23} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 24]} { foreach trig [split $incith::google::ign_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::ign_results > 0} { set item "${incith::google::helpmsg3}${incith::google::ign_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help24} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 25]} { foreach trig [split $incith::google::myspacevids_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::myspacevids_results > 0} { set item "${incith::google::helpmsg3}${incith::google::myspacevids_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help25} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 26]} { foreach trig [split $incith::google::trends_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::trends_results > 0} { set item "${incith::google::helpmsg3}${incith::google::trends_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help26} ${item}" } set temp "" if {$found == "all" || $found == [lindex [split $incith::google::helplist " "] 27]} { foreach trig [split $incith::google::scholar_binds " "] { append temp "${incith::google::command_char}${trig}," } set temp [string trimright $temp ","] if {$incith::google::scholar_results > 0} { set item "${incith::google::helpmsg3}${incith::google::image_results}${incith::google::helpmsg4}" } else { set item "${incith::google::helpmsg2}" } puthelp "NOTICE $nick :${temp} ${incith::google::help27} ${item}" } } # FETCH_HTML # fetches html for the various *.google.com sites # proc fetch_html {input switch} { global incithcharset global incithcookie set country "" #--> # Begin urlencoding kludge if {($switch < 15) || ($switch > 23) && ($switch != 28) && ($switch !=29) && ($switch !=56) && ($switch !=58) && ($switch !=59)} { set helps $input regexp -nocase -- {^\.(.+?)\s(.+?)$} $input - country input # this is my input encoding hack, this will convert input before it goes # out to be queried. if {$incith::google::encoding_conversion_input > 0 && $country != "" } { set encoding_found [lindex [split [lindex $incith::google::encode_strings [lsearch -glob $incith::google::encode_strings "$country:*"]] :] 1] if {$encoding_found != "" && [lsearch -exact [encoding names] $encoding_found] != -1} { set input [encoding convertfrom $encoding_found $input] } } else { set encoding_found "" } set input [urlencode $input 0 "utf-8"] set country "" ;#reset country and input } #<-- # End urlencoding kludge # GOOGLE if {$switch == 1} { # make it so people can search their country set country "" regexp -nocase -- {^\.(.+?)\s(.+?)$} $helps - country dummy if {$country == ""} { set country "${incith::google::google_country}" set flavor "search" } else { if {[string match */* $country]} { if {![string length [set flavor [join [lrange [split $country /] 1 end] /]]]} { set flavor "search" } set country [lindex [split $country /] 0] } else { set flavor "search" } } if {[string equal -nocase "intl" [lindex [split $flavor /] 0]]} { set lng [lindex [split $flavor /] 1] set uselang 1 } # we don't want 'define:+<search>', so we'll just remove the space if there is one. regsub -nocase -- {^define:\s*} $input {define:} input # spell after define so 'spell: define: foo' doesn't turn into a define lookup if {[string match -nocase "spell%3a*" $input] == 1} { regsub -nocase -- {^spell%3a\s*} $input {} input set spell "&spell=1" } else { set spell "" } if {[info exists uselang]} { set query "http://www.google.${country}/search?hl=${lng}&q=${input}&safe=${incith::google::safe_search}&lr=lang_${incith::google::language}&ie=utf-8${spell}&nfpr=1" } else { set query "http://www.google.${country}/${flavor}?q=${input}&safe=${incith::google::safe_search}&lr=lang_${incith::google::language}&ie=utf-8${spell}&nfpr=1" } # IMAGES } elseif {$switch == 2} { # make it so people can search their country set country "" regexp -nocase -- {^\.(.+?)\s(.+?)$} $helps - country dummy if {$country == ""} { set country "${incith::google::google_country}" } set query "http://images.google.${country}/images?q=${input}&safe=${incith::google::safe_search}&btnG=Search+Images&ie=utf-8&sout=1&nfpr=1" # LOCAL } elseif {$switch == 3} { # make it so people can search their country set country "" regexp -nocase -- {^\.(.+?)\s(.+?)$} $helps - country dummy if {$country == ""} { set country "${incith::google::google_country}" set dummy $helps } #regexp -nocase -- {^(.+?) near (.+?)$} $dummy - search location #set query "http://maps.google.${country}/maps?f=q&q=${search}&near=${location}&ie=UTF8&filter=0&oi=lwp_thresh&sa=X&view=text&ct=clnk&cd=1&nfpr=1" set query "http://maps.google.${country}/maps?f=q&q=${input}&ie=utf-8&filter=0&oi=lwp_thresh&sa=X&view=text&ct=clnk&cd=1&nfpr=1" } elseif {$switch == 4} { # make it so people can search their country set country "" regexp -nocase -- {^\.(.+?)\s(.+?)$} $helps - country dummy if {$country == ""} { set country "${incith::google::google_country}" } set query "http://groups.google.${country}/groups/search?ie=UTF-8&q=${input}&qt_s=Search&safe=${incith::google::safe_search}&ie=utf-8&nfpr=1" } elseif {$switch == 5} { # make it so people can search their country set country "" regexp -nocase -- {^\.(.+?)\s(.+?)$} $helps - country dummy if {$country == ""} { set country "${incith::google::google_country}" } set query "http://news.google.${country}/news?q=${input}&ie=utf-8&nfpr=1" } elseif {$switch == 6} { # make it so people can search their country set country "" regexp -nocase -- {^\.(.+?)\s(.+?)$} $helps - country dummy if {$country == ""} { set country "${incith::google::google_country}" } set query "http://books.google.${country}/books?q=${input}&btnG=Search+Books&ie=utf-8&nfpr=1" } elseif {$switch == 7} { # make it so people can search their country set country "" regexp -nocase -- {^\.(.+?)\s(.+?)$} $helps - country dummy if {$country == ""} { set country "${incith::google::google_country}" } set query "http://www.google.${country}/search?q=${input}&tbs=vid:1&nfpr=1" #set query "http://video.google.${country}/videosearch?q=${input}&btnG=Search+Video&ie=utf-8" } elseif {$switch == 8} { # make it so people can search their country set country "" regexp -nocase -- {^\.(.+?)\s(.+?)$} $helps - country dummy if {$country == ""} { set country "${incith::google::google_country}" } set query "http://www.google.${country}/search?hl=&q=${input}&safe=off&btnG=Search&lr=lang_all&num=1&ie=utf-8" } elseif {$switch == 9} { # make it so people can search their country set country "" ; set hd "" if {[regsub -nocase -all -- "[urlencode $::incith::google::youtube_highdef 0]" $input "" input]} { set hd "&high_definition=1" } regexp -nocase -- {^\.(.+?)\s(.+?)$} $helps - country dummy if {$country == ""} { set country "${incith::google::youtube_country}" } if {$country == "com"} { set query "http://www.youtube.com/results?search_query=${input}&hl=en&ie=utf-8$hd" } else { set query "http://${country}.youtube.com/results?search_query=${input}&hl=${country}&ie=utf-8$hd" } } elseif {$switch == 10} { # make it so people can search their country set country "" regexp -nocase -- {^\.(.+?)\s(.+?)$} $helps - country dummy if {$country == ""} { set country "${incith::google::google_country}" } set query "http://scholar.google.${country}/scholar?hl=all&lr=&safe=${incith::google::safe_search}&q=${input}&btnG=Search&ie=utf-8" } elseif {$switch == 11} { #set query "http://vidsearch.myspace.com/index.cfm?fuseaction=vids.fullsearch&searchText=${input}&fullSearch=Search%20Videos" #set query "http://vids.myspace.com/index.cfm?SearchBoxID=SplashHeader&fuseaction=vids.search&q=${input}&t=tvid" set query "http://searchservice.myspace.com/index.cfm?fuseaction=sitesearch.results&orig=search_Header&origpfc=VidsSplash&type=MySpaceTV&qry=${input}&submit=Search" } elseif {$switch == 12} { #set query "http://www.gamespot.com/search.html?qs=${input}&x=0&y=0" #set query "http://www.gamespot.com/pages/search/index.php?qs=${input}&sub=g" set query "http://www.gamespot.com/pages/search/search_ajax.php?q=${input}&type=game&offset=0&tags_only=false&sort=rank" #set query "http://www.gamespot.com/search.html?tag=search%3Bbutton&om_act=convert&om_clk=search&qs=${input}" #set query "http://www.gamespot.com/pages/search/index.php?qs=${input}#game" #set query "http://www.gamespot.com/search.html?qs=${input}" #set query "http://www.gamespot.com/pages/tags/index.php?type=game&tags=${input}" } elseif {$switch == 13} { # make it so people can search their country set country "" regexp -nocase -- {^\.(.+?)\s(.+?)$} $helps - country dummy if {$country == ""} { set country "${incith::google::google_country}" } set query "http://www.google.${country}/trends/hottrends?date=${input}&sa=x&ctab=0&hl=en" } elseif {$switch == 14} { # make it so people can search their country set country "" regexp -nocase -- {^\.(.+?)\s(.+?)$} $helps - country dummy if {$country == ""} { set country "${incith::google::daily_country}" } if {$country == "en"} { set query "http://www.dailymotion.com/relevance/search/${input}" } else { set query "http://www.dailymotion.com/${country}/relevance/search/${input}" } } elseif {$switch == 15} { set query "http://www.gamefaqs.com/ds/releases${input}" } elseif {$switch == 16} { set query "http://www.gamefaqs.com/iphone/releases${input}" } elseif {$switch == 17} { set query "http://www.gamefaqs.com/psp/releases${input}" } elseif {$switch == 18} { set query "http://www.gamefaqs.com/xbox360/releases${input}" } elseif {$switch == 19} { set query "http://www.gamefaqs.com/xbox/releases${input}" } elseif {$switch == 20} { set query "http://www.gamefaqs.com/gamecube/releases${input}" } elseif {$switch == 21} { set query "http://www.gamefaqs.com/ps2/releases${input}" } elseif {$switch == 22} { set query "http://www.gamefaqs.com/pc/releases${input}" } elseif {$switch == 23} { set query "http://www.gamefaqs.com/ps3/releases${input}" } elseif {$switch == 24} { # make it so people can search their country set country "" regexp -nocase -- {^\.(.+?)\s(.+?)$} $helps - country dummy if {$country == ""} { set country "${incith::google::google_country}" } regsub -all -- {-} $input "%2d" input set query "http://blogsearch.google.${country}/blogsearch?q=${input}&lr=&sa=N&tab=gn&ie=utf-8" } elseif {$switch == 25} { # make it so people can search their country set country "" ; set shop "" regexp -nocase -- {^\.(.+?)\s(.+?)$} $helps - country dummy if {$country == ""} { if {![regexp -nocase -- {^\@(.+?)\s(.+?)$} $helps - shop input]} { set country $::incith::google::ebay_country } } regsub -all -- {-} $input "%2d" input regsub -all -- { } $input "-" input #set query "http://search.ebay.com/search/search.dll?sofocus=unknown&sbrftog=1&from=R10&_trksid=m37&satitle=${input}&sacat=-1%26catref%3DC6&sargn=-1%26saslc%3D2&sadis=200&fpos=95482&sabfmts=1&saobfmts=insif&ftrt=1&ftrv=1&saprclo=&saprchi=&fsop=1%26fsoo%3D1&coaction=compare&copagenum=1&coentrypage=search" #set query "http://search.ebay.${country}/${input}" #set query "http://shop.ebay.${country}/items/_W0QQ_nkwZ${input}QQ_armrsZ1QQ_fromZQQ_mdoZ" #set query "http://shop.ebay.${country}/${input}" #set query "http://shop.ebay.${country}/items/_W0QQ_nkwZ${input}QQ_armrsZ1QQ_fromZQQ_mdoZ" if {![string length $shop]} { set query "http://shop.ebay.${country}/i.html?_nkw=${input}&_armrs=1&_from=&_ipg=&_dmd=1" } else { set query "http://$shop.shop.ebay.com/?_nkw=${input}&_armrs=1&_from=&_ipg=&_dmd=1" } #set query "http://search.ebay.${country}/${input}_W0QQpqryZ${input}" } elseif {$switch == 26} { set query "http://search.ign.com/products?sort=relevance&query=${input}&so=exact&objtName=all&origin=&startat=0&nc=false&ns=false" #set query "http://search.ign.com/products?query=${input}" } elseif {$switch == 27} { # place holder for wikipedia # eventually it will get put back into fetch_html } elseif {$switch == 28} { set query "http://www.gamefaqs.com/wii/releases${input}" } elseif {$switch == 29} { set query "http://www.gamefaqs.com/dreamcast/releases${input}" } elseif {$switch == 30} { set query "http://www.gamerankings.com/browse.html?site=gamecube&cat=0&year=2&numrev=0&sort=${input}&search=" } elseif {$switch == 31} { set query "http://www.gamerankings.com/browse.html?site=pc&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 32} { set query "http://www.gamerankings.com/browse.html?site=ps2&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 33} { set query "http://www.gamerankings.com/browse.html?site=ps3&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 34} { set query "http://www.gamerankings.com/browse.html?site=wii&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 35} { set query "http://www.gamerankings.com/browse.html?site=xbox&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 36} { set query "http://www.gamerankings.com/browse.html?site=xbox360&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 37} { set query "http://www.gamerankings.com/browse.html?site=ds&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 38} { set query "http://www.gamerankings.com/browse.html?site=gba&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 39} { set query "http://www.gamerankings.com/browse.html?site=psp&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 40} { set query "http://www.gamerankings.com/browse.html?site=mobile&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 41} { set query "http://www.gamerankings.com/browse.html?site=ngage&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 42} { set query "http://www.gamerankings.com/browse.html?site=3do&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 43} { set query "http://www.gamerankings.com/browse.html?site=dreamcast&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 44} { set query "http://www.gamerankings.com/browse.html?site=genesis&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 45} { set query "http://www.gamerankings.com/browse.html?site=jaguar&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 46} { set query "http://www.gamerankings.com/browse.html?site=n64&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 47} { set query "http://www.gamerankings.com/browse.html?site=neo&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 48} { set query "http://www.gamerankings.com/browse.html?site=ps&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 49} { set query "http://www.gamerankings.com/browse.html?site=saturn&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 50} { set query "http://www.gamerankings.com/browse.html?site=snes&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 51} { set query "http://www.mininova.org/search/${input}/seeds" } elseif {$switch == 52} { set query "http://www.gamerankings.com/browse.html?site=segacd&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 53} { set query "http://www.gamerankings.com/browse.html?site=gameboy&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 54} { set query "http://www.gamerankings.com/browse.html?site=gbc&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 55} { set query "http://www.gamerankings.com/browse.html?site=&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 56} { set query "http://www.gamefaqs.com/3ds/releases${input}" } elseif {$switch == 57} { set query "http://www.gamerankings.com/browse.html?site=3ds&cat=0&year=0&numrev=3&sort=${input}&search=" } elseif {$switch == 58} { set query "http://www.gamerankings.com/browse.html?site=mac&cat=0&year=0&numrev=2&sort=${input}&search=" } elseif {$switch == 59} { set query "http://www.gamefaqs.com/mac/releases${input}" } # didnt have this before, this is needed for google parsers to correctly # encode the 'do not include' tag, aka the hyphen.. hehe if {$switch < 9} { regsub -nocase -- {-} $input "%2d" input } regsub -all -- {\+} $query {%2B} query regsub -all -- {\"} $query {%22} query if {$switch != 25} { regsub -all -- { } $query {+} query } if {$switch == 12} { # grab the ajax data set http [::http::geturl $query -headers "X-Requested-With XMLHttpRequest X-Request JSON Referer $query $::incith_hdr" -timeout [expr 1000 * 10]] upvar #0 $http state set html [ungzip [string map {"\\n" "" "\\" ""} [::http::data $http]] $state(meta)] set incithcharset [string map -nocase {"UTF-" "utf-" "iso-" "iso" "windows-" "cp" "shift_jis" "shiftjis"} $state(charset)] set redir [::http::ncode $http] set cookies [list] } else { # beware, changing the useragent will result in differently formatted html from Google. set ua "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3" #set ua "Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.7e" # enable proxy if {![string length $::incith::google::proxy_host]} { set http [::http::config -useragent $ua] } else { set http [::http::config -useragent $ua -proxyhost $::incith::google::proxy_host -proxyport $::incith::google::proxy_port] } # stole this bit from rosc2112 on egghelp forums # borrowed is a better term, all procs eventually need this error handler. catch {set http [::http::geturl "$query" -headers $::incith_hdr -timeout [expr 1000 * 12]]} error if {[string match -nocase "*couldn't open socket*" $error]} { return "socketerrorabort|${query}" } if { [::http::status $http] == "timeout" } { return "timeouterrorabort" } upvar #0 $http state set html [ungzip [::http::data $http] $state(meta)] set redir [::http::ncode $http] # CHECK CHECK upvar #0 $http state set incithcharset [string map -nocase {"UTF-" "utf-" "iso-" "iso" "windows-" "cp" "shift_jis" "shiftjis"} $state(charset)] # Are there cookies? set cookies [list] foreach {name value} $state(meta) { # do we have cookies? if {[string equal -nocase $name "Set-Cookie"]} { # yes, add them to cookie list lappend webCookies [lindex [split $value {;}] 0] } } if {[info exists webCookies] && [llength $webCookies]} { set cookies "[string trim [join $webCookies {;}] {;}]" } else { set cookies "" } # REDIRECT while {[string match "*${redir}*" "303|302|301" ]} { foreach {name value} $state(meta) { if {[regexp -nocase ^location$ $name]} { if {![string match "http*" $value]} { if {![string match "/" [string index $value 0]]} { set value "[join [lrange [split $query "/"] 0 2] "/"]/$value" } else { set value "[join [lrange [split $query "/"] 0 2] "/"]$value" } } if {[string length $cookies]} { set http [::http::geturl "[string map {" " "%20"} $value]" -headers "$::incith_hdr Referer $query Cookie $cookies" -timeout [expr 1000 * 10]] } else { set http [::http::geturl "[string map {" " "%20"} $value]" -headers "$::incith_hdr Referer $query" -timeout [expr 1000 * 10]] } if { $::incith::google::debug > 0 } { putserv "privmsg $::incith::google::debugnick :\002redirected \($redir\):\002 $query -> $value :: \002Cookie:\002 [join $cookies]" } if {[string match -nocase "*couldn't open socket*" $error]} { return "socketerrorabort|${value}" } if { [::http::status $http] == "timeout" } { return "timeouterrorabort" } upvar #0 $http state # Are there cookies? foreach {nam val} $state(meta) { # do we have cookies? if {[string equal -nocase $nam "Set-Cookie"]} { if {![info exists flagme]} { set flagme 0 set cookies [list] } # yes, add them to cookie list lappend webCookies [lindex [split $val {;}] 0] } } if {[info exists webCookies] && [llength $webCookies]} { set cookies "[string trim [join $webCookies {;}] {;}]" } else { set cookies "" } set redir [::http::ncode $http] set incithcharset [string map -nocase {"UTF-" "utf-" "iso-" "iso" "windows-" "cp" "shift_jis" "shiftjis"} $state(charset)] set query [string map {" " "%20"} $value] } } } } set html [ungzip [::http::data $http] $state(meta)] ::http::cleanup $http # ---- step 1 # Determine which encoding to use # set encoding_found [lindex [split [lindex $incith::google::encode_strings [lsearch -glob $incith::google::encode_strings "$country:*"]] :] 1] if {$incith::google::encoding_conversion_output > 0} { if {$incith::google::automagic > 0} { if {[string match -nocase "utf-8" $incithcharset] && $incith::google::utf8workaround > 0 && $encoding_found != "" && [lsearch -exact [encoding names] $encoding_found] != -1} { set new_encoding $encoding_found } else { set new_encoding $incithcharset } } else { if {$encoding_found != "" } { set new_encoding $encoding_found } else { set new_encoding "NONE" } } } else { set new_encoding "DISABLED" } # ---- step 2 # Report the conclusion to debugnick # if {$incith::google::debug > 0} { if {[string match -nocase $new_encoding $incithcharset]} { if {[lsearch -exact [encoding names] $incithcharset] != -1} { putserv "privmsg $incith::google::debugnick :\002url \($redir\):\002 $query \002\037charset:\037\002 $incithcharset \002encode_string:\002 $encoding_found :: \002Cookie:\002 $cookies" } else { putserv "privmsg $incith::google::debugnick :\002url \($redir\):\002 $query \002\037charset:\037\002 $incithcharset \037<--ERROR: Unknown\037 \002encode_string:\002 $encoding_found :: \002Cookie:\002 $cookies" } } elseif {[string match -nocase $new_encoding $encoding_found]} { if {$encoding_found != "" && [lsearch -exact [encoding names] $encoding_found] != -1} { putserv "privmsg $incith::google::debugnick :\002url \($redir\):\002 $query \002charset:\002 $incithcharset \037\002encode_string:\002\037 $encoding_found :: \002Cookie:\002 $cookies" } else { putserv "privmsg $incith::google::debugnick :\002url \($redir\):\002 $query \002charset:\002 $incithcharset \002\037encode_string:\037\002 $encoding_found \037<--ERROR: Unknown\037 :: \002Cookie:\002 $cookies" } } elseif {[string match -nocase "DISABLED" $new_encoding]} { putserv "privmsg $incith::google::debugnick :\002url \($redir\):\002 $query \002charset:\002 $incithcharset \002encode_string:\002 $encoding_found \037DISABLED:\037 Using default charset. :: \002Cookie:\002 $cookies" } else { putserv "privmsg $incith::google::debugnick :\002url \($redir\):\002 $query \002charset:\002 $incithcharset \002encode_string:\002 $encoding_found \037UNKNOWN ERROR:\037 Using default charset. :: \002Cookie:\002 $cookies" } } # ---- step 3 # Apply the encoding # if {![string match *$new_encoding* "utf-8"] && ![string equal "DISABLED" $new_encoding]} { set incithcharset $new_encoding set html [incithencode $html] } # generic pre-parsing regsub -all "\n" $html "" html regsub -all "(?:\x91|\x92|')" $html {'} html regsub -all "(?:\x93|\x94|")" $html {"} html regsub -all "&" $html {\&} html regsub -all -nocase {<sup>(.+?)</sup>} $html {^\1} html if {![string match $switch "4"] && ![string match $switch "26"]} { regsub -all -nocase {<font.+?>} $html "" html regsub -all -nocase {</font>} $html "" html regsub -all -nocase {<script type=.*?script>} $html "" html } if {![string match *$switch* "|9|7|"]} { regsub -all -nocase {<span.*?>} $html "" html regsub -all -nocase {</span>} $html "" html } regsub -all -nocase {<input.+?>} $html "" html regsub -all -nocase {(?:<i>|</i>)} $html "" html regsub -all "×" $html {*} html regsub -all " " $html { } html regsub -all -nocase "×" $html "x" html regsub -all -nocase "<" $html "<" html regsub -all -nocase ">" $html ">" html regsub -all {\x000f} $html "" html # ' # regexps that should remain seperate go here # google specific regexps if {$switch == 1} { # regexp the rest of the html for a much easier result to parse regsub -all -nocase {<b>\[PDF\]</b>\s*} $html "" html regsub {<p class=g style="margin-top:0">(.+?)</p>} $html "" html } elseif {$switch == 2} { # these %2520 codes, I have no idea. But they're supposed to be %20's regsub -all {%2520} $html {%20} html } elseif {$switch == 3} { regsub -all -nocase { - <nobr>Unverified listing</nobr>} $html "" html regsub -all -- { } $html { } html } elseif {$switch == 4} { } elseif {$switch == 5} { } elseif {$switch == 6} { } elseif {$switch == 7} { } elseif {$switch == 8} { } elseif {$switch == 9} { regsub -all "\t" $html "" html regsub -all "\n" $html "" html regsub -all "\r" $html "" html regsub -all "\v" $html "" html } elseif {$switch == 10} { regsub -all -nocase { - <nobr>Unverified listing</nobr>} $html "" html regsub -all -- { } $html { } html } elseif {$switch == 25} { regsub -all {<script.*?>.+?</script>} $html "" html regsub -all "\t" $html "" html regsub -all "\n" $html "" html regsub -all "\r" $html "" html regsub -all "\v" $html "" html regsub -all "<wbr/>" $html "" html } elseif {$switch > 11 && $switch < 31 || $switch == 56 || $switch == 58 || $switch == 59} { regsub -all "\t" $html "" html regsub -all "\n" $html "" html regsub -all "\r" $html "" html regsub -all "\v" $html "" html regsub -all "'" $html "'" html } elseif {$switch == 51} { regsub -all "<strong>|</strong>" $html "\002" html } # no point having it so many times if {$incith::google::bold_descriptions > 0 && [string match "\002" $incith::google::desc_modes] != 1} { regsub -all -nocase {(?:<b>|</b>|<em>|</em>|<strong>|</strong>)} $html "\002" html } else { regsub -all -nocase {(<b>|</b>|<em>|</em>|<strong>|</strong>)} $html "" html } # DEBUG DEBUG set junk [open "ig-debug.txt" w] puts $junk $html close $junk return $html } # PUBLIC_MESSAGE # decides what to do with binds that get triggered # proc public_message {nick uhand hand chan input} { if {[lsearch -exact [channel info $chan] +google] != -1} { if {$incith::google::chan_user_level == 3} { if {[isop $nick $chan] == 0} { return } } elseif {$incith::google::chan_user_level == 2} { if {[ishalfop $nick $chan] == 0 && [isop $nick $chan] == 0} { return } } elseif {$incith::google::chan_user_level == 1} { if {[isvoice $nick $chan] == 0 && [ishalfop $nick $chan] == 0 && [isop $nick $chan] == 0} { return } } send_output "$input" "$chan" "$nick" "$uhand" } } # PRIVATE_MESSAGE # decides what to do with binds that get triggered # proc private_message {nick uhand hand input} { if {$incith::google::private_messages >= 1} { send_output $input $nick $nick $uhand } } # SEND_OUTPUT # no point having two copies of this in public/private_message{} # proc send_output {input where nick uhand} { # this is my input encoding hack, this will convert input before it goes # out to be queried. if {$incith::google::encoding_conversion_input > 0} { if {[encoding system] != "identity" && [lsearch [encoding names] "utf-8"]} { set command_char [encoding convertfrom "utf-8" ${incith::google::command_char}] set input [encoding convertfrom "utf-8" $input] } elseif {[encoding system] == "identity"} { set command_char [encoding convertfrom identity ${incith::google::command_char}] set input [encoding convertfrom identity $input] } else { set command_char ${incith::google::command_char} } } else { set command_char ${incith::google::command_char} } #Specifically retrieve only ONE (ascii) character, then check that matches the command_char first set trigger_char [string index $input 0] if {[encoding system] == "identity"} { set trigger_char [encoding convertfrom identity $trigger_char] } #Sanity check 1 - If no match, stop right here. No need to match every (first word) of # every line of channel data against every bind if the command_char doesnt even match. if {$trigger_char != $command_char} { return } set trigger [string range [lindex [split $input] 0] 1 end] #Sanity check 2 - Stop if theres nothing to search for (quiet) if {$incith::google::aversion_vocabulary > 0} { set search [vocabaversion [string trim [string range $input [string wordend $input 1] end]]] } else { set search [string trim [string range $input [string wordend $input 1] end]] } if {$search == ""} { return } if {$incith::google::force_private == 1} { set where $nick } # check for !google if {$incith::google::search_results > 0} { foreach bind [split $incith::google::google_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # channel filter check foreach c [split $incith::google::filtered " "] { if {[string match -nocase $where $c] == 1} { return } } # flood protection check if {[flood $nick $uhand]} { return } # call google foreach line [incith::google::parse_output [google $search]] { put_output $where "$incith::google::search_prepend$line" } break } } } # check for !images if {$incith::google::image_results > 0} { foreach bind [split $incith::google::image_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call images foreach line [incith::google::parse_output [images $search]] { put_output $where "$incith::google::image_prepend$line" } break } } } # check for !local if {$incith::google::local_results > 0} { foreach bind [split $incith::google::local_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # local requires splitting of the search regexp -nocase -- {^(.+?) near (.+?)$} $search - what location if {![info exists what] || ![info exists location]} { put_output $where "Local searches should be the format of 'pizza near footown, bar'" return } foreach line [incith::google::parse_output [local $search]] { put_output $where "$incith::google::local_prepend$line" } break } } } # check for !groups if {$incith::google::group_results > 0} { foreach bind [split $incith::google::group_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call groups foreach line [incith::google::parse_output [groups $search]] { put_output $where "$incith::google::group_prepend$line" } break } } } # check for !news if {$incith::google::news_results > 0} { foreach bind [split $incith::google::news_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call news foreach line [incith::google::parse_output [news $search]] { put_output $where "$incith::google::news_prepend$line" } break } } } # check for !print if {$incith::google::print_results > 0} { foreach bind [split $incith::google::print_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call print foreach line [incith::google::parse_output [print $search]] { put_output $where "$incith::google::print_prepend$line" } break } } } # check for !video if {$incith::google::video_results > 0} { foreach bind [split $incith::google::video_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call video foreach line [incith::google::parse_output [video $search]] { put_output $where "$incith::google::video_prepend$line" } break } } } # check for !scholar if {$incith::google::scholar_results > 0} { foreach bind [split $incith::google::scholar_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call video foreach line [incith::google::parse_output [scholar $search]] { put_output $where "$incith::google::scholar_prepend$line" } break } } } # check for !fight if {$incith::google::google_fight > 0} { foreach bind [split $incith::google::fight_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # fight requires splitting of the search regexp -nocase -- {^(.+?) vs (.+?)$} $search - word1 word2 if {![info exists word1] || ![info exists word2]} { put_output $where "Google fights should be the format of 'word(s) one vs word(s) two'" return } # call fight foreach line [incith::google::parse_output [fight $search]] { put_output $where "$incith::google::fight_prepend$line" } break } } } # check for !ebayfight if {$incith::google::google_fight > 0} { foreach bind [split $incith::google::efight_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # fight requires splitting of the search regexp -nocase -- {^(.+?) vs (.+?)$} $search - word1 word2 if {![info exists word1] || ![info exists word2]} { put_output $where "Ebay fights should be the format of 'word(s) one vs word(s) two'" return } # call ebayfight foreach line [incith::google::parse_output [ebayfight $search]] { put_output $where "$incith::google::ebayfight_prepend$line" } break } } } # check for !youtube if {$incith::google::youtube_results > 0} { foreach bind [split $incith::google::youtube_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call youtube foreach line [incith::google::parse_output [youtube $search]] { put_output $where "$incith::google::youtube_prepend$line" } break } } } # check for !helpbot if {$incith::google::helpbot_results > 0} { foreach bind [split $incith::google::helpbot_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call helpbot foreach line [incith::google::parse_output [helpbot $nick $search]] { put_output $where $line } break } } } # check for !myspacevids if {$incith::google::myspacevids_results > 0} { foreach bind [split $incith::google::myspacevids_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call myspacevids foreach line [incith::google::parse_output [myspacevids $search]] { put_output $where "$incith::google::myspacevids_prepend$line" } break } } } # check for !mininova if {$incith::google::mininova_results > 0} { foreach bind [split $incith::google::mininova_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call mininova foreach line [incith::google::parse_output [mininova $search]] { put_output $where "$incith::google::mininova_prepend$line" } break } } } # check for !recent if {$incith::google::recent_results > 0} { foreach bind [split $incith::google::recent_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call recent game lookup foreach line [incith::google::parse_output [recent $search]] { put_output $where "$incith::google::recent_prepend$line" } break } } } # check for !wiki if {$incith::google::wiki_results > 0} { foreach bind [split $incith::google::wiki_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call wiki foreach line [incith::google::parse_output [wiki $search]] { put_output $where "$incith::google::wiki_prepend$line" } break } } } # check for !wikimedia if {$incith::google::wikimedia_results > 0} { foreach bind [split $incith::google::wikimedia_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call wiki foreach line [incith::google::parse_output [wikimedia $search]] { put_output $where "$incith::google::wikimedia_prepend$line" } break } } } # check for !review if {$incith::google::rev_results > 0} { foreach bind [split $incith::google::rev_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call review foreach line [incith::google::parse_output [rev $search]] { put_output $where "$incith::google::rev_prepend$line" } break } } } # check for !ign if {$incith::google::ign_results > 0} { foreach bind [split $incith::google::ign_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call ign foreach line [incith::google::parse_output [ign $search]] { put_output $where "$incith::google::ign_prepend$line" } break } } } # check for !trends if {$incith::google::trends_results > 0} { foreach bind [split $incith::google::trends_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call trends foreach line [incith::google::parse_output [trends $search]] { put_output $where "$incith::google::trends_prepend$line" } break } } } # check for !gamespot if {$incith::google::gamespot_results > 0} { foreach bind [split $incith::google::gamespot_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call gamespot foreach line [incith::google::parse_output [gamespot $search]] { put_output $where "$incith::google::gamespot_prepend$line" } break } } } # check for !trans if {$incith::google::trans_results > 0} { foreach bind [split $incith::google::trans_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # translation requires splitting of the search if {![regexp -nocase -- {^(.+?)@(.+?)\s(.+?)$} $search - word1 word2 word3]} { if {[regexp -nocase -- {^@(.+?)\s(.+?)$} $search - word2 word3]} { set search [join [lrange [split $search] 1 end]] } else { regexp -nocase -- {^(.+?)@\s(.+?)$} $search - word1 word3 } } if {[info exists word2]} { if {[string equal [string index $word2 0] " "]} { regexp -nocase -- {^(.+?)@\s(.+?)$} $search - word1 word3 set word2 $::incith::google::trans } } if {![info exists word1]} { set word1 "auto" } if {![info exists word2]} { set word2 $::incith::google::trans } if {![info exists word3]} { set word3 $search } set search "$word1@$word2 $word3" # call translate trans $search $where } } } # check for !dailymotion if {$incith::google::daily_results > 0} { foreach bind [split $incith::google::daily_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call dailymotion foreach line [incith::google::parse_output [dailymotion $search]] { put_output $where "$incith::google::dailymotion_prepend$line" } break } } } # check for !gamefaqs if {$incith::google::gamefaq_results > 0} { foreach bind [split $incith::google::gamefaq_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # gamefaqs requires splitting of the search regexp -nocase -- {^(.+?) in (.+?)$} $search - system region if {![info exists system] || ![info exists region]} { put_output $where "Error! Correct usage: !gamefaqs system in region \[system = nds/gba/gc/wii/ps2/psp/ps3/xbox/x360/pc; region = usa/jap/eur/aus\]" return } # call gamefaqs foreach line [incith::google::parse_output [gamefaqs $system $region]] { put_output $where "$incith::google::gamefaqs_prepend$line" } break } } } # check for !locate if {$incith::google::locate_results > 0} { foreach bind [split $incith::google::locate_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call locate if {![string match "*.*" $search]} { set nsearch [lindex [split [getchanhost $search $where] @] 1] if {[string length $nsearch]} { set search $nsearch } } foreach line [incith::google::parse_output [locate $search]] { put_output $where "$incith::google::locate_prepend$line" } break } } } # check for !blog if {$incith::google::blog_results > 0} { foreach bind [split $incith::google::blog_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call blogsearch.google foreach line [incith::google::parse_output [blog $search]] { put_output $where "$incith::google::blog_prepend$line" } break } } } # check for !ebay if {$incith::google::ebay_results > 0} { foreach bind [split $incith::google::ebay_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call ebay foreach line [incith::google::parse_output [ebay $search]] { put_output $where "$incith::google::ebay_prepend$line" } break } } } # check for !popular if {$incith::google::popular_results > 0} { foreach bind [split $incith::google::popular_binds " "] { if {[string match -nocase $bind $trigger] == 1} { # flood protection check if {[flood $nick $uhand]} { return } # call popular foreach line [incith::google::parse_output [popular $search]] { put_output $where "$incith::google::popular_prepend$line" } break } } } # check for customized any triggers if {$incith::google::my_custom > 0} { foreach bind $incith::google::my_customs { foreach sbind [split [lindex [split $bind :] 0]] { if {[string match -nocase $sbind $trigger] == 1} { # invoke customized trigger with phrase # no need to flood protect this, if we do # it may trigger erroneously set text [join [lrange [split $bind :] 2 end] :] if {$::incith::google::custom_words > 0} { set remaps [regexp -inline -all {%%((?:end|[0-9]{1,2}|[0-9]{1,2}-(?:[0-9]{1,2}|end)))%%} $text] foreach {junk remap} $remaps { if {[regexp -nocase {^((?:end|[0-9]{1,2}))$} $remap - rnum]} { if {[string equal -nocase "end" $rnum]} { set real [llength [split $search]] } else { set real [expr {$remap -1}] } regsub -all "$junk" $text "[lindex [split $search] $real]" text } elseif {[regexp -nocase {^([0-9]{1,2})-((?:[0-9]{1,2}|end))$} $remap - rstart rend]} { if {![string equal -nocase "end" $rend]} { set real [expr {$rend -1}] } else { set real [llength [split $search]] } regsub -all "$junk" $text "[join [lrange [split $search] [expr {${rstart}-1}] $real]]" text } } } regsub -all -- {%search%} $text "$search" text send_output "$::incith::google::command_char[lindex [split $bind :] 1] $text" $where $nick $uhand } } } } } # PUT_OUTPUT # actually sends the output to the server proc put_output {where line} { if {$incith::google::notice_reply == 1} { putserv "NOTICE $where :$line" } else { putserv "PRIVMSG $where :$line" } } # PARSE_OUTPUT # prepares output for sending to a channel/user, calls line_wrap # proc parse_output {input} { set parsed_output [list] ; set parsed_current [list] if {[string match "*\n*" $incith::google::seperator] == 1} { set lastline "" foreach newline [split $input "\n"] { foreach line [incith::google::line_wrap $newline] { set fix "" # bold if {[expr {[regexp -all {\002} $lastline] & 1 }]} { append fix "\002" } # underline if {[expr {[regexp -all {\037} $lastline] & 1 }]} { append fix "\037" } # color if {[expr {[regexp -all {\003} $lastline] & 1 }]} { if {[set i [string last "\003" $lastline]] != -1} { set lc [string range $lastline [expr {$i + 1}] [expr {$i + 5}]] if {![regexp {^[0-9]+\,[0-9+]$} $lc]} { if {[regexp {^[0-9]+$} [string range $lc 0 1]]} { append fix "\003[string range $lc 0 1]" } } else { append fix "\003$lc" } } } # add fix+line to output if {[string length [string map {" " ""} [stripcodes bcruag $line]]]} { lappend parsed_output "$fix$line" } set lastline "$fix$line" } } } else { set input [string trimright $input $incith::google::seperator] set lastline "" foreach line [incith::google::line_wrap $input] { # initialize fix each iteration set fix "" # add bold if {[expr {[regexp -all {\002} $lastline] & 1 }]} { append fix "\002" } # add underline if {[expr {[regexp -all {\037} $lastline] & 1 }]} { append fix "\037" } # add color if {[expr {[regexp -all {\003} $lastline] & 1 }]} { if {[set i [string last "\003" $lastline]] != -1} { set lc [string range $lastline [expr {$i + 1}] [expr {$i + 5}]] if {![regexp {^[0-9]{1,2}\,[0-9]{1,2}$} $lc]} { if {[regexp {^[0-9]{1,2}} [string range $lc 0 1]]} { append fix "\003[string range $lc 0 1]" } } else { append fix "\003$lc" } } } # add fix+line to output if {[string length [string map {" " ""} [stripcodes bcruag $line]]]} { lappend parsed_output "$fix$line" } set lastline "$fix$line" } } return $parsed_output } # LINE_WRAP # takes a long line in, and chops it before the specified length # http://forum.egghelp.org/viewtopic.php?t=6690 # proc line_wrap {str {splitChr { }}} { set out [set cur {}] set i 0 set len $incith::google::split_length #regsub -all "\002" $str "<ZQ" str #regsub -all "\037" $str "<ZX" str #regsub -all "\003" $str "<ZJ" str foreach word [split [set str][set str ""] $splitChr] { if {[incr i [string len $word]] > $len} { #regsub -all "<ZQ" $cur "\002" cur #regsub -all "<ZX" $cur "\037" cur #regsub -all "<ZJ" $cur "\003" cur lappend out [join $cur $splitChr] set cur [list $word] set i [string len $word] } else { lappend cur $word } incr i } #regsub -all "<ZQ" $cur "\002" cur #regsub -all "<ZX" $cur "\037" cur #regsub -all "<ZJ" $cur "\003" cur lappend out [join $cur $splitChr] } # FLOOD_INIT # modified from bseen # variable flood_data variable flood_array proc flood_init {} { if {$incith::google::ignore < 1} { return 0 } if {![string match *:* $incith::google::flood]} { putlog "$incith::google::version: variable flood not set correctly." return 1 } set incith::google::flood_data(flood_num) [lindex [split $incith::google::flood :] 0] set incith::google::flood_data(flood_time) [lindex [split $incith::google::flood :] 1] set i [expr $incith::google::flood_data(flood_num) - 1] while {$i >= 0} { set incith::google::flood_array($i) 0 incr i -1 } } ; flood_init # FLOOD # updates and returns a users flood status # proc flood {nick uhand} { if {$incith::google::ignore < 1} { return 0 } if {$incith::google::flood_data(flood_num) == 0} { return 0 } set i [expr ${incith::google::flood_data(flood_num)} - 1] while {$i >= 1} { set incith::google::flood_array($i) $incith::google::flood_array([expr $i - 1]) incr i -1 } set incith::google::flood_array(0) [unixtime] if {[expr [unixtime] - $incith::google::flood_array([expr ${incith::google::flood_data(flood_num)} - 1])] <= ${incith::google::flood_data(flood_time)}} { putlog "$incith::google::version: flood detected from ${nick}." putserv "notice $nick :$incith::google::version: flood detected, placing you on ignore for $::incith::google::ignore minute(s)! :P" newignore [join [maskhost *!*[string trimleft $uhand ~]]] $incith::google::version flooding $incith::google::ignore return 1 } else { return 0 } } # AUTOMAGIC CHARSET ENCODING SUPPORT # on the fly encoding support # proc incithdecode {text} { global incithcharset if {[lsearch -exact [encoding names] $incithcharset] != -1} { set text [encoding convertfrom $incithcharset $text] } return $text } proc incithencode {text} { global incithcharset if {[lsearch -exact [encoding names] $incithcharset] != -1} { set text [encoding convertto $incithcharset $text] } return $text } # utf-8 sucks for displaying any language using extended ascii, this helps alleviate that. # correct utf-8 problems before they even appear. proc utf8encodefix {country input} { if {[lsearch -exact [encoding names] [set encoding_found [lindex [split [lindex $incith::google::encode_strings [lsearch -glob $incith::google::encode_strings "${country}:*"]] :] 1]]]} { if {![string match "" $encoding_found]} { set input [encoding convertto $encoding_found $input] } } return $input } # Wikipedia/Wikimedia subtag-decoder... # decodes those silly subtags # proc subtagDecode {text} { set url "" regsub -all {\.([0-9a-fA-F][0-9a-fA-F])} $text {[format %c 0x\1]} text set text [subst $text] regsub -all "\r\n" $text "\n" text foreach byte [split [encoding convertto "utf-8" $text] ""] { scan $byte %c i if { $i < 33 } { append url [format %%%02X $i] } else { append url $byte } } return [string map {% .} $url] } # Vocabulary Aversion # This converts swear words into appropriate words for IRC # this is rather rudementary, is probably a better way to do this but meh.. # proc vocabaversion {text} { set newtext "" foreach element [split $text] { set violation 0 foreach vocabulary $incith::google::aversion { set swear [lindex [split $vocabulary :] 0] set avert [join [lrange [split $vocabulary :] 1 end]] if {[string match -nocase "$swear" $element] && $avert != ""} { append newtext "$avert " set violation 1 break } } if {$violation == 0} { append newtext "$element " } } return [string trim $newtext] } # Description Decode # convert html codes into characters - credit perplexa (urban dictionary) # proc descdecode {text} { # code below is neccessary to prevent numerous html markups # from appearing in the output (ie, ", ᘧ, etc) # stolen (borrowed is a better term) from perplexa's urban # dictionary script.. if {[string match *&* $text]} { global incithcharset set escapes {   \xa0 ¡ \xa1 ¢ \xa2 £ \xa3 ¤ \xa4 ¥ \xa5 ¦ \xa6 § \xa7 ¨ \xa8 © \xa9 ª \xaa « \xab ¬ \xac ­ \xad ® \xae ¯ \xaf ° \xb0 ± \xb1 ² \xb2 ³ \xb3 ´ \xb4 µ \xb5 ¶ \xb6 · \xb7 ¸ \xb8 ¹ \xb9 º \xba » \xbb ¼ \xbc ½ \xbd ¾ \xbe ¿ \xbf À \xc0 Á \xc1  \xc2 à \xc3 Ä \xc4 Å \xc5 Æ \xc6 Ç \xc7 È \xc8 É \xc9 Ê \xca Ë \xcb Ì \xcc Í \xcd Î \xce Ï \xcf Ð \xd0 Ñ \xd1 Ò \xd2 Ó \xd3 Ô \xd4 Õ \xd5 Ö \xd6 × \xd7 Ø \xd8 Ù \xd9 Ú \xda Û \xdb Ü \xdc Ý \xdd Þ \xde ß \xdf à \xe0 á \xe1 â \xe2 ã \xe3 ä \xe4 å \xe5 æ \xe6 ç \xe7 è \xe8 é \xe9 ê \xea ë \xeb ì \xec í \xed î \xee ï \xef ð \xf0 ñ \xf1 ò \xf2 ó \xf3 ô \xf4 õ \xf5 ö \xf6 ÷ \xf7 ø \xf8 ù \xf9 ú \xfa û \xfb ü \xfc ý \xfd þ \xfe ÿ \xff ƒ \u192 Α \u391 Β \u392 Γ \u393 Δ \u394 Ε \u395 Ζ \u396 Η \u397 Θ \u398 Ι \u399 Κ \u39A Λ \u39B Μ \u39C Ν \u39D Ξ \u39E Ο \u39F Π \u3A0 Ρ \u3A1 Σ \u3A3 Τ \u3A4 Υ \u3A5 Φ \u3A6 Χ \u3A7 Ψ \u3A8 Ω \u3A9 α \u3B1 β \u3B2 γ \u3B3 δ \u3B4 ε \u3B5 ζ \u3B6 η \u3B7 θ \u3B8 ι \u3B9 κ \u3BA λ \u3BB μ \u3BC ν \u3BD ξ \u3BE ο \u3BF π \u3C0 ρ \u3C1 ς \u3C2 σ \u3C3 τ \u3C4 υ \u3C5 φ \u3C6 χ \u3C7 ψ \u3C8 ω \u3C9 ϑ \u3D1 ϒ \u3D2 ϖ \u3D6 • \u2022 … \u2026 ′ \u2032 ″ \u2033 ‾ \u203E ⁄ \u2044 ℘ \u2118 ℑ \u2111 ℜ \u211C ™ \u2122 ℵ \u2135 ← \u2190 ↑ \u2191 → \u2192 ↓ \u2193 ↔ \u2194 ↵ \u21B5 ⇐ \u21D0 ⇑ \u21D1 ⇒ \u21D2 ⇓ \u21D3 ⇔ \u21D4 ∀ \u2200 ∂ \u2202 ∃ \u2203 ∅ \u2205 ∇ \u2207 ∈ \u2208 ∉ \u2209 ∋ \u220B ∏ \u220F ∑ \u2211 − \u2212 ∗ \u2217 √ \u221A ∝ \u221D ∞ \u221E ∠ \u2220 ∧ \u2227 ∨ \u2228 ∩ \u2229 ∪ \u222A ∫ \u222B ∴ \u2234 ∼ \u223C ≅ \u2245 ≈ \u2248 ≠ \u2260 ≡ \u2261 ≤ \u2264 ≥ \u2265 ⊂ \u2282 ⊃ \u2283 ⊄ \u2284 ⊆ \u2286 ⊇ \u2287 ⊕ \u2295 ⊗ \u2297 ⊥ \u22A5 ⋅ \u22C5 ⌈ \u2308 ⌉ \u2309 ⌊ \u230A ⌋ \u230B ⟨ \u2329 ⟩ \u232A ◊ \u25CA ♠ \u2660 ♣ \u2663 ♥ \u2665 ♦ \u2666 " \x22 & \x26 < \x3C > \x3E O&Elig; \u152 œ \u153 Š \u160 š \u161 Ÿ \u178 ˆ \u2C6 ˜ \u2DC   \u2002   \u2003   \u2009 ‌ \u200C ‍ \u200D ‎ \u200E ‏ \u200F – \u2013 — \u2014 ‘ \u2018 ’ \u2019 ‚ \u201A “ \u201C ” \u201D „ \u201E † \u2020 ‡ \u2021 ‰ \u2030 ‹ \u2039 › \u203A € \u20AC ' \u0027 ‎ "" ‏ "" ‬ "" ‭ "" ‮ "" — \u2014 } set text [string map $escapes $text] # enable transcoding html elements? if {$::incith::google::dirty_decode > 0} { if {![string equal $incithcharset [encoding system]]} { set text [encoding convertfrom $incithcharset $text] } set text [string map [list "\]" "\\\]" "\[" "\\\[" "\$" "\\\$" "\\" "\\\\"] $text] regsub -all -- {&#([[:digit:]]{1,5});} $text {[format %c [string trimleft "\1" "0"]]} text regsub -all -- {&#x([[:xdigit:]]{1,4});} $text {[format %c [scan "\1" %x]]} text regsub -all -- {\\x([[:xdigit:]]{1,2})} $text {[format %c [scan "\1" %x]]} text set text [subst "$text"] if {![string equal $incithcharset [encoding system]]} { set text [encoding convertto $incithcharset $text] } } } # correct possible bleedover of bold or underline set fix "" ; if {[expr {[regexp -all {\002} $text] & 1 }]} { append fix "\002" } if {[expr {[regexp -all {\037} $text] & 1 }]} { append fix "\037" } set text "$text$fix" return $text } # URL Decode # Decodes all of the %00 strings in a url and returns it # proc urldecode {text} { set url "" # tcl filter required because we are using SUBST command below # this will escape any sequence which could potentially trigger # the interpreter.. regsub -all -- \\\\ $text \\\\\\\\ text regsub -all -- \\\[ $text \\\\\[ text regsub -all -- \\\] $text \\\\\] text regsub -all -- \\\} $text \\\\\} text regsub -all -- \\\{ $text \\\\\{ text regsub -all -- \\\" $text \\\\\" text regsub -all -- \\\$ $text \\\\\$ text # end tcl filter regsub -all {\%([0-9a-fA-F][0-9a-fA-F])} $text {[format %c 0x\1]} text set text [subst $text] foreach byte [split $text ""] { scan $byte %c i if { $i < 33 || $i > 127 } { append url [format %%%02X $i] } else { append url $byte } } return $url } # Un Gzip # Unzips those silly g-zipped wikis # proc ungzip {html metas} { if {$::incith::google::use_gzip > 0} { if {![info exists ::incith_nozlib]} { foreach {name value} $metas { if {[regexp -nocase ^Content-Encoding$ $name]} { if {[string equal -nocase "gzip" $value]} { if {![info exists ::incith_trf]} { if {[catch {set html [zlib inflate [string range $html 10 [expr { [string length $html] - 8 } ]]]} error]} { return $html } } else { set html [zip -mode decompress -nowrap 1 [string range $html 10 [expr { [string length $html] - 8 } ]]] } break } } } } } return $html } # URL Encode # Encodes anything not a-zA-Z0-9 into %00 strings... # proc urlencode {text type {enc ""}} { if {[string length $enc]} { set text [encoding convertto $enc $text] } set url "" foreach byte [split $text ""] { scan $byte %c i if {$i < 65 || $i > 122} { append url [format %%%02X $i] } else { append url $byte } } if {$type == 1} { return [string map {%25 . %3A : %2D - %2F / %2E . %30 0 %31 1 %32 2 %33 3 %34 4 %35 5 %36 6 %37 7 %38 8 %39 9 %80 _ % .} $url] } else { return [string map {%2D - %30 0 %31 1 %32 2 %33 3 %34 4 %35 5 %36 6 %37 7 %38 8 %39 9 \[ %5B \\ %5C \] %5D \^ %5E \_ %5F \` %60} $url] } } } } putlog " - UNOFFICIAL $incith::google::version loaded." # EOF