simple !say command for IRC Bots

By saloun on Mar 22, 2014

This is a simple !echo command that allow you to say something on channels if your bot is on that chans

If you have any Problem please Post a comment and i'll help you .

if you want it to work only for you use the 1st version and Replace BotOwnerNickHere with your nick.

If you want it to work for the public use the 2nd version.

@UPDATED on 29/03/2014

--1st Version--
on *:text:!say*:#:{
  if ($nick == saloun) msg $2 $3-
}
--2nd Version--
on *:text:!say*:#:{
  msg $2 $3-
}   

Comments

Sign in to comment.
ovelayer   -  Mar 22, 2014
on *:TEXT:*:#: {
  if ($1 == !say) { 
    .msg $2 $3-
 }
if ($1 == !echo) && ($nick == BotOwnerNickHere) {
   .msg $2 $3-
 }
}

would be better

saloun  -  Mar 22, 2014

Thanks For your answer , i will Update it

[AFX]  -  Mar 22, 2014

ovelayer did you test that before posting? you cant message $2 because $2 is a part of the $1- string, which takes in the command the user sends with !say

just test by doing echo $1-...theres no target to message. you probably meant .msg $chan $2 $3-

ovelayer  -  Mar 22, 2014

i updated the code you were right about the $3-
but the msg target would be the $2
$1 would be the command $2 the channel/person $3- the message

[AFX]  -  Mar 22, 2014

$1 = !say
$2 = comes after !say
$3 = comes after $2

sorry, but your code doesnt work because you arent messaging the correct target. i tested your code and it doesnt work. it can be modified to work in the way you are attempting to make it work though.

[AFX]  -  Mar 22, 2014

on :text::#: {
if ($1 = !say) { .msg # $2- }
elseif ($1 = !echo) && ($nick == BotOwnerNickHere) { .msg # $2- }
}

tested and %100 working.

ovelayer  -  Mar 22, 2014

(11:09) <~xXBERTOXx> !say #coders hello
(11:09) <@tEsTcLiEnT> hello
(11:10) <~xXBERTOXx> !echo #coders hello
(11:10) <@tEsTcLiEnT> hello

works just fine

[AFX]  -  Mar 22, 2014

$2 shouldnt be up to the end user to determine which channel the bot messages. what if that bot isnt in that channel? i used # (or you can use $chan) because this ensures that the bot isnt going to start messaging channels it isnt in text the end user supplies

the way you are doing it, you might as well change your event to be:

on :text::*:

this way, you do have control as to which channel the bot messages, but it only makes sense for the bot to be in the channel you (the end user is on). error checking my friend.

ovelayer  -  Mar 22, 2014

i just edited the orig script for a better result.
your gettin into techical stuff that wasn't in the orig script
yes it can be altered many ways but that is up to the person using the script how the want to use it

[AFX]  -  Mar 22, 2014

sorry, i dont mean to argue with you by any means as that is truly not my intention, but i dont understand how you made the outcome "a better result". sorry that i am too technical for you too, but the code was just wrong and if you are going to release a script you best make sure that it is tested and scripted properly, with full error checking instead of taking the easy way out, if anything, i just fixed his script.

ovelayer  -  Mar 22, 2014

on :text::*:
would make it respond to commands in any event?
im not sure where your goin with this

[AFX]  -  Mar 22, 2014

yes, because the last asterisk determines which kind of window the event takes place in

from the mirc help file:

The location where this event occurrs can be specified using:

? for any private message

for any channel message

mirc for any messages on channel #mirc

  • for any private or channel messages

if i were the author, i would stick with on :text::# as this only responds to channels as originally written
and in your case, lose the $2, because if i do !say #test blahblah blah, and the bot isnt on #test, the command wont parse properly. the way i did it ensures that it only messages the channel the bot is in

ovelayer  -  Mar 22, 2014

correct
that is how the orig script listened for the commands thus why i redid it like that

[AFX]  -  Mar 22, 2014

see my edit above

[AFX]  -  Mar 22, 2014

you could make it work that way (the way you did it)

on :text::#: {
if ($1 = !say) && ($2 ischan) { .msg $2 $3- }
elseif ($1 = !say) && ($2 !ischan) { .join $2 | .msg $2 $3- }
}

this checks that $1 is !say and if the bot is in the channel, message the channel $3-
if the bot isnt in the channel ($2), it will join that channel and message the channel $3-

see what i am getting at here?

ovelayer  -  Mar 22, 2014

or you could do something like

if ($1 == !say) { 
  if (# isin $2) && ($me !ison $2) { .msg $chan sorry but i am not on $2 | halt }
    .msg $2 $3-
 }
[AFX]  -  Mar 22, 2014

yes, now you are adding the error checking, which is correct, which is what i was trying to get at. so now the script wont break and now it works properly.

except i would add an else after the fact

if ($1 == !say) {
if (# isin $2) && ($me !ison $2) { .msg $chan sorry but i am not on $2 }
else { .msg $2 $3- }
}

P.S how are you making code blocks when you post? whats the bbc code to do that?

ovelayer  -  Mar 22, 2014

=)

[AFX]  -  Mar 22, 2014

how are you making code blocks in your posts? the ``` didnt work for me

ovelayer  -  Mar 22, 2014

by typing it out.. [ code ] and [ /code ]
remove the spaces in the blocks

[AFX]  -  Mar 22, 2014

ah i thought i tried that before but it wasnt showing me the actual script i was testing with....gonna test in this post....disregard

alias -l test_inptyn { var %c = $?!="Are the code blocks working?" | echo -s $iif(%c =y,yes,no) }
saloun  -  Mar 23, 2014

My script work 100% fine , i tested it many times

Astreon3868  -  Mar 23, 2014

If you want to make the !say command public, just use this script:

on *:text:*:#:{
  if ($1 == !say) msg $$2 [Bot message by $nick on $chan ] $3
}

This will show who used this command, and !echo (that command for owners) is invisible!

saloun  -  Mar 25, 2014

I already know , anyway Thanks mate

OkamiTheWusky  -  Mar 28, 2014

I just use the following:

on *:TEXT:!say *:#: { msg $chan $2- } 
saloun  -  Mar 29, 2014

no your fail @OkamiTheWusky
i UPDATED The script so use the new one

Nos  -  Mar 29, 2014
 on *:TEXT:!say*:#:/msg $chan $2- 
Astreon3868  -  Mar 29, 2014

I don't understand this 2nd one. $nick == $1 LOL. The 2nd one is a command for everyone (official command), isn't it? If so, then no need to put this "if ($nick == $1)

The script looks so then:

--2nd Version--
on *:text:!say*:#:{
  msg $2 $3-
} 
saloun  -  Mar 29, 2014

k UPDATED

saloun  -  Mar 30, 2014

All Off-topic comments has been deleted . Post here if you need help about my script

Sign in to comment

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.