Advertisement
paintbalbot

link lookup [twitch chat bot tutorial]

Jun 13th, 2014
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. on *:text:*:#: {
  2. if (http:// isin $1-) {
  3. sockclose linkchecker
  4. set %link $remove($matchtok($1-,http://,1,32),http://)
  5. set %linkchan $chan
  6. set %actlink $nick $+ 's link
  7. if (/ !isin %link) { set %link %link $+ / }
  8. sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
  9. halt
  10. }
  11. elseif (www. isin $1-) {
  12. sockclose linkchecker
  13. set %link $matchtok($1-,www.,1,32)
  14. set %linkchan $chan
  15. set %actlink $nick $+ 's link
  16. if (/ !isin %link) { set %link %link $+ / }
  17. sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
  18. halt
  19. }
  20. elseif (.com isin $1-) {
  21. sockclose linkchecker
  22. set %link $matchtok($1-,.com,1,32)
  23. set %linkchan $chan
  24. set %actlink $nick $+ 's link
  25. if (/ !isin %link) { set %link %link $+ / }
  26. sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
  27. halt
  28. }
  29. elseif (.tv isin $1-) {
  30. sockclose linkchecker
  31. set %link $matchtok($1-,.tv,1,32)
  32. set %linkchan $chan
  33. set %actlink $nick $+ 's link
  34. if (/ !isin %link) { set %link %link $+ / }
  35. sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
  36. halt
  37. }
  38. elseif (https:// isin $1-) {
  39. sockclose linkchecker
  40. set %link $matchtok($1-,https://,1,32)
  41. set %linkchan $chan
  42. set %actlink $nick $+ 's link
  43. if (/ !isin %link) { set %link %link $+ / }
  44. sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
  45. halt
  46. }
  47. elseif (.ca isin $1-) {
  48. sockclose linkchecker
  49. set %link $matchtok($1-,.ca,1,32)
  50. set %linkchan $chan
  51. set %actlink $nick $+ 's link
  52. if (/ !isin %link) { set %link %link $+ / }
  53. sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
  54. halt
  55. }
  56. elseif (.org isin $1-) {
  57. sockclose linkchecker
  58. set %link $matchtok($1-,.org,1,32)
  59. set %linkchan $chan
  60. set %actlink $nick $+ 's link
  61. if (/ !isin %link) { set %link %link $+ / }
  62. sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
  63. halt
  64. }
  65. elseif (.net isin $1-) {
  66. sockclose linkchecker
  67. set %link $matchtok($1-,.net,1,32)
  68. set %linkchan $chan
  69. set %actlink $nick $+ 's link
  70. if (/ !isin %link) { set %link %link $+ / }
  71. sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
  72. halt
  73. }
  74. elseif (.int isin $1-) {
  75. sockclose linkchecker
  76. set %link $matchtok($1-,.int,1,32)
  77. set %linkchan $chan
  78. set %actlink $nick $+ 's link
  79. if (/ !isin %link) { set %link %link $+ / }
  80. sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
  81. halt
  82. }
  83. elseif (.edu isin $1-) {
  84. sockclose linkchecker
  85. set %link $matchtok($1-,.edu,1,32)
  86. set %linkchan $chan
  87. set %actlink $nick $+ 's link
  88. if (/ !isin %link) { set %link %link $+ / }
  89. sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
  90. halt
  91. }
  92. elseif (.gov isin $1-) {
  93. sockclose linkchecker
  94. set %link $matchtok($1-,.gov,1,32)
  95. set %linkchan $chan
  96. set %actlink $nick $+ 's link
  97. if (/ !isin %link) { set %link %link $+ / }
  98. sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
  99. halt
  100. }
  101. elseif (.mil isin $1-) {
  102. sockclose linkchecker
  103. set %link $matchtok($1-,.mil,1,32)
  104. set %linkchan $chan
  105. set %actlink $nick $+ 's link
  106. if (/ !isin %link) { set %link %link $+ / }
  107. sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
  108. halt
  109. }
  110. }
  111. }
  112. on *:sockopen:linkchecker: {
  113. if $sockerr > 0 { sockclose $sockname | halt }
  114. sockwrite -n $sockname GET / $+ $right(%link,$calc($len(%link)- $pos(%link,/,1))) HTTP/1.1
  115. sockwrite -n $sockname Host: $remove($left(%link,$pos(%link,/,1)),/)
  116. sockwrite -n $sockname $crlf
  117. }
  118. on *:sockread:linkchecker: {
  119. if $sockerr > 0 { sockclose $sockname | halt }
  120. sockread %linkh
  121. if (%delbug != $null) && ($len(%linkch) <= 150) && (</title> !isin %linkh) { set %linkch %linkch %linkh }
  122. if (%delbug != $null) && (</title> isin %linkh) {
  123. msg $chan %linkchan $replace(%linkch,&quot;,",&apos;,',&amp;,&,&lt;,<,&gt;,>,&copy;,©,&reg;,®,&trade;,™,&euro;,€,&pound;,£,&yen;,¥) ( %actlink )
  124. unset %delbug
  125. sockclose $sockname
  126. halt
  127. }
  128. if (<title> isin %linkh) {
  129. set %linkch $remove($left(%linkh,$pos(%linkh,</title>,1)),</title>)
  130. set %linkch $right(%linkch,$calc($len(%linkch)- $pos(%linkch,<title>,1) -6))
  131. set %linkch $left(%linkch,$calc($len(%linkch)-1))
  132. set %delbug 1
  133. if (%linkch != $null) {
  134. msg $chan %linkchan $replace(%linkch,&quot;,",&apos;,',&amp;,&,&lt;,<,&gt;,>,&copy;,©,&reg;,®,&trade;,™,&euro;,€,&pound;,£,&yen;,¥) ( %actlink )
  135. sockclose $sockname
  136. unset %delbug
  137. halt
  138. }
  139. }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement