Posted to tcl by Surmaelk at Tue Feb 18 21:24:44 GMT 2020view raw

  1. ErrorCode:
  2. Tcl error [m00nie::movie::search]: invalid bareword "lt"
  3. in expression " $i < 5 ";
  4. should be "$lt" or "{lt}" or "lt(...)" or ...
  5.  
  6. From:
  7. proc getinfo { url } {
  8. for { set i 1 } { $i <= 5 } { incr i } { set rawpage [::http::data [::http::geturl "$url" -timeout 5000]] if {[string length rawpage] > 0} { break }
  9. }
  10. #########################################################################################
  11. # Name m00nie::movie
  12. # Description Uses omdbapi to grab info about a film title then spam it into the chan
  13. #
  14. # Version 1.0 - Initial release
  15. # Website https://www.m00nie.com
  16. # Notes Create ypu own API keys here: http://www.omdbapi.com
  17. # requires .chanset #chan +movie
  18. #########################################################################################
  19. namespace eval m00nie {
  20. namespace eval movie {
  21. package require json
  22. bind pub - !movie m00nie::movie::search
  23. # Uncomment bind below to also use "more traditional" !imdb search
  24. bind pub - !imdb m00nie::movie::search
  25. variable version "1.0"
  26. setudef flag movie
  27. # Setup your own app and keys at the URL above
  28. variable key "XXXX"
  29.  
  30. proc search {nick uhost hand chan text} {
  31. if {[channel get $chan movie]} {
  32. putlog "m00nie::movie::search is running"
  33. regsub -all {\s+} $text "%20" text
  34. set response [getinfo "http://www.omdbapi.com/?t=$text&apikey=$m00nie::movie::key"]
  35. #set response [dict get [json::json2dict $response]]
  36. foreach var { Title Year Rated Released Runtime Genre Actors Plot Metascore imdbRating imdbID } {
  37. set $var [dict get $response $var]
  38. }
  39. set imdburl "http://www.imdb.com/title/$imdbID/"
  40. puthelp "PRIVMSG $chan :\002$Title ($Year)\002 $Rated \002|\002 $Runtime \002|\002 $Genre \002|\002 $Released"
  41. puthelp "PRIVMSG $chan :\002Cast:\002 $Actors"
  42. puthelp "PRIVMSG $chan :\002Plot:\002 $Plot"
  43. puthelp "PRIVMSG $chan :\002Metascore:\002 $Metascore, \002IMDB Rating:\002 $imdbRating"
  44. puthelp "PRIVMSG $chan :$imdburl"
  45. }
  46. }
  47.  
  48. proc getinfo { url } {
  49. for { set i 1 } { $i < 5 } { incr i } { set rawpage [::http::data [::http::geturl "$url" -timeout 5000]] if {[string length rawpage] > 0} { break }
  50. }
  51. putlog "m00nie::movie::getinfo Rawpage length is: [string length $rawpage]"
  52. if {[string length $rawpage] == 0} { error "omdbapi returned ZERO no data :( or we couldnt connect properly" }
  53. set ids [dict get [json::json2dict $rawpage]]
  54. putlog "m00nie::movie::getinfo IDS are $ids"
  55. return $ids
  56.  
  57. }
  58. }
  59. }
  60. putlog "m00nie::movie $m00nie::movie::version loaded"