Skip to content

Instantly share code, notes, and snippets.

@SierraKomodo
Last active November 24, 2022 17:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SierraKomodo/18c877055a49629758260d0690bc9ba6 to your computer and use it in GitHub Desktop.
Save SierraKomodo/18c877055a49629758260d0690bc9ba6 to your computer and use it in GitHub Desktop.
mIRC Automated Execution Script v1.1.0
/*
** mIRC Automated Execution Script v1.1.0
**
** Author: Sierra Brown [ SierraKomodo ]
** Website: https://gist.github.com/SierraKomodo/18c877055a49629758260d0690bc9ba6
** IRC: SierraKomodo @ irc.freenode.net
**
** Provides some better control over automated functions to occur when you start mirc, connect to a
** server, or join a channel. Everything is stored into separated .ini files stored in
** scripts/config by default (Change the global variable %glo.ConfigPath to set a new location -
** Make sure the folder exists.)
**
** Refer to the example entries in the autoconnect, autocommand, and autojoin ini files.
**
** Implemented features:
** * Auto connect on start, including delayed autoconnections, support for multiple servers, and
** full support for most features of the /server command
** * Auto join on connection to server, including delayed auto joins and support for channel keys
** * Auto command on connection to server, allowing executing any IRC commands - Essentially runs
** /raw command here
*/
; INI file paths
alias -l locGlobalConfig return $+(%glo.ConfigPath, autoexec.ini)
alias -l locGlobalConfig.AutoConnect return $+(%glo.ConfigPath, autoexec-autoconnect.ini)
alias -l locServerConfig return $+(%glo.ConfigPath, $network, /autoexec.ini)
alias -l locServerConfig.AutoJoin return $+(%glo.ConfigPath, $network, /autoexec-autojoin.ini)
alias -l locServerConfig.AutoCommand return $+(%glo.ConfigPath, $network, /autoexec-autocommand.ini)
alias -l locChannelConfig return $+(%glo.ConfigPath, $iif($2, $2, $network), /, $iif($1, $1, $chan), /autoexec.ini)
alias -l locError return $+(%glo.ConfigPath, error.log)
on *:START: {
if (%glo.ConfigPath == $null) {
mkdir scripts
mkdir scripts/config
var -g %glo.ConfigPath = scripts/config/
}
; Write default config entries/generate files
if ($readini($locGlobalConfig, n, Config, bAutoConnect) == $null) {
writeini $locGlobalConfig Config bAutoConnect 0
}
if ($readini($locGlobalConfig, n, Config, iAutoConnectDelay) == $null) {
writeini $locGlobalConfig Config iAutoConnectDelay 5
}
if ($readini($locGlobalConfig, n, Config, sAutoConnectList) == $null) {
writeini $locGlobalConfig Config sAutoConnectList ExampleServer
writeini $locGlobalConfig.AutoConnect ExampleServer sAddress irc.example.com
writeini $locGlobalConfig.AutoConnect ExampleServer iPort 6667
writeini $locGlobalConfig.AutoConnect ExampleServer sPassword Password
writeini $locGlobalConfig.AutoConnect ExampleServer bSSL 0
writeini $locGlobalConfig.AutoConnect ExampleServer sNick Nickname
writeini $locGlobalConfig.AutoConnect ExampleServer sAltNick Alternate Nickname
writeini $locGlobalConfig.AutoConnect ExampleServer sRealName Real Name
writeini $locGlobalConfig.AutoConnect ExampleServer sIdent Ident
writeini $locGlobalConfig.AutoConnect ExampleServer iDelay 5
}
; Auto Connect
if (($readini($locGlobalConfig, n, Config, bAutoConnect)) && ($readini($locGlobalConfig, n, Config, sAutoConnectList) != $null)) {
; If autoconnect global delay is set, delay auto connection by X seconds - This delay exists to allow mIRC to load up fully before executing connections.
if ($readini($locGlobalConfig, n, Config, iAutoConnectDelay) > 0) {
timerglo.AutoConnect -o 1 $v1 atimer.AutoConnect
}
else {
atimer.AutoConnect
}
}
}
on *:CONNECT: {
if (!$exists(%glo.ConfigPath $+ $network)) {
mkdir %glo.ConfigPath $+ $network
}
; Write default config entries/generate files
if ($readini($locServerConfig, n, Config, bAutoJoin) == $null) {
writeini $locServerConfig Config bAutoJoin 0
}
if ($readini($locServerConfig, n, Config, iAutoJoinDelay) == $null) {
writeini $locServerConfig Config iAutoJoinDelay 3
}
if ($readini($locServerConfig, n, Config, sAutoJoinList) == $null) {
writeini $locServerConfig Config sAutoJoinList #Example
writeini $locServerConfig.AutoJoin #Example sKey Password
writeini $locServerConfig.AutoJoin #Example iDelay 5
}
if ($readini($locServerConfig, n, Config, bAutoCommand) == $null) {
writeini $locServerConfig Config bAutoCommand 0
}
if ($readini($locServerConfig, n, Config, iAutoCommandDelay) == $null) {
writeini $locServerConfig Config iAutoCommandDelay 1
}
if ($readini($locServerConfig, n, Config, sAutoCommandList) == $null) {
writeini $locServerConfig Config sAutoCommandList ExampleCommand
writeini $locServerConfig.AutoCommand ExampleCommand 1 privmsg NickServ identify password
writeini $locServerConfig.AutoCommand ExampleCommand 2 other command to send to the server
}
; Auto Join
if (($readini($locServerConfig, n, Config, bAutoJoin)) && ($readini($locServerConfig, n, Config, sAutoJoinList) != $null)) {
; If autojoin global delay is set, delay auto join by X seconds - This delay exists to allow mIRC to finish processing any on CONNECT scripts before executing joins.
if ($readini($locServerConfig, n, Config, iAutoJoinDelay) > 0) {
timer [ $+ [ $cid ] $+ ] .AutoJoin 1 $v1 atimer.AutoJoin
}
else {
atimer.AutoJoin
}
}
; Auto Command
if (($readini($locServerConfig, n, config, bAutoCommand)) && ($readini($locServerConfig, n, Config, sAutoCommandList) != $null)) {
; If autocommand delay is set, delay commands by X seconds - This delay exists to allow mIRC to finish processing any on CONNECT scripts before executing any other commands
if ($readini($locServerConfig, n, Config, iAutoCommandDelay) > 0) {
timer [ $+ [ $cid ] $+ ] .AutoCommand 1 $v1 atimer.AutoCommand
}
else {
atimer.AutoCommand
}
}
}
alias atimer.AutoConnect {
; Cycle through each server name entry in [Config] sAutoConnectList
var %loc.AutoConnectList = $readini($locGlobalConfig, n, Config, sAutoConnectList)
var %loc.NewWindow = 0
var %loc.Count = 1
while (%loc.Count <= $gettok(%loc.AutoConnectList, 0, 32)) {
var %loc.Current = $gettok(%loc.AutoConnectList, %loc.Count, 32)
; Check if the server name provided exists in the autoconnect ini file
if ($readini($locGlobalConfig.AutoConnect, n, %loc.Current, sAddress) != $null) {
var %loc.Address = $v1
var %loc.Port = $iif($readini($locGlobalConfig.AutoConnect, n, %loc.Current, iPort) != $null, $v1, 6667)
var %loc.Password = $readini($locGlobalConfig.AutoConnect, n, %loc.Current, sPassword)
var %loc.SSL = $iif($readini($locGlobalConfig.AutoConnect, n, %loc.Current, bSSL) != $null, $v1, 0)
var %loc.Nick = $readini($locGlobalConfig.AutoConnect, n, %loc.Current, sNick)
var %loc.AltNick = $iif($readini($locGlobalConfig.AutoConnect, n, %loc.Current, sAltNick), $v1, $+(%loc.Nick, _))
var %loc.RealName = $iif($readini($locGlobalConfig.AutoConnect, n, %loc.Current, sRealName), $v1, mIRC $version)
var %loc.Ident = $iif($readini($locGlobalConfig.AutoConnect, n, %loc.Current, sIdent), $v1, mirc)
var %loc.Delay = $readini($locGlobalConfig.AutoConnect, n, %loc.Current, iDelay)
; Connect to the server
if (%loc.Delay != $null) {
if (%loc.Nick != $null) {
timerglo.AutoConnect. [ $+ [ %loc.Current ] ] -o 1 %loc.Delay server $iif(%loc.NewWindow, -m) %loc.Address $iif(%loc.SSL, $+(+, %loc.Port), %loc.Port) %loc.Password -i %loc.Nick %loc.AltNick $+(%loc.Ident, @fake-ident-email.com)) %loc.RealName
}
else {
timerglo.AutoConnect. [ $+ [ %loc.Current ] ] -o 1 %loc.Delay server $iif(%loc.NewWindow, -m) %loc.Address $iif(%loc.SSL, $+(+, %loc.Port), %loc.Port) %loc.Password
}
}
else {
if (%loc.Nick != $null) {
server $iif(%loc.NewWindow, -m) %loc.Address $iif(%loc.SSL, $+(+, %loc.Port), %loc.Port) %loc.Password -i %loc.Nick %loc.AltNick $+(%loc.Ident, @fake-ident-email.com)) %loc.RealName
}
else {
server $iif(%loc.NewWindow, -m) %loc.Address $iif(%loc.SSL, $+(+, %loc.Port), %loc.Port) %loc.Password
}
}
; Set the 'New Window' flag to open all future server connections in a new connection window.
if (%loc.NewWindow == 0) %loc.NewWindow = 1
unset %loc.Address %loc.Port %loc.Password %loc.SSL %loc.Nick %loc.AltNick %loc.RealName %loc.Ident
}
; Go to next entry
unset %loc.Current
inc %loc.Count
continue
:error
echo -a * AutoExec Error in atimer.AutoConnect %loc.Current : $error
write $locError $logstamp - AutoExec Error in atimer.AutoConnect %loc.Current : $error
unset %loc.Current
; reseterror
inc %loc.Count
continue
}
return
:error
echo -a * AutoExec Error in atimer.AutoConnect : $error
write $locError $logstamp - AutoExec Error in atimer.AutoConnect : $error
; reseterror
}
alias atimer.AutoJoin {
; Cycle through each channel entry in [Config] sAutoJoinList
var %loc.AutoJoinList = $readini($locServerConfig, n, Config, sAutoJoinList)
var %loc.Count = 1
while (%loc.Count <= $gettok(%loc.AutoJoinList, 0, 32)) {
var %loc.Current = $gettok(%loc.AutoJoinList, %loc.Count, 32)
; Check if already in channel
if ($me !ison %loc.Current) {
var %loc.Key = $readini($locServerConfig.AutoJoin, n, %loc.Current, sKey)
var %loc.Delay = $readini($locGlobalConfig.AutoJoin, n, %loc.Current, iDelay)
; Join the channel
if (%loc.Delay != $null) {
timer [ $+ [ $cid ] $+ ] .AutoJoin. [ $+ [ %loc.Current ] ] join %loc.Current %loc.Key
}
else {
join %loc.Current %loc.Key
}
}
; Go to next entry
inc %loc.Count
continue
:error
echo -a * AutoExec Error in atimer.AutoJoin %loc.Current ( CID: $cid ) : $error
write $locError $logstamp - AutoExec Error in atimer.AutoJoin %loc.Current ( CID: $cid ) : $error
; reseterror
inc %loc.Count
continue
}
return
:error
echo -a * AutoExec Error in atimer.AutoJoin ( CID: $cid ) : $error
write $locError $logstamp - AutoExec Error in atimer.AutoJoin ( CID: $cid ) : $error
; reseterror
}
alias atimer.AutoCommand {
; Cycle through each command entry in [Config] sAutoCommandList
var %loc.AutoCommandList = $readini($locServerConfig, n, Config, sAutoCommandList)
var %loc.Count = 1
while (%loc.Count <= $gettok(%loc.AutoCommandList, 0, 32)) {
var %loc.Current = $gettok(%loc.AutoCommandList, %loc.Count, 32)
; Loop through each command line
var %loc.Count2 = 1
while ($readini($locServerConfig.AutoCommand, n, %loc.Current, %loc.Count2) != $null) {
raw $readini($locServerConfig.AutoCommand, n, %loc.Current, %loc.Count2)
inc %loc.Count2
continue
:error
echo -a * AutoExec Error in atimer.AutoCommand %loc.Current entry %loc.Count2 ( CID: $cid ) : $error
write $locError $logstamp - AutoExec Error in atimer.AutoCommand %loc.Current entry %loc.Count2 ( CID: $cid ) : $error
; reseterror
inc %loc.Count2
continue
}
inc %loc.Count
continue
:error
echo -a * AutoExec Error in atimer.AutoCommand %loc.Current ( CID: $cid ) : $error
write $locError $logstamp - AutoExec Error in atimer.AutoCommand %loc.Current ( CID: $cid ) : $error
; reseterror
inc %loc.Count
continue
}
return
:error
echo -a * AutoExec Error in atimer.AutoCommand ( CID: $cid ) : $error
write $locError $logstamp - AutoExec Error in atimer.AutoCommand ( CID: $cid ) : $error
; reseterror
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment