IRC Socket Connection

By Solitude on Jul 15, 2009

This is a basic IRC socket bot/connection/whatever.

I did NOT make this, nor do I take responsibility for it. I've been looking at this and various other tutorials/scripts to aid me in learning about sockets myself. I thought it'd be nice to share it with others who don't go to mircscripts.org

The original link to this: http://www.mircscripts.org/showdoc.php?type=tutorial&id=1541

It helped me understand a bit :

-NOTE: I advise looking at the tutorial if you don't understand this, it'll describe it far better than I possibly could. ^__^

;sb_open host [port]
alias sb_open {
  if ($sock(sb)) return
  if ($window(@sb_debug)) titlebar @sb_debug - Connecting
  .enable #sb_connecting
  sockopen sb $$1 $iif($2,$2,6667)
}

;sb_close
alias sb_close sb_cleanup

;sb_quit [message]
alias sb_quit sb_out QUIT $iif($0,: $+ $1-)

;sb_out 
alias sb_out {
  if ($sock(sb) == $null) return
  if ($window(@sb_debug)) echo 10 -ti2 @sb_debug >> $1-
  sockwrite -n sb $1-
}

;sb_debug
alias sb_debug {
  window -e @sb_debug
  if ($_online) titlebar @sb_debug - Nick: $_me
  else titlebar @sb_debug - Disconnected
}

alias -l sb_cleanup {
  if ($window(@sb_debug)) titlebar @sb_debug - Disconnected
  sockclose sb
  .disable #sb_connecting
  .timer 1 0 unset %sb_me
  .signal -n sbeDISCONNECT
}

alias -l sb_nick return SockBot
alias -l sb_nick2 return SB[ $+ $r(1000,9999) $+ ]
alias -l sb_user return bot
alias -l sb_realname return Socket Bot Sample 1.0 - myndzi

alias _getnick return $gettok($_strip:($1),1,33)
alias _getuser return $gettok($gettok($1,2,33),1,64)
alias _gethost return $gettok($1,2,64)
alias _strip: return $iif(:* iswm $1,$right($1,-1),$1)
alias _me if ($isid) return %sb_me | set %sb_me $$1 | if ($window(@sb_debug)) titlebar @sb_debug - Nick: %sb_me
alias _online return $iif($sock(sb),$true,$false)

on *:input:@sb_debug:{
  if ($left($1,1) == $readini($mircini,text,commandchar)) && (!$ctrlenter) return
  sb_out $1-
  haltdef
}

on *:sockopen:sb:{
  if ($sockerr) return $sb_cleanup
  sb_out NICK $sb_nick
  sb_out USER $sb_user * * :  $+ $sb_realname
}
on *:sockread:sb:{
  if ($sockerr) return $sb_cleanup
  var %t
  while ($sock(sb).rq) {
    sockread %t | tokenize 32 %t
    if ($sockbr == 0) return
    if ($window(@sb_debug)) echo 11 -ti2 @sb_debug << $1-
    if ($1 == PING) sb_out PONG $2-
    else .signal -n sbe_ $+ $2 $1-
  }
}
on *:sockwrite:sb:if ($sockerr) return $sb_cleanup
on *:sockclose:sb:return $sb_cleanup

on *:signal:sbe_NICK:if ($_getnick($1) == $_me) _me $_strip:($3)
on *:signal:sbe_PRIVMSG:{
  if (:ACTION * iswm $4-) .signal -n sbeACTION $1 ACTION $3 $left($5-,-1)
  elseif (:* iswm $4-) .signal -n sbeCTCP $1 CTCP $3 $mid($_strip:($4-),2,-1)
  else .signal -n sbeTEXT $1 TEXT $3 $_strip:($4-)
}
on *:signal:sbe_NOTICE:{
  if (:* iswm $4-) .signal -n sbeCTCPREPLY $1 CTCPREPLY $3 $mid($_strip:($4-),2,-1)
  elseif (. isin $_getnick($1)) .signal -n sbeSNOTICE $1 SNOTICE $3 $_strip:($4-)
  else .signal -n sbeNOTICE $1 NOTICE $3 $_strip:($4-)
}

#sb_connecting off
on *:signal:sbe_433:sb_out NICK $sb_nick2
on *:signal:sbe_422:sb_connected $3
on *:signal:sbe_376:sb_connected $3

alias -l sb_connected {
  _me $1
  if ($window(@sb_debug)) titlebar @sb_debug - Nick: $_me
  .disable #sb_connecting
  .signal -n sbeCONNECT
}
#sb_connecting end

Comments

Sign in to comment.
Fujitsu   -  Jul 17, 2009

ok thanx...

 Respond  
FordLawnmower   -  Jul 16, 2009

The script you described has nothing to do with sockets Fujitsu. Your example script would use either dccchat or pm and has nothing to do with this post.
Try posting it here --->> http://www.hawkee.com/phpBB2/viewforum.php?f=9

 Respond  
Fujitsu   -  Jul 16, 2009

nah.. that only the example for question i wanna ask, now my question is,.does this addon irc connection socket can be made like i explain just now?

 Respond  
Solitude   -  Jul 16, 2009

Try posting that in the 'requests' section on the forum.

 Respond  
Fujitsu   -  Jul 16, 2009

hurm,ok i try explain again 1 more times,hope u guys can understand what im trying to ask here,.im looking for IRC Socket Connection for mass invite bot which happen outside the channel that i wan to make mass invite with.

1.One connection open,normal ip,connect at IRC.join channel #1.this is set as the spy(watcher)User A

2.One more connection open connected to server using proxy ip,this is set as the inviter.current not joining any channel.<-- this is socket bot connection ..(user B)

3.User joining channel #1 will got automsg from user B ..*OP cant ban/kick out User B because its outside the channel.

4.hope u guys understand =\ ........ this is wat im trying to ask here ty ..

any codes/scripts can suggest to me?..or this addons the 1 im looking for all this time

 Respond  
Solitude   -  Jul 16, 2009

I don't really understand what you're trying to say, Fujitsu. Too jumbled :(

 Respond  
Fujitsu   -  Jul 16, 2009

im wondering wat scripts user use for massinvite outside channel?..example like user A(watcher) stay at channel #1 and user B(inviter ppl who joining channel #1) which not joining any channel.user A spy for user B to make automsg invite to ppl who joining the channel..i heard its socket bot also, could this code the things that im looking for all this time?..eg.like shadowx irc socket inviter/ but badly cant find the download link =\ ..loverss?horrible..pakerole? worst..

 Respond  
Solitude   -  Jul 15, 2009

I thought it'd be nice to share it with others who don't go to mircscripts.org

lol. I thought that'd make sense to people.

If you used somebody else's snippet you must include a URL to the original.

If people don't like that I found something cool and decided to share it, Hawkee or somebody can take the code down for me.

 Respond  
knoeki   -  Jul 15, 2009

...so what's the point of posting code as a snippet that isn't even yours?

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.