-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetLinkInfo.mrc
189 lines (182 loc) · 10.8 KB
/
GetLinkInfo.mrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
;Original GetLinkInfo Script by Ford_Lawnmower (irc.GeekShed.net #Script-Help)
;Modified by Moodkiller (irc.xertion.org #MK) to work with a better service
;Version 2.3 16/07/2023
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Start Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Change this to 0 to resolve youtube links
alias -l IgnoreYoutubeLinks return 1
;Change this to change the logo
alias -l GetLinkInfoLogo return $+($chr(3),12,🌎)
;Change this to change the text color
alias -l GetLinkInfoTextColor return $+($chr(15),$chr(2))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;End Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
menu Channel,Status {
.$iif($group(#GetLinkInfo) == On,$style(1)) GetLinkInfo
..$iif($group(#GetLinkInfo) == On,$style(2)) On: .enable #GetLinkInfo
..$iif($group(#GetLinkInfo) == Off,$style(2)) Off: .disable #GetLinkInfo
}
#GetLinkInfo on
On $*:Text:/(^[+-]LinkInfo|(https?|www\.)(www\.)?[\S]*)/Si:#: {
;if ($chan == #kai) && (Aerith ison $chan) { halt }
if (Serv isin $right($nick,4)) || ($nick == Aerith) || ($nick == NukuServ|Archive) { halt }
;echo
var %action $strip($regml(1))
;echo %action
if ($regex(action,%action,^[+-])) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/)) || ($regex(action,%action,^[+-])) && ($nick == Moodkiller) {
if (+* iswm %action) {
if ($istok(%linkinfoChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the script }
else {
.enable #GetLinkInfo
Set %linkinfoChanList $addtok(%linkinfoChanList,$+($network,$chan),32)
.msg $chan $nick has activated the linkinfo script for $chan
}
}
else {
if (!$istok(%linkinfoChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the linkinfo script }
else {
Set %linkinfoChanList $remtok(%linkinfoChanList,$+($network,$chan),1,32)
.msg $chan $nick has deactivated the linkinfo script for $chan
}
}
}
elseif (!$timer($+(linkinfo,$network,$chan))) && ($istok(%linkinfoChanList,$+($network,$chan),32)) {
.timer $+ $+(linkinfo,$network,$chan) 1 1 noop
var %method msg #
;if ($IgnoreYoutubeLinks && $regex(%action,/(?:^https?:\/\/|www\.)(?:[\S]*youtube\.com|youtu\.be)/i)) {
if ($IgnoreYoutubeLinks && $regex(%action,/(?:^https?:\/\/|www\.)(?:[\S]*youtube\.com|youtu\.be)/i)) {
return
}
else {
;Getlinkinfo %method $gettok(%action,2-,47)
Getlinkinfo %method %action
;echo
;echo output of gettok:
;echo %action
}
}
}
#GetLinkInfo end
alias linkinfo { Getlinkinfo echo -a $1- }
alias -l Getlinkinfo {
var %sockname $+(LinkInfo,$network,$2,$ticks)
;sockopen -en4 %sockname animk.info +443
sockclose %sockname
sockopen %sockname animk.info 80
svar %sockname method $1-2
;svar %sockname url $+(/lib/getlinkinfo.php?url=,$urlencode($+(https://,$3)))
svar %sockname url $+(/lib/getlinkinfo-v2.php?url=,$urlencode($+($3)))
;echo Output of what is sent to animk.info:
;echo %sockname url $+(/lib/getlinkinfo.php?url=,$urlencode($+($3)))
}
On *:sockopen:LinkInfo*: {
if (!$sockerr) {
sockwrite -nt $sockname GET $svar($sockname,url) HTTP/1.1
;echo $sockname GET $svar($sockname,url) HTTP/1.1
sockwrite -n $sockname Host: $sock($sockname).addr
;echo $sockname Host: $sock($sockname).addr
sockwrite -n $sockname $crlf
}
else { echo -st Socket Error The First $nopath($script) | sockclose $sockname | return }
}
On *:sockread:LinkInfo*: {
if ($sockerr) { echo -st Socket Error The Second $nopath($script) | sockclose $sockname | return }
else {
var %LinkInfo | sockread %LinkInfo
;Uncomment to display returned webpage of website title
;echo %LinkInfo
if ($regex(%LinkInfo,/<linkinfo>(.*?)<\/linkinfo>/i)) {
;This works for russian and pretty much everything using mIRC built in utfencode and decode scripts.
$svar($sockname,method) $GetLinkInfoLogo $+($GetLinkInfoTextColor,$utfdecode($utfencode($regml(1), 204)))
$secho $bracket($time) $bracket($script) [URL Title]: $regml(1)
; Below works for the most part except with Russian
;$svar($sockname,method) $GetLinkInfoLogo $+($GetLinkInfoTextColor,$regml(1))
;Testing output and trigger
;echo LinkInfo variable: %LinkInfo
;echo I found something
sockclose $sockname
return
}
}
}
alias Xchr {
var %return $regsubex($regsubex($1-,/&#x([A-F0-9]{1,2});/g,$chr($base($regml(\n),16,10))),/&#([0-9]{2,4});/g,$utf8(\1))
return $xXchr($replacecs(%return,–,$utf8(8211),—,$utf8(8212),¡,$utf8(161),·,·,»,»,«,«,Ü,Ü,$&
ü,ü,Á,Á,á,á,É,É,¿,$utf8(191),“,$utf8(8220),”,$utf8(8221),',',$&
‘,$utf8(8216),’,$utf8(8217),¢,$utf8(162),©,$utf8(169),÷,$utf8(247),µ,$utf8(181),$&
¶,$utf8(182),±,±,€,$utf8(8364),£,£,®,$utf8(174),§,$utf8(167),™,$utf8(153),$&
¥,$utf8(165),¤,$utf8(164),¦,$utf8(166),§,$utf8(167),¨,$utf8(168),ª,$utf8(170),$&
¬,$utf8(172),­,$utf8(173),¯,$utf8(175),°,$utf8(176),²,$utf8(178),³,$utf8(179),$&
´,´,ç,$utf8(184),¹,$utf8(185),º,$utf8(186),¼,$utf8(188),½,$utf8(189),$&
¾,$utf8(190),À,$utf8(192),Â,$utf8(194),Ã,$utf8(195),Ä,$utf8(196),Å,$utf8(197),$&
Æ,$utf8(198),Ç,$utf8(199),È,$utf8(200),Ê,$utf8(202),Ë,$utf8(203),Ì,$utf8(204),Î,$utf8(206),$&
Ï,$utf8(207),Ð,$utf8(208),Ò,$utf8(210),Ô,$utf8(212),Õ,$utf8(213),Ö,$utf8(214),×,$utf8(215),$&
Ø,$utf8(216),Ù,$utf8(217),Û,$utf8(219),Ý,$utf8(221),Þ,$utf8(222),ß,$utf8(223),à,$utf8(224),$&
â,$utf8(226),ã,$utf8(227),ä,$utf8(228),å,$utf8(229),ç,$utf8(231),è,$utf8(232),ê,$utf8(234),ë,$utf8(235),$&
ì,$utf8(236),î,$utf8(238),ï,$utf8(239),ð,$utf8(240),ò,$utf8(242),ô,$utf8(244),õ,$utf8(245),ö,$utf8(246),$&
÷,$utf8(247),ø,$utf8(248),ù,$utf8(249),û,$utf8(251),ý,$utf8(253),þ,$utf8(254),ÿ,$utf8(255),∠,$utf8(8736),$&
∧,$utf8(8743),ƒ,$utf8(402),Α,$utf8(913),Β,$utf8(914),Γ,$utf8(915),Δ,$utf8(916),Ε,$utf8(917),Ζ,$utf8(918),$&
Η,$utf8(919),Θ,$utf8(920),Ι,$utf8(921),Κ,$utf8(922),Λ,$utf8(923),Μ,$utf8(924),Ν,$utf8(925),Ξ,$utf8(926),$&
Ο,$utf8(927),Π,$utf8(928),Ρ,$utf8(929),Σ,$utf8(931),Τ,$utf8(932),Υ,$utf8(933),Φ,$utf8(934),Χ,$utf8(935),$&
Ψ,$utf8(936),Ω,$utf8(937),α,$utf8(945),β,$utf8(946),γ,$utf8(947),δ,$utf8(948),ε,$utf8(949),ζ,$utf8(950)))
}
alias -l xXchr {
return $replacecs($1-,η,$utf8(951),θ,$utf8(952),ι,$utf8(953),κ,$utf8(954),λ,$utf8(955),μ,$utf8(956),$&
ν,$utf8(957),ξ,$utf8(958),ο,$utf8(959),π,$utf8(960),ρ,$utf8(961),ς,$utf8(962),$&
σ,$utf8(963),τ,$utf8(964),υ,$utf8(965),φ,$utf8(966),χ,$utf8(967),ψ,$utf8(968),$&
ω,$utf8(969),ϑ,$utf8(977),ϒ,$utf8(978),ϖ,$utf8(982),•,$utf8(8226),…,$utf8(8230),$&
′,$utf8(8242),″,$utf8(8243),‾,$utf8(8254),⁄,$utf8(8260),℘,$utf8(8472),$&
ℑ,$utf8(8465),ℜ,$utf8(8476),™,$utf8(8482),ℵ,$utf8(8501),←,$utf8(8592),$&
↑,$utf8(8593),→,$utf8(8594),↓,$utf8(8595),↔,$utf8(8596),↵,$utf8(8629),⇐,$utf8(8656),$&
⇑,$utf8(8657),⇒,$utf8(8658),⇓,$utf8(8659),⇔,$utf8(8660),∀,$utf8(8704),∂,$utf8(8706),$&
∃,$utf8(8707),∅,$utf8(8709),∇,$utf8(8711),∈,$utf8(8712),∉,$utf8(8713),∋,$utf8(8715),$&
∏,$utf8(8719),∑,$utf8(8721),−,$utf8(8722),∗,$utf8(8727),√,$utf8(8730),∝,$utf8(8733),$&
∞,$utf8(8734),∨,$utf8(8744),∩,$utf8(8745),∪,$utf8(8746),∫,$utf8(8747),∴,$utf8(8756),$&
∼,$utf8(8764),≅,$utf8(8773),≈,$utf8(8776),≠,$utf8(8800),≡,$utf8(8801),≤,$utf8(8804),$&
≥,$utf8(8805),⊂,$utf8(8834),⊃,$utf8(8835),⊄,$utf8(8836),⊆,$utf8(8838),⊇,$utf8(8839),$&
⊕,$utf8(8853),⊗,$utf8(8855),⊥,$utf8(8869),⋅,$utf8(8901),⌈,$utf8(8968),⌉,$utf8(8969),$&
⌊,$utf8(8970),⌋,$utf8(8971),⟨,$utf8(9001),⟩,$utf8(9002),◊,$utf8(9674),♠,$utf8(9824),$&
♣,$utf8(9827),♥,$utf8(9829),♦,$utf8(9830),é,é,Í,Í,í,í,Ó,Ó,ó,ó,$&
Ñ,Ñ,ñ,ñ,Ú,Ú,ú,ú, ,$chr(32),æ,æ,",",<,<,>,>, &,&,",")
}
; Below encodes URL going TO the server
alias -l urlencode {
;return $regsubex($replace($1-,$chr(32),$+(%,2d),$+(%,20),$+(%,2d)),/([^a-z0-9])/ig,% $+ $base($asc(\t),10,16,2))
; The below encodes "&" correctly and "."
;return $regsubex($$1-,/([^-.~\w])/g,$+(%,$base($asc(\t),10,16)))
; Converts spaces into %20's etc etc
return $regsubex($1-,/([^\d\w])/g,$+(%,$base($asc(\t),10,16)))
}
alias -l Svar {
var %sockname $1, %item $+($2,$1)
if ($isid) {
if ($regex(svar,$sock(%sockname).mark,/ $+ %item $+ \x01([^\x01]*)/i)) return $regml(svar,1)
}
elseif ($3) {
var %value $3-
if (!$regex(svar,$sock(%sockname).mark,/ $+ %item $+ \x01/i)) { sockmark %sockname $+($sock(%sockname).mark,$chr(1),%item,$UTF8(1),%value) }
else { sockmark %sockname $regsubex(svar,$sock(%sockname).mark,/( $+ %item $+ \x01[^\x01]*)/i,$+(%item,$chr(1),%value)) }
}
}
alias -l UTF8 {
if ($version >= 7) return $chr($1)
elseif ($1 < 255) { return $chr($1) }
elseif ($1 >= 256) && ($1 < 2048) { return $+($chr($calc(192 + $div($1,64))),$chr($calc(128 + $mod($1,64)))) }
elseif ($1 >= 2048) && ($1 < 65536) { return $+($chr($calc(224 + $div($1,4096))),$chr($calc(128 + $mod($div($1,64),64))),$chr($calc(128 + $mod($1,64)))) }
elseif ($1 >= 65536) && ($1 < 2097152) {
return $+($chr($calc(240 + $div($1,262144))),$chr($calc(128 + $mod($div($1,4096),64))),$chr($calc(128 + $mod($div($1,64),64))),$&
$chr($calc(128 + $mod($1,64))))
}
}
alias utfencodei {
if ($1 isnum 0-127) return $1
if ($1 isnum 128-2047) return $int($calc(192 + $1 / 64)) $calc(128 + $1 % 64)
if ($1 isnum 2048-65535) return $int($calc(224 + $1 / 4096)) $int($calc(128 + ($1 / 64) % 64)) $&
$calc(128 + $1 % 64)
if ($1 isnum 65536-1114111) return $int($calc(240 + $1 / 262144)) $int($calc(128 + ($1 / 4096) % 64)) $&
$int($calc(128 + ($1 / 64) % 64)) $calc(128 + $1 % 64)
}
alias -l div { return $int($calc($1 / $2)) }
alias -l mod {
var %int $int($calc($1 / $2))
return $calc($1 - (%int * $2))
}
alias -l H2U { return $utf8($base($1,16,10)) }