mIRC Homepage
Posted By: Zaephyr Scripts for an mirc bot - 08/08/06 04:30 AM
Here are a few of the things I want to be able to do with my bot.

Take 3 nicks
Zaephyr
Darkhawk
Midnight

when the nicks enter the room I want my bot to say a certain message for each nick such as this

Welcome home, Mistress Zaephyr.
Greetings Master Darkhawk.
Hello Mistress Midnight.

another thing I want to be able to do is these

!bindf [nick]

would have Nisstyre perform this action:
Nisstyre takes [nick] and binds her hands securely.

and lastly I want my bot to say random things while its in the room.

Things like
actions:

Nisstyre wanders over to the bar and pours herself a drink.

or have her say things:

Nisstyre: God it's still monday.

Anyone that can help me do this, I'd really appreciate it.
Posted By: RusselB Re: Scripts for an mirc bot - 08/08/06 04:54 AM
1) Search for Greeting scripts. They've been done a fair bit, from very simple to very complicated.
2)
Code:
 on *:text:!bindf*:#:{
if !$2 {
.notice $nick You have to specify who you want to have bound
}
elseif $2 !ison $chan {
.notice $nick Sorry, but $2 has to be present for me to bind her
}
else {
describe # takes $2 and binds her hands securely
}
}

3) Create a text file with a different saying on each line
NOTE:This is NOT for actions
Code:
 on me:*:join:#:{
.timer 1 1800 .msg $chan $!read(saying.txt)
}
 

You will have to have the bot leave and rejoin the room. The bot will send a random message from the file saying.txt to the channel every 30 minutes
Posted By: landonsandor Re: Scripts for an mirc bot - 08/08/06 04:58 AM
In all the examples, replace #channel with the channel name.

Code:
on *:join:#channel: {
  if ($nick == Zaephyr) { msg # Welcome home, Mistress Zaephyr. }
  if ($nick == Darkhawk) { msg # Greetings Master Darkhawk. }
  if ($nick == Midnight) { msg # Hello Mistress Midnight. }
}


on *:text:!bindf *:#channel:/describe takes $2 and binds her hands securely.

As for the random actions, you'd need to do something like this (as an example):

on *:text:!ract:#:/msg # $read(random.txt)

You then place all kinds of random events in a Random.txt file in your mirc directory and the $read function would take a random line from it. If you wanted to combine the two ON TEXT events, try this:


Code:
on *:text:*:#channel: {
  if (!bindf == $1) { /describe takes $2 and binds her hands securely. }
  if (!ract == $1) { msg # $read(random.txt) }
  halt
}
Posted By: Zaephyr Re: Scripts for an mirc bot - 08/08/06 05:13 AM
I feel stupid, but I can get the script to work at all. Nothing happens. I dont know what I'm doing wrong.

I'm using the Dragonbot 1.4 found on www.geocities.com/irc_dragonbot/

I set the dragonbot.ini file to automatically open the greet.ini file

in the greet.ini I copy pasted the script

on *:join:#channel: { if ($nick == Zaephyr) { msg # Welcome home, Mistress Zaephyr. } if ($nick == Darkhawk) { msg # Greetings Master Darkhawk. } if ($nick == Midnight) { msg # Hello Mistress Midnight. }}

Exactly like it was shown when landon posted. But it wont do anything when I leave and reenter.
Posted By: RusselB Re: Scripts for an mirc bot - 08/08/06 05:25 AM
The script does NOT go in the ini file. It goes into a remote file on the bot. Go to your bot's client, Press Alt R, click Remotes, click File - New, copy and paste the script into the new remote file that you just created.
Click OK to close the Script editor.

Personally I'm sceptical when it comes to codes that have the mIRC files included with the script and/or everything is contained in an executable. Also please note that the most recent version of DragonBot (according to the website) has mIRC 6.15 with it. There have been 3 releases of mIRC since that time. It has been roughly 2 years since 6.16 was released (although it came out only about a month after 6.15, which is the version that comes with DragonBot)

If you're having trouble working with/configuring DragonBot, then you should be corresponding with the author.
Posted By: Zaephyr Re: Scripts for an mirc bot - 08/08/06 05:41 AM
is there a way to change landon's script for the !bindf so that if someone uses !bindf Midnight it doesn't appear in the room, only the results?
Posted By: KingTomato Re: Scripts for an mirc bot - 08/08/06 06:05 AM
if i understand properly...
Code:
on ^*:text:*:#channel: {
  if (!bindf == $1) { /describe takes $2 and binds her hands securely. | haltdef }
  if (!ract == $1) { msg # $read(random.txt) }
}
Posted By: RusselB Re: Scripts for an mirc bot - 08/08/06 06:16 AM
Yes, it's possible
Code:
 on *:text:*:*: {
  if (!bindf == $1) { /describe #channel takes $2 and binds her hands securely. }
elseif (!ract == $1) { msg #channel $read(random.txt) }
} 

You'll have to replace #channel with the actual name of the channel/room.

Usage so that only the results show in the channel: /msg <bot's name> !bindf <nick>

The options that I had in my code, such as ensuring that there was a nick entered and that the person is on the channel have not been incorporated here.
Posted By: Zaephyr Re: Scripts for an mirc bot - 08/08/06 06:16 AM
I got that part now King, it needed to be /describe $chan to place it in the channel window.

But now I'm having more trouble.

would the !ract thing make the bot say things on its own? or would you have to type !ract in the room?

I needed something that made a bot speak randomly, with random times and such.

And with actions as well as speaking.
Posted By: RusselB Re: Scripts for an mirc bot - 08/08/06 06:21 AM
For the random messages, refer to my original post item #3.
Posted By: Zaephyr Re: Scripts for an mirc bot - 08/08/06 06:32 AM
But is there a way to randomize the timing a bit more? instead of just every 30 minutes, couldnt it be set to do at random times?
Posted By: KingTomato Re: Scripts for an mirc bot - 08/08/06 06:34 AM
Here's the entirety of what you were looking for. Make a new text file in your mIRC directory named brand.txt (you can use //run notepad.exe $+(",$mircdirbrand.txt,") to have notepad make it for you). Within in, put your acitions/msgs. For actions, prefix the messages with /me. E.g. for the two demo's you gave, make the text file read:

Code:
God it's still monday.
/me wanders over to the bar and pours herself a drink.


And here is the code:

Code:
alias -l brandtime {
  var %lowtime = 300  [color:blue]| ; quickest duration between messages (in seconds)[/color]
  var %hightime = 900 [color:blue]| ; longest duration between messages (in seconds)[/color]
  return $rand(%lowtime,%hightime)
}
alias brandmsg {
  var %rline = $read(brand.txt)
  if (/me* iswm %rline) /describe $chan $gettok(%rline,2-,32)
  else /msg $chan %rline
  .timer [ $+ [ $1 $+ $2 ] ] 1 $brandtime brandmsg $1-
}
on *:JOIN:#: {
  .timer [ $+ [ $chan $+ $server ] ] 1 $brandtime brandmsg $chan $server
  
  ; add a new message using %msg.&lt;nickname&gt; format
  ; use $nick for their name
  var %msg.Zaephy   = Welcome home, Mistress $nick $+ .
  var %msg.Darkhawk = Greetings Master $nick $+ .
  var %msg.Midnight = Hello Mistress $nick $+ .
  if (%msg. [ $+ [ $nick ] ]) /msg $chan $v1
}
on ^*:TEXT:!bindf &amp;:#: {
  /describe $chan takes $nick and binds her hands securely.
  /haltdef
}

*untested, let me know of any bugs
Posted By: Zaephyr Re: Scripts for an mirc bot - 08/08/06 06:46 AM
that doesnt work, it wont randomly show up anything
Posted By: KingTomato Re: Scripts for an mirc bot - 08/08/06 06:54 AM
I'm sorry. Almost 3am here, brain farts. Try this: the rand messages were tested, just not the bindf or greetings.

[code]
alias -l brandtime {
var %lowtime = 300 | ; quickest duration between messages (in seconds)
var %hightime = 900 | ; longest duration between messages (in seconds)
return $rand(%lowtime,%hightime)
}
alias brandmsg {
var %rline = $read(brand.txt)
if (/me* iswm %rline) /describe $1 $gettok(%rline,2-,32)
else /msg $1 %rline
.timer [ $+ [ $1 ] ] 1 $brandtime brandmsg $1-
}
on *:JOIN:#: {
if ($nick == $me) .timer [ $+ [ $chan ] ] 1 $brandtime brandmsg $chan $server

; add a new message using %msg.<nickname> format
; use $nick for their name
var %msg.Zaephy = Welcome home, Mistress $nick $+ .
var %msg.Darkhawk = Greetings Master $nick $+ .
var %msg.Midnight = Hello Mistress $nick $+ .
if (%msg. [ $+ [ $nick ] ]) /msg $chan $v1
}
on ^*:TEXT:!bindf &:#: {
/describe $chan takes $nick and binds her hands securely.
/haltdef
}
[code]
Posted By: Zaephyr Re: Scripts for an mirc bot - 08/08/06 07:13 AM
Ok, how do I set up the message to run like this.

For that last scripting, with the brand.txt file giving out the messages to run, how do I set the date to show the accurate date such as. God, is it still {day of the week}
Posted By: Zaephyr Re: Scripts for an mirc bot - 08/08/06 08:17 AM
Nevermind that last posting, I managed to figure out how to get it done, but now I have another question.

How would I write a line in the file brand.txt in order to make the bot do this as a random action.

Nisstyre kneels beside Mistress Zaephyr and asks softly, "Would you like something to drink Mistress?"

But instead of Mistress Zaephyr, I want it to pull a random nick from somebody in the room at the time.

So if there are five people, named A, B, C, D, E how would I write it for the bot to choose a nick randomly and then ask it using that nick?

Also, how could I add a title to the names as in

Mistress A
Master B

where if nick B is chosen she says Master B, or if nick A is chosen she says Mistress A
Posted By: Inky Re: Scripts for an mirc bot - 08/08/06 11:59 AM
You can set welcome messages with the standard /botserv bots, put one of those in your channel, then type /botserv HELP, I'm sure it will explain how to set them up.
Posted By: KingTomato Re: Scripts for an mirc bot - 08/08/06 03:28 PM
The brand file accepts using mIRC commands. When the random action/msg is pulled, it is also evaluated.

If you wanted a random name, there is a few ways to go about it. One is if you want a random one form a specific list, you could use something like:

$gettok(A B C D E,$calc($rand(1,999) % 5 + 1),32)

The A B C D E would be the list of specific nicknames to use, the 5 is the number of names in that list. If you want a random nickname from the channel, use this:

$nick($chan,$calc($rand(1,999) % $nick($chan,0) + 1))

To ad Mistress or Master before either (You won't be able to do specify it based on gender, unless you coded a work-around, but if you wanted just a simple random, use:

$iif($calc($rand(1,999) % 2),Mistress,Master)

Add that before either of your random commands. Again, put any of this information in the brand file, and mIRC will evaluate it at the time of the random message.
© mIRC Discussion Forums