egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Gmail Notify Channel

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
BigToe
Halfop


Joined: 30 Dec 2010
Posts: 99

PostPosted: Thu Jan 17, 2013 7:47 pm    Post subject: Gmail Notify Channel Reply with quote

Hey there, after looking for quite a while and finding nothing i thought this would be the most appropriate forum to write the following request

I need a script that will fetch from my gmail account any new email received and labelled under 'my friends label' and will write to channel #friends the subject of that email.

Thank you
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Thu Feb 07, 2013 7:43 am    Post subject: Reply with quote

You can take a look at this script

Code:

######################################################################################
# GMAIL Notifier #################################################### v.0.12 #########
################################################### from game_over ###################
# NEED OPENSSL AND TLS PACKAGE TO WORK ###############################################
package require tls 1.4 ;                                                            #
###### Info ##########################################################################
# This is script who shows you RSS feed from your gmail mail profile under SSL       #
# connection, emulation of base64 tcl pure encoding and custom browser using cookies.#
# In this script i try to get efect like your browser do because if you use direct   #
# link to your mail you may be hacked. I recommend you to use this script only in    #
# your local machines. If you use this script don't forget to secure your machine.   #
# Tcl is open sourse and everyone can read your private data.                        #
###### Settings ######################################################################
# set here your email ################################################################
set gacc "your mail here@gmail.com"
# set here your password #############################################################
set gpass "your password here"
# set your nickname in irc ###########################################################
set gnick "your nick here"
# autochesk your mail and if you have new msg (in minutes) ###########################
set gresponce 10
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ##
set ::defnick 0
set ::SetCookie ""
if {[timerexists {checkmail $::botnick "" "" ""}]==""} {set ::starGttime [timer $gresponce {checkmail $::botnick "" "" ""}]}
bind msg - !gmail checkmail
bind DCC -|- gread readmail
proc checkmail {nick host hand text} {
   global gpass gacc gresponce
   set abc [split "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ""]
   set para ""; set gipm [split "$gacc:$gpass" ""]; set Bpat ""; set bcount 0; set bnum ""; set nam ""
   foreach mpig $gipm {binary scan $mpig B* X; set Bpat "$Bpat$X"}
   foreach sixbits [split $Bpat ""] {
      if {$bcount == 5} {binary scan [binary format B8 00$bnum$sixbits] c1 bnum; set para "$para[lindex $abc $bnum]"; set bnum ""; set bcount 0} else {set bnum "$bnum$sixbits"; incr bcount 1}
   }
   if {$nick != $::botnick} {set ::defnick 1}
   if {$bcount != 5 && $bcount != 0} {set nam [expr 6 - $bcount]; set bnum "$bnum[string repeat 0 $nam]"; binary scan [binary format B8 00$bnum] c1 bnum; set para "$para[lindex $abc $bnum]"}
   set Gsock [::tls::socket -async mail.google.com 443]
   set ::Gltv $Gsock ; after 3000 check_for_web
   fconfigure $Gsock -buffering line -encoding binary
   puts $Gsock "GET /mail/feed/atom/ HTTP/1.0"
   puts $Gsock "Accept: */*"
   puts $Gsock "Host: mail.googlel.com"
   if {$::SetCookie != ""} {puts $Gsock "Cookie: $::SetCookie"}
   puts $Gsock "Authorization: Basic $para[string repeat = [expr $nam / 2]]"
   puts $Gsock "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3"
   puts $Gsock "Content-Type: text/html"
   puts $Gsock ""
   fileevent $Gsock readable "readGmail $Gsock"
   if {[timerexists {checkmail $::botnick "" "" ""}]==""} {set ::starGttime [timer $gresponce {checkmail $::botnick "" "" ""}]}
}

proc check_for_web {} {
   global gnick
   if {$::Gltv != 0} {
      if {$::defnick==1} {putquick "PRIVMSG $gnick :Request timed out!"}
   }
}

proc readGmail {k} {
   set dfl ""
   while {[gets $k data] >= 0} {
      set data [string map { \{ "" \} "" \" ""} $data]
      if {[string match *Set-Cookie:* $data] && $::SetCookie == ""} {set ::SetCookie [string map {";" ""} [lindex $data 1]]}
      if {[string match *</feed>* $data]} {set ::Gltv 0}
      append dfl "$data\n"; unset data
   }
   readgm [split $dfl \n]; close $k;
}
set ::emils 0
proc readgm {lin} {
   global gnick
   if {$::Gltv != 0} {return 0}
   if {[regexp -all {<fullcount>(.*?)</fullcount>} $lin -> mails] == 1 && $::defnick == 1} {
      putquick "PRIVMSG $gnick :You have $mails emails! Type on DCC .gread <num of email> to read titles!"
   } elseif {[regexp -all {<fullcount>(.*?)</fullcount>} $lin -> mails] == 1 && $::defnick == 0 && $::emils < $mails} {
      putquick "PRIVMSG $gnick :You have new email! Type on DCC .gread <num of email> to read titles!"
   } else {return 0}; set ::emils $mails
   set begin [lsearch -regexp $lin "<fullcount>"]; set count 0; set f 0; set ::titlet ""; set ::summary ""; set ::namet ""; set ::mailt ""; set ::issyt ""
   foreach nil $lin {
      if {$begin < $count} {
         if {[regexp {<title>(.*?)</title>} $nil -> title] == 1} {append ::titlet " [string map "{{}} -" [list "$title"]]"}
         if {[regexp {<summary>(.*?)</summary>} $nil -> summar] == 1} {append ::summary " [string map "{{}} -" [list "$summar"]]"}
         if {[regexp {<issued>(.*?)</issued>} $nil -> issy] == 1} {append ::issyt " [string map "{{}} -" [list "$issy"]]"}
         if {[string mat *<author>* $nil]} {set f 1} elseif {[string mat *</author>* $nil]} {set f 0}
         if {[regexp {<name>(.*?)</name>} $nil -> name] == 1 && $f == 1} {append ::namet " [string map "{{}} -" [list "$name"]]"}
         if {[regexp {<email>(.*?)</email>} $nil -> mail] == 1 && $f == 1} {append ::mailt " [string map "{{}} -" [list "$mail"]]"}
      }
      incr count 1
   }
   unset begin; unset count
}
proc readmail {handle idx text} {
   global gnick
   if {$handle!=$gnick} {return 0}
   if {[string is digit -strict -failindex 1234567890 [lindex $text 0]]==1 && [lindex $text 0]<=[llength $::titlet] && [llength $::titlet]>0 && [lindex $text 0]>0} {
      set text [expr [lindex $text 0] - 1]; putquick "PRIVMSG $gnick : Title:[lindex [lindex $::titlet $text] 0] Summary:[lindex $::summary $text] Name:[lindex $::namet $text] Email:[lindex $::mailt $text] Date:[lindex $::issyt $text]"
   } else {putquick "PRIVMSG $gnick : ERR: You don't have this number of letters!"; return 0}
}

_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber