mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
Joined: Sep 2008
Posts: 23
P
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Sep 2008
Posts: 23
Hello mIRC Geniuses,

I want to set up a script so that when, lets say, someone needs me they can say !request and it will send a text to my phone saying "Username Needs you".

I think I can figure everything out up to the texting part. I know someone programmed a bot in perl to do that, and I am just wondering if it's available in mIRC.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Technically it might be possible, but it is, somewhat, dependent on the methods that messages can be sent to your cell phone.

Eg: I can't set up mIRC to send a text message to my cell phone using my provider's website, due to the fact that the messaging system from the website requires an authorization code, which is generated at the time of the message to be sent. You've probably seen the type of thing I'm talking about where there's a sequence of letters and numbers that have to be entered, but they are shown to you as a picture, so you can't just copy & paste the code.

However, my provider does support messages sent to my phone using an e-mail format of myphonenum@provider.com
and mIRC can be set up to send messages like that, using something like
Code:
/url -n mailto:email.address@provider.com?subject=Subject
with the ?subject=Subject being optional.

Joined: Sep 2008
Posts: 62
_
Babel fish
Offline
Babel fish
_
Joined: Sep 2008
Posts: 62
Another excellent method is using AIM, which I've seen a few web projects starting to use. You'd have to login to AIM, much like you'd have to login to an email server to send an email, but it's another option as well if you want full automation.


Joined: Sep 2008
Posts: 23
P
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Sep 2008
Posts: 23
Both of these idea's sound great.

Memo, I would love to attempt yours if you explain how to do it a little more.

Russle, I did try the email thing. Everything works for it, except someone needs to manually hit send. Is there any way that your aware of to automatically send the message?

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I've seen topics that refer to an alias called sendkeys
While I don't understand how it works, this is the one recently posted by Horstl
Code:
alias -l sendkeys { .comopen a WScript.Shell | .comclose a $com(a,SendKeys,3,*bstr,$$1-) }
Maybe he can explain how it works, or make other comments on it.

I had it working with a script, but due to losses occured due to hard drive crash, that was one of a few codes that I lost.

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
This alias just simulate the keyboard, /sendkey %r would simulate alt + r (% is alt) and open the mirc script editor (if mirc is active)


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Make a socket script that connect to your SMTP server and sends the message. SMTP is very easy to use (S = Simple), so it should be easy to create a script to send an email. In fact, I happen to have one that I made a long time ago:


Code:

alias sendmail {
  ;------ SET THE SERVER SETTINGS ------
  set %sndmail.smtpserver your.smtp.server.com
  set %sndmail.smtpport 25
  set %sndmail.debug $true

  ;------ SET THESE VALUES THEN CALL /sendmail -----
  set %sndmail.fromaddress from@address.com
  set %sndmail.toaddress to@address.com
  set %sndmail.subject This is the email subject
  set %sndmail.body This is the email body

  ;------ DON'T EDIT BELOW THIS LINE ------
  ;
  set %sndmail.logfile $+(maillog.,$asctime(dd.mm.yyyy),.txt)
  set %sndmail.state 1
  if ($sock(sendmail)) sockclose sendmail
  write %sndmail.logfile # Connect Attempt to %sndmail.smtpserver $+ : %sndmail.smtpport
  sockopen sendmail %sndmail.smtpserver %sndmail.smtpport
}
;
on *:sockread:sendmail:{ 
  var %temptext
  sockread %temptext
  tokenize 32 %temptext

  write %sndmail.logfile $asctime(HH:nn:ss) -> $1- 
  if ((%sndmail.state == 1) && ($1 == 220)) {
    mailsockwrite HELO localhost
    maildebug 220 -> HELO
    inc %sndmail.state
  } 
  elseif ((%sndmail.state == 2) && ($1 == 250)) { 
    mailsockwrite MAIL From: $+ %sndmail.fromaddress
    maildebug 250 -> MAIL
    inc %sndmail.state
  }
  elseif ((%sndmail.state == 3) && ($1 == 250)) { 
    mailsockwrite RCPT To: $+ %sndmail.toaddress 
    maildebug 250 -> RCPT
    inc %sndmail.state
  } 
  elseif ((%sndmail.state == 4) && ($1 == 250)) { 
    mailsockwrite DATA 
    maildebug 250 -> DATA
    inc %sndmail.state
  }
  elseif ((%sndmail.state == 5) && ($1 == 354)) {
    mailsockwrite Subject: %sndmail.subject 
    mailsockwrite $crlf 
    mailsockwrite %sndmail.body 
    mailsockwrite . 
    maildebug 354 -> SEND
    inc %sndmail.state
  }
  elseif ((%sndmail.state == 6) && ($1 == 250)) {
    mailsockwrite QUIT
    maildebug 250 -> QUIT
    inc %sndmail.state
  }
  elseif ((%sndmail.state == 7) && ($1 == 221)) {
    sockclose $sockname
    maildebug 221 ** DONE
    unset %sndmail.*
  }
  elseif ((%sndmail.state < 0) && ($1 == 221)) {
    sockclose $sockname
    maildebug 221 ** DONE
    unset %sndmail.*
  }
  else {
    mailsockwrite QUIT
    maildebug -> QUIT
    maildebug ** 4ERROR: $1-
    set %sndmail.state -1
  }
} 
;
alias mailsockwrite {
  sockwrite -n $sockname $1-
  write %sndmail.logfile $asctime(HH:nn:ss) <- $1-
}
alias maildebug { if (%sndmail.debug) echo 3 -at $1- }



Change the variables at the top to match your server/email settings, then call /sendmail

You can disable the debug echos by changing %sndmail.debug to $false.

This code can only send 1 email at a time, so you must add your own code to ensure it isn't called a second time before it has finished the first time. The code logs all SMTP traffic to daily logfiles.

-genius_at_work

Joined: Sep 2008
Posts: 23
P
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Sep 2008
Posts: 23
Thank you for the script smile

A few questions. Should that code go in the Alias section. Then I made this in the remote section:
on 300:TEXT:!report buffer:#:{ /msg $chan Reporting Bad video buffer to Dylan, $nick | /sendmail }

Second, in this part:
Code:
  ;------ SET THE SERVER SETTINGS ------
  set %sndmail.smtpserver your.smtp.server.com
  set %sndmail.smtpport 25
  set %sndmail.debug $true


Is that doable for something like gmail? Where would I put the username/password in?

Thanks much

Joined: Oct 2007
Posts: 214
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
Question for Geneious at Work,

What if your Email provider wanted to use SMTP Authentication,

Then how would you edit your script to reflect this, logging in with a username/password combo?

Thanks in advance,

Cheers,

Jay

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
SMTP with authentication:

Code:

alias sendmail {
  if (%sndmail.busy) {
    echo -a Already sending. Try again later.
    return -1
  }
  set %sndmail.busy 1

  ;------ SERVER SETTINGS ------
  set %sndmail.smtpserver smtp.server.com
  set %sndmail.smtpport 25

  set %sndmail.doauth $true
  set %sndmail.authuser smtp_auth_username
  set %sndmail.authpass smtp_auth_password

  set %sndmail.debug $true

  ;------ SET THESE VALUES THEN CALL /sendmail -----
  set %sndmail.fromaddress from@address.com
  set %sndmail.toaddress to@address.com
  set %sndmail.subject This is the subject
  set %sndmail.body This is the body

  ;------
  ;
  set %sndmail.logfile $+(maillog.,$asctime(dd.mm.yyyy),.txt)
  set %sndmail.state 1

  if ($sock(sendmail)) sockclose sendmail
  write %sndmail.logfile # Connect Attempt to %sndmail.smtpserver $+ : %sndmail.smtpport
  sockopen sendmail %sndmail.smtpserver %sndmail.smtpport
}
;
on *:sockread:sendmail:{ 
  var %temptext
  sockread %temptext
  tokenize 32 %temptext

  ;echo 2 -a %sndmail.state > $1-
  .timersmtp 1 5 mailsockclose $sockname

  write %sndmail.logfile $asctime(HH:nn:ss) -> $1- 
  if ((%sndmail.state == 1) && ($1 == 220)) {
    mailsockwrite EHLO localhost
    maildebug 220 -> EHLO (Introduce ourselves)
    %sndmail.state = 2
  }
  elseif ((%sndmail.state == 2) && ($left($1,4) == 250-)) {
    ; Do nothing
  }
  elseif ((%sndmail.state == 2) && ($1 == 250)) {
    if (%sndmail.doauth) {
      mailsockwrite AUTH LOGIN
      maildebug 250 -> AUTH LOGIN (Begin authentication)
      %sndmail.state = 3
    }
    else {
      mailsockwrite MAIL From: $+ %sndmail.fromaddress
      maildebug 250 -> MAIL (Auth OK; Specify FROM address)
      %sndmail.state = 6
    }
  }
  elseif ((%sndmail.state == 3) && ($1 == 334)) {
    mailsockwrite $encode(%sndmail.authuser,m) 
    maildebug 334 -> $encode(%sndmail.authuser,m) (Send Base64 encoded username)
    %sndmail.state = 4
  }
  elseif ((%sndmail.state == 4) && ($1 == 334)) {
    mailsockwrite $encode(%sndmail.authpass,m)
    maildebug 334 -> $encode(%sndmail.authpass,m) (Send Base64 encoded password)
    %sndmail.state = 5
  }
  elseif ((%sndmail.state == 5) && ($1 == 535)) {
    mailsockwrite QUIT
    maildebug 535 -> QUIT (Auth failed; Disconnect)
    %sndmail.state = -1
  }
  elseif ((%sndmail.state == 5) && ($1 == 235)) {
    mailsockwrite MAIL From: $+ %sndmail.fromaddress
    maildebug 250 -> MAIL (Auth OK; Specify FROM address)
    %sndmail.state = 6
  }

  elseif ((%sndmail.state == 6) && ($1 == 250)) { 
    mailsockwrite RCPT To: $+ %sndmail.toaddress 
    maildebug 250 -> RCPT (Specify TO address)
    %sndmail.state = 7
  }

  elseif ((%sndmail.state == 7) && ($1 == 250)) { 
    mailsockwrite DATA 
    maildebug 250 -> DATA (Initiate BODY specification)
    %sndmail.state = 8
  }

  elseif ((%sndmail.state == 8) && ($1 == 354)) {
    mailsockwrite Subject: %sndmail.subject 
    mailsockwrite $crlf 
    mailsockwrite %sndmail.body 
    mailsockwrite . 
    maildebug 354 -> SEND (Specify BODY data; Send email)
    %sndmail.state = 9
  }
  elseif ((%sndmail.state == 9) && ($1 == 250)) {
    mailsockwrite QUIT
    maildebug 250 -> QUIT (Email accepted; Disconnect)
    %sndmail.state = -1
  }

  elseif ((%sndmail.state < 0) && ($1 == 221)) {
    sockclose $sockname
    maildebug 221 (Quit successful)
    unset %sndmail.*
  }
  else {
    mailsockwrite QUIT
    maildebug -> QUIT (Unhandled result; Disconnect)
    maildebug ** 4ERROR: $1-
    set %sndmail.state -1
  }
} 
;
alias mailsockwrite {
  sockwrite -n $sockname $1-
  write %sndmail.logfile $asctime(HH:nn:ss) <- $1-
}
alias maildebug { if (%sndmail.debug) echo 3 -at $1- }
alias mailsockclose { if ($sock($1)) mailsockwrite $1 QUIT }



Operates the same as my previous code.

If the %sndmail.doauth variable is $true, authentication is done using the specified %sndmail.authuser and %sndmail.authpass . If it is $false, authentication is not done.

-genius_at_work

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
All of the code I provided should go in the REMOTES section.

If gmail allows you to connect to their SMTP server through sockets (not by using their webmail portal), then you should be able to use gmail.

It would be a VERY good idea to add some kind of anti-abuse to your !commands. Something like this:

Code:

on 300:TEXT:!report buffer:#:{
  if (%report.buffer) {
    notice $nick Bad video buffer was already reported to Dylan less than 30 minutes ago.
    return
  }
  set -u1800 %report.buffer 1
  notice $nick Reporting bad video buffer to Dylan, $nick $+ .
  sendmail
}



This will keep users from reporting more than once every 30 minutes.

-genius_at_work

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
RusselB feels that Genius is an understatement for genius_at_work's level of understanding regarding mIRC scripting.

Joined: Oct 2007
Posts: 214
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
Hello genius_at_work,

I must say your advanced scripting knowledge is definetly a piece of work!

I definetly like where this is going.

Now that I am all setup on the SMTP side, is there a way to do something similar with regards to a POP server with Authentication?

I've looked all over the net, and couldn't find any documentation related to mIRC connecting to a POP server.

Thanks a bunch for everything!

Cheers,

Jay

Joined: Sep 2007
Posts: 202
F
Fjord artisan
Offline
Fjord artisan
F
Joined: Sep 2007
Posts: 202
nice job genius_at_work

Joined: Sep 2008
Posts: 23
P
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Sep 2008
Posts: 23
Genius_at_work,

Thank you for the script! Its great.. although developing an error.

Quote:
220 -> EHLO (Introduce ourselves)
250 -> AUTH LOGIN (Begin authentication)
-> QUIT (Unhandled result; Disconnect)
** ERROR: 530 5.7.0 Must issue a STARTTLS command first. p27sm7379144qbp.16
221 (Quit successful)


Any idea what that means? Assuming it's because gmail uses TLS for encrypted connections and the current coding doesn't support that.

Last edited by partyboy911; 17/11/08 10:04 PM.
Joined: Sep 2008
Posts: 62
_
Babel fish
Offline
Babel fish
_
Joined: Sep 2008
Posts: 62
Gmail requires TLS/SSL to connect, which fortunately is trivial in mSL since it natively supports SSL sockets. You need to download and install the OpenSSL libraries. mIRC requires libeay32.dll and ssleay32.dll to be in $mircdir

$sslready can be used to check if SSL is available or not. Various SSL settings can be changed in the Connect/Options dialog and are available only if the OpenSSL libraries have been loaded successfully.

As far as changing the script, I'll leave that to the man whom wrote it. I would recommend going ahead however and installing OpenSSL and verifying it's working (in the Options as stated above, or //echo -a $sslready).

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
I haven't been able to get gmail to respond to my TLS connection attempts.

I already have a POP3 script that I need to test before I post it.

-genius_at_work

Joined: Sep 2008
Posts: 23
P
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Sep 2008
Posts: 23
Any suggestions on an email service that doesn't require a TLS connection?

Also, how do you get it to abort sending an email. I tried a different email service and had a wrong port.. so it's been sitting there trying to send it constantly. Restart mIRC and Restarting the computer did nothing


Scratch that, doing it on a different computer and it's working with my comcast email!

Thanks a ton! One last final question..

I am trying to get it to put what they say into the text message. So if they say !text Hey Where Are you it will include that.

I have the script setup like:
Code:
on 300:TEXT:!text*:#:{ /msg $chan Hello $nick , I am now texting " $2- " to Dylan | /sendmail }


And in the body part of the script it's setup as:
Code:
set %sndmail.body $nick says " $2- "

Last edited by partyboy911; 18/11/08 12:42 PM.
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
In my code, if you change this line:

Code:

set %sndmail.body This is the body



to this:

Code:

set %sndmail.body $1-



You can use the command like this:

/sendmail Your message body goes here.
/sendmail $nick says: $2-


Also, you should make all of your !commands like the !report buffer one I posted above. Otherwise, you will have people abusing your SMS messages.

-genius_at_work

Joined: Sep 2008
Posts: 23
P
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Sep 2008
Posts: 23
Originally Posted By: genius_at_work
In my code, if you change this line:

Code:

set %sndmail.body This is the body



to this:

Code:

set %sndmail.body $1-



You can use the command like this:

/sendmail Your message body goes here.
/sendmail $nick says: $2-


Also, you should make all of your !commands like the !report buffer one I posted above. Otherwise, you will have people abusing your SMS messages.

-genius_at_work


Genius at work, you are the genius.

Thank you VERY much! Props to you.

Page 1 of 2 1 2

Link Copied to Clipboard