[color:red] [/color]
alias checkgmail {
var %e = echo -ac info * Gmail checker:
if (!$0) { %e you must specify an email address. | return }
set %gmail.email $1
if (!$($+(%,gmail_,$1,_cookie),2)) gmail_getcookie
else {
if (!$window(@gmail)) window -h @gmail
%e checking for unread emails on account $1...
sockclose gmail
sockopen gmail mail.google.com 80
}
}
[color:red] [/color]
on *:sockopen:gmail:{
if ($sockerr) return
var %s = sockwrite -tn gmail
%s GET /mail/?&ik=&search=inbox&view=tl HTTP/1.1
%s Host: mail.google.com
%s Cookie: $($+(%,gmail_,%gmail.email,_cookie),2)
%s
}
[color:red] [/color]
on *:sockread:gmail:{
if ($sockerr) return
var %a
sockread %a
while ($sockbr) {
if (%a != $null) aline @gmail %a
sockread %a
}
}
[color:red] [/color]
on *:sockclose:gmail:{
filter -wk @gmail parsegmail
echo -ac info * Gmail checker: $iif(%gmail.total,$ifmatch,no) unread mails found.
gmail_cleanup
}
[color:red] [/color]
alias -l parsegmail {
if ($regex(gmail,$1,/<span id=\\"_user_(.+?)\\"><b>.+?&nbsp;"\54"<b>(.+?)<\/b>"\54"(.+?)&hellip;/)) {
inc %gmail.total
echo -a From: $regml(gmail,1)
echo -a Subject: $gmail_html($regml(gmail,2))
echo -a Excerpt: $gmail_html($regml(gmail,3)) $+ ...
echo -a
}
}
[color:red] [/color]
alias -l gmail_html {
var %result = $1
while $regex(gm,%result,/(&#(\d+?);)/) {
%result = $replace(%result,$regml(gm,1),$chr($regml(gm,2)))
}
return %result
}
[color:red] [/color]
; Code for retrieving cookie with COM
[color:red] [/color]
alias -l gmail_getcookie {
var %e = echo -ac info * Gmail checker:
set %gmail.pass $input(Enter your gmail password,po)
if (%gmail.pass == $null) {
%e you did not fill in the password... aborting.
gmail_cleanup
return
}
%e retrieving cookie, hold on...
ie.navigate http://mail.google.com/mail/?logout
gmail_timer
}
[color:red] [/color]
alias -l gmail_check {
if (!$timer(gmail_check).reps) gmail_error
elseif ($ie.status == 4) {
var %url = $ie.url
if (!%gmail.login) {
if (*ServiceLogin* iswm %url) { inc %gmail.login | gmail_login }
}
else {
if (http://mail.google.com/mail/* iswm %url) {
set $+(%,gmail_,%gmail.email,_cookie) $ie.cookie
.timergmail_check off
checkgmail %gmail.email
}
elseif (%url == https://www.google.com/accounts/ServiceLoginAuth) {
echo -ac info * Gmail checker: you've supplied the wrong email/pass, try again.
gmail_cleanup
}
}
}
}
[color:red] [/color]
alias -l gmail_login {
var %t
%t = $com(ie.main,document,2,dispatch* ie.doc)
.comclose ie.doc $com(ie.doc,getelementbyid,1,bstr*,gaia_loginform,dispatch* ie.form)
if (!$com(ie.form)) { gmail_error | return }
%t = $com(ie.form,email,2,dispatch* ie.form.email)
.comclose ie.form.email $com(ie.form.email,value,4,bstr*,%gmail.email)
%t = $com(ie.form,passwd,2,dispatch* ie.form.passwd)
.comclose ie.form.passwd $com(ie.form.passwd,value,4,bstr*,%gmail.pass)
%t = $com(ie.form,submit,1)
.comclose ie.form
gmail_timer
}
[color:red] [/color]
alias -l gmail_error {
echo -ac info * Gmail checker: unable to retrieve cookie, try again later.
gmail_cleanup
}
[color:red] [/color]
alias -l gmail_cleanup {
.timergmail_check off
if ($com(ie.main)) .comclose ie.main $com(ie.main,quit,1)
if ($window(@gmail)) close -@ @gmail
unset %gmail.*
}
[color:red] [/color]
alias -l gmail_timer .timergmail_check -m 50 150 gmail_check
[color:red] [/color]
alias -l ie.navigate {
if (!$com(ie.main)) .comopen ie.main internetexplorer.application
showmirc -s
return $com(ie.main,navigate,1,bstr*,$1)
}
[color:red] [/color]
alias -l ie.status {
if ($com(ie.main)) return $(,,$com(ie.main,readystate,2)) $com(ie.main).result
}
[color:red] [/color]
alias -l ie.url {
if ($com(ie.main)) return $(,,$com(ie.main,locationurl,2)) $com(ie.main).result
}
[color:red] [/color]
alias -l ie.cookie {
var %t = $$com(ie.main)
%t = $com(ie.main,document,2,dispatch* ie.doc)
if ($com(ie.doc)) {
%t = $com(ie.doc,cookie,2)
%t = $com(ie.doc).result
.comclose ie.doc
}
return %t
}