mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 4 1 2 3 4
#186435 22/09/07 06:47 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
I've decided on a project, writing my own bot. I've ran into a few snags. One of them being bot self protections, and another being userlists. The bot is using a userlist with access level syscon for bot operators. However, some of the bot's bot-ops change IPs frequently. I don't know how to write a remote-login for bot-ops, or maybe I should do syscon:$address(botopnick,2}

Anyway, this is what I got for the unban:
Code:
on 1:BAN:#:{
  if ($banmask == $address($me,2)) { /mode $chan -b $banmask | halt }
}


EDIT: on * instead of on 1 fixed the unban. Is it possible to do $address($me,*), so that if the ban matches me at all it unbans?

Mpot #186436 22/09/07 07:02 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
For the unban script, you could try:

Code:
if ($banmask iswm $ial($me)) { do stuff }


As for the login script, this is a little something i did a little while ago. It can be improved alot, but I have to go to work soon so I can't edit it further, sorry.

Code:
menu channel,status {
  $iif($dialog(ulst),$style(3)) User List: { 
    ulst open
  }
}

On *:Disconnect: {
  ulst save
  if ($hget(loggedin_nicks)) hfree $v1
}
On *:Exit: {
  ulst save
  if ($isfile(loggedin_nicks.hsh)) remove loggedin_nicks.hsh
}
on *:start:{
  if (!$hget(ulst))  { .hmake ulst 10 }
  if ($exists(ulst.hsh)) { .hload -i ulst ulst.hsh }
}

dialog ulst {
  title "User List"
  size -1 -1 80 117
  option dbu notheme
  list 1, 2 2 77 87, size
  box "", 2, 1 -2 79 92
  button "&Add", 3, 9 92 31 11, flat
  button "&Rem", 4, 40 92 31 11, flat
  button "&Close", 5, 9 104 62 11, flat ok
}

On *:Dialog:ulst:*:*: {
  if ($devent == init) {
    var %x = 1
    while (%x <= $hget(ulst,0).item) {
      did -a $dname 1 $hget(ulst,%x).item
      inc %x
    }
  }
  if ($devent == sclick) {
    if ($did == 3) {
      var %ulst.add = $$input($cr,e,User List - Please add a nickname), %ulst.pw $$input($cr,e,User List - Please add a password)
      ulst %ulst.add %ulst.pw
      did -a $dname 1 %ulst.add
      dialog -v ulst ulst
    }
    if ($did == 4) {
      if (!$did($dname,1).sel) return
      ulst -r $did($dname,1).seltext
      did -d $dname 1 $didwm($dname,1,$did($dname,1).seltext,1)
    }
  }
}

alias ulst {
  if (!$hget(ulst)) hmake ulst 10
  if ($1 == -r) {
    if (!$2) echo 2 -a * /ulst: insufficient parameters
    elseif (!$hget(ulst,$2)) echo 3 -a * /ulst: $2 not in user list
    else { hdel ulst $2 | echo 3 -a * Removed $+($chr(2),$2,$chr(2)) from user list }
  }
  elseif ($1 == -l) {
    if ($hget(ulst,0).item < 1) echo 2 -a * user list empty
    else {
      echo 2 -a * ulst list:
      var %x = 1
      while (%x <= $hget(ulst,0).item) {
        echo 3 -a $hget(ulst,%x).item
        inc %x
      }
    }
  }
  elseif ($1 == save) hsave -i ulst ulst.hsh
  elseif ($1 == open) dialog $iif($dialog(ulst),-v,-dm) ulst ulst
  else {
    if (!$2) echo 2 -a * /ulst: insufficient parameters
    elseif (!$hget(ulst,$1)) && ($2 isalnum) { hadd ulst $1 $2 | echo 3 -a * Added $+($chr(2),$1,$chr(2)) to user list with password $+($chr(2),$2) }
    else { echo 3 -a * /ulst: $1 is already in user list }
  }
  hsave -i ulst ulst.hsh
}

on 1:Text:login*:?: {
  if (!$hfind(ulst, $2)) { 
    .notice $nick Sorry, your nickname is not in my user user list. 
    halt 
  }
  if ($hfind(users, $2)) && (!$3) { 
    .notice $nick You didn't specify a password. 
    halt 
  }
  if ($hfind(loggedin_nicks, $2)) { 
    .notice $nick You are already logged in. 
    halt
  }
  if ($hfind(ulst, $2)) && ($hget(ulst,$2) == $3) { 
    .notice $nick Authorisation to user $+($chr(2),$2,$chr(2)) has been accepted, you are now logged in.
    hadd -m loggedin_nicks $2 Yes
    hsave -i loggedin_nicks loggedin_nicks.hsh 
    halt 
  }
  if ($hfind(ulst, $2)) && ($hget(users,$2) != $3) { 
    .notice $nick Password for account $+($chr(2),$2,$chr(2)) is incorrect. 
    halt 
  }
  if ($hfind(ulst, $2)) && (!$3) { 
    .notice $nick You didn't specify a password. 
    halt
  }
}

on 1:text:logout*:?: {
  if ($2) {
    if ($hfind(loggedin_nicks, $2)) { 
      hdel loggedin_nicks $2
      hsave -i loggedin_nicks loggedin_nicks.hsh 
      .notice $nick You have successfully logged out.
      halt 
    }
    if (!$hfind(loggedin_nicks, $2)) && ($hfind(ulst,$2)) { 
      .notice $nick You are already logged out.
      halt
    }
  }
}

on *:TEXT:*:?: {
  ;Commands if they're logged in
  if ($hfind(loggedin_nicks, $nick)) {
  ;A simple op me script, commands are sent to query.  Change if the ? to # if you want it in channels. 
    if (opme == $1) && ($me isop $2) mode $2 +o $nick
  }
}

Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
I can't say I understand how the login script works.

Mpot #186439 22/09/07 07:37 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
It's pretty simple. Open up the dialog, click add. Then enter a username and password when prompted.

Then they type login <User> <Pass>, in a PM with you.

I should have added comments initially, but it is fairly straight forward.

Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
if ($chan == #uranme && %uranmeuno == off) { msg $chan Sorry, uno has been disabled on #uranme. | halt }

Will that work? I'm trying to combine two things here. It's part of my bot-op control. Basically, I want it to where if %uranmeuno is off, and the command is triggered on #uranme, then it halts. Can I combine operators like that?

Mpot #186470 23/09/07 05:20 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yes, you can combine like that.

Regarding "halt", keep in mind two things...

1) If you don't need to halt the script, don't. Halting when it's going to halt on its own is not necessary.

2) If you're just trying to end a script early based on something that happened (an error or not matching something, for example), use RETURN instead of HALT.


Invision Support
#Invision on irc.irchighway.net
Riamus2 #186502 23/09/07 05:45 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
I have a systems control script I've written for my bot. Is there anyway for the bot to write to a op_log.txt file when someone uses one of the commands, logging when the action was done in HH:mm:ss,and noting who ran the command and what channel it was ran on, or if it was done via query?

Edit: /write C:/IcyBot2/Scripts/op_log.txt $nick used $$1 on $chan at

I just randomly came up with that. I think it should work, but I don't know the timestamp $identifier.
Code:
;IcyBot systems control

;IcyBot
on syscon:TEXT:!disable_bot:#:set %icybot off | msg $chan IcyBot's functionality has been disabled. | halt
on syscon:TEXT:!disable_bot:?:set %icybot off | notice $nick IcyBot's functionality has been disabled. | halt
on syscon:TEXT:!enable_bot:#:set %icybot on | msg $chan IcyBot's functionality has been enabled. | halt
on syscon:TEXT:!enable_bot:?:set %icybot on | notice $nick IcyBot's functionality has been enabled. | halt

;Banners
on syscon:TEXT:!disable_banners:#:set %banners off | msg $chan Banners have been disabled. | halt
on syscon:TEXT:!disable_banners:?:set %banners off | notice $nick Banners have been disabled. | halt
on syscon:TEXT:!enable_banners:#:set %banners on | msg $chan Banners have been enabled. | halt
on syscon:TEXT:!enable_banners:?:set %banners on | notice $nick Banners have been enabled. | halt

;8ball
on syscon:TEXT:!disable_8ball:#:set %8ball off | msg $chan 8ball has been disabled. | halt
on syscon:TEXT:!disable_8ball:?:set %8ball off | notice $nick 8ball has been disabled. | halt
on syscon:TEXT:!enable_8ball:#:set %8ball on | msg $chan 8ball has been enabled. | halt
on syscon:TEXT:!enable_8ball:?:set %8ball on | notice $nick 8ball has been enabled. | halt

;Uno
on syscon:TEXT:!disable_uno:#:set %uno off | msg $chan Uno has been disabled. | halt
on syscon:TEXT:!disable_uno:?:set %uno off | notice $nick Uno has been disabled. | halt
on syscon:TEXT:!enable_uno:#:set %uno on | msg $chan Uno has been enabled. | halt
on syscon:TEXT:!enable_uno:?:set %uno on | notice $nick Uno has been enabled. | halt

;Trivia
on syscon:TEXT:!disable_trivia:#:set %trivia off | msg $chan Trivia has been disabled. | halt
on syscon:TEXT:!disable_trivia:?:set %trivia off | notice $nick Trivia has been disabled. | halt
on syscon:TEXT:!enable_trivia:#:set %trivia on | msg $chan Trivia been enabled. | halt
on syscon:TEXT:!enable_trivia:?:set %trivia on | notice $nick Trivia has been enabled. | halt

;Invite
on syscon:TEXT:!disable_invite:#:set %invite off | msg $chan Inviting has been disabled. | halt
on syscon:TEXT:!disable_invite:?:set %invite off | notice $nick Inviting has been disabled. | halt
on syscon:TEXT:!enable_invite:#:set %invite on | msg $chan Inviting been enabled. | halt
on syscon:TEXT:!enable_invite:?:set %invite on | notice $nick Inviting has been enabled. | halt

;Huggle
on syscon:TEXT:!disable_huggle:#:set %huggle off | msg $chan Huggling has been disabled. | halt
on syscon:TEXT:!disable_huggle:?:set %huggle off | notice $nick Huggling has been disabled. | halt
on syscon:TEXT:!enable_huggle:#:set %huggle on | msg $chan Huggling been enabled. | halt
on syscon:TEXT:!enable_huggle:?:set %huggle on | notice $nick Huggling has been enabled. | halt

;Misc
on syscon:TEXT:!disable_misc:#:set %misc off | msg $chan Miscellaneous features have been disabled. | halt
on syscon:TEXT:!disable_misc:?:set %misc off | notice $nick Miscellaneous features have been disabled. | halt
on syscon:TEXT:!enable_misc:#:set %misc on | msg $chan Miscellaneous features have been enabled. | halt
on syscon:TEXT:!enable_misc:?:set %misc on | notice $nick Miscellaneous features have been enabled. | halt

;Timebomb
on syscon:TEXT:!disable_timebomb:#:set %timebomb off | msg $chan Timebomb has been disabled. | halt
on syscon:TEXT:!disable_timebomb:?:set %timebomb off | notice $nick Timebomb has been disabled. | halt
on syscon:TEXT:!enable_timebomb:#:set %timebomb on | msg $chan Timebomb has been enabled. | halt
on syscon:TEXT:!enable_timebomb:?:set %timebomb on | notice $nick Timebomb has been enabled. | halt

;Greet
on syscon:TEXT:!disable_greet:#:set %greet off | msg $chan Greet notices have been disabled. | halt
on syscon:TEXT:!disable_greet:?:set %greet off | notice $nick Greet notices have been disabled. | halt
on syscon:TEXT:!enable_greet:#:set %greet on | msg $chan Greet notices have been enabled. | halt
on syscon:TEXT:!enable_greet:?:set %greet on | notice $nick Greet notices have been enabled. | halt

;Rules
on syscon:TEXT:!disable_rules:#:set %rules off | msg $chan Greet notices have been disabled. | halt
on syscon:TEXT:!disable_rules:?:set %rules off | notice $nick Greet notices have been disabled. | halt
on syscon:TEXT:!enable_rules:#:set %rules on | msg $chan Greet notices have been enabled. | halt
on syscon:TEXT:!enable_rules:?:set %rules on | notice $nick Greet notices have been enabled. | halt

;Bannermaker
on syscon:TEXT:!disable_bannermaker:#:set %bannermaker off | msg $chan Banner making has been disabled. | halt
on syscon:TEXT:!disable_bannermaker:?:set %bannermaker off | notice $nick Banner making has been disabled. | halt
on syscon:TEXT:!enable_bannermaker:#:set %bannermaker on | msg $chan Banner making has been enabled. | halt
on syscon:TEXT:!enable_bannermaker:?:set %bannermaker on | notice $nick Banner making has been enabled. | halt

;HelpSys
on syscon:TEXT:!disable_helpsys:#:set %helpsys off | msg $chan Help system has been disabled. | halt
on syscon:TEXT:!disable_helpsys:?:set %helpsys off | notice $nick Help system has been disabled. | halt
on syscon:TEXT:!enable_helpsys:#:set %helpsys on | msg $chan Help system has been enabled. | halt
on syscon:TEXT:!enable_helpsys:?:set %helpsys on | notice $nick Help system has been enabled. | halt

;OpGreet
on syscon:TEXT:!disable_opgreet:#:set %opgreet off | msg $chan Bot-Op greeting has been disabled. | halt
on syscon:TEXT:!disable_opgreet:?:set %opgreet off | notice $nick Bot-Op greeting has been disabled. | halt
on syscon:TEXT:!enable_opgreet:#:set %opgreet on | msg $chan Banner Bot-Op greeting been enabled. | halt
on syscon:TEXT:!enable_opgreet:?:set %opgreet on | notice $nick Bot-Op greeting has been enabled. | halt


Code:
;Bot controls

;Part
on syscon:text:!part*:*:{
  if ($2 == $null) { /part $chan | /notice $nick Parted channel. | halt }
  if ($2 !ischan ) { /notice $nick I'm already off that channel. | halt }
  if ($2 != $null) { /part $2 | /notice $nick Parted channel. | halt } 
}

;Join
on syscon:text:!join*:*:{
  if ($2 ischan) { /notice $nick I'm already on $2 | halt }
  if ($2 !ischan) { /join $2 | /notice $nick Join attempt complete. | halt }
}

; #uranme part
on uranmepart:text:!leave_uranme:*:{
  if ($me ischan #uranme) { /part #uranme | /notice $nick Parted #uranme | halt }
  if (me !ischan #uranme) { /notice $nick I'm not on #uranme. | halt }
}

Last edited by Mpot; 23/09/07 06:10 PM.
Mpot #186508 23/09/07 06:11 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Code:
;IcyBot systems control

On syscon:Text:!*_*:*: {
  var %c = $gettok($1,1,95), %d = $gettok($1,2,95), %t = $target
  if (%c == enable) {
    if (%d == bot) { set %icybot on | msg $iif(%t ischan,$chan,$nick) IcyBot's functionality has been enabled. }
    if (%d == banners) { set %banners on | msg $iif(%t ischan,$chan,$nick) Banners have been enabled. }
    if (%d == 8ball) { set %8ball on | msg $iif(%t ischan,$chan,$nick) 8ball has been enabled. }
    if (%d == uno) { set %uno on | msg $iif(%t ischan,$chan,$nick) 8ball has been enabled. }
    if (%d == trivia) { set %trivia on | msg $iif(%t ischan,$chan,$nick) Trivia has been enabled. }
    if (%d == invite) { set %invite on | msg $iif(%t ischan,$chan,$nick) Inviting has been enabled. }
    if (%d == huggle) { set %huggle on | msg $iif(%t ischan,$chan,$nick) Huggling has been enabled. }
    if (%d == misc) { set %misc on | msg $iif(%t ischan,$chan,$nick) Miscellaneous features have been enabled. }
    if (%d == timebomb) { set %timebomb on | msg $iif(%t ischan,$chan,$nick) Timebomb has been enabled. }
    if (%d == greet) { set %greet on | msg $iif(%t ischan,$chan,$nick) Greet notices has been enabled. }
    if (%d == rules) { set %rules on | msg $iif(%t ischan,$chan,$nick) Rules have been enabled. }
    if (%d == bannermaker) { set %bannermaker on | msg $iif(%t ischan,$chan,$nick) Banner making has been enabled. }
    if (%d == helpsys) { set %helpsys on | msg $iif(%t ischan,$chan,$nick) Help System has been enabled. }
    write op_log.txt At $time(HH:nn:ss) $nick used enable command for %d in $iif(%t ischan,$chan,in private message)
  }
  if (%c == disable) {
    if (%d == bot) { set %icybot off | msg $iif(%t ischan,$chan,$nick) IcyBot's functionality has been disabled. }
    if (%d == banners) { set %banners off | msg $iif(%t ischan,$chan,$nick) Banners have been disabled. }
    if (%d == 8ball) { set %8ball off | msg $iif(%t ischan,$chan,$nick) 8ball has been disabled. }
    if (%d == uno) { set %uno off | msg $iif(%t ischan,$chan,$nick) 8ball has been disabled. }
    if (%d == trivia) { set %trivia off | msg $iif(%t ischan,$chan,$nick) Trivia has been disabled. }
    if (%d == invite) { set %invite off | msg $iif(%t ischan,$chan,$nick) Inviting has been disabled. }
    if (%d == huggle) { set %huggle off | msg $iif(%t ischan,$chan,$nick) Huggling has been disabled. }
    if (%d == misc) { set %misc off | msg $iif(%t ischan,$chan,$nick) Miscellaneous features have been disabled. }
    if (%d == timebomb) { set %timebomb off | msg $iif(%t ischan,$chan,$nick) Timebomb has been disabled. }
    if (%d == greet) { set %greet off | msg $iif(%t ischan,$chan,$nick) Greet notices has been disabled. }
    if (%d == rules) { set %rules off | msg $iif(%t ischan,$chan,$nick) Rules have been disabled. }
    if (%d == bannermaker) { set %bannermaker off | msg $iif(%t ischan,$chan,$nick) Banner making has been disabled. }
    if (%d == helpsys) { set %helpsys off | msg $iif(%t ischan,$chan,$nick) Help System has been disabled. }
    write op_log.txt At $time(HH:nn:ss) $nick used disable command for %d in $iif(%t ischan,$chan,in private message)
  }
}


I tried to clean the code up a little, it can be improved more but I was just rushing.

It's untested, but I think it should work.

Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
It would be a bit easier for me to just insert a line into some of the on texts. Would I be able to use for the channel on texts

/write C:\IcyBot2\Scripts\op_log.txt $nick used $$1 on $chan at $time(HH:nn:ss)

and

/write C:\IcyBot2\Scripts\op_log.txt $nick used $$1 on via private msg at $time(HH:nn:ss)

?


EDIT: How can I put in the date, too?

Last edited by Mpot; 23/09/07 06:37 PM.
Mpot #186531 23/09/07 06:57 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
/help $date

Sorry for the vague reply, but it's fairly simple.

Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
/write C:\IcyBot2\Scripts\op_log.txt $date(mmm,d,yy) $+ at $time(h,n,s,TT) $+ : $nick used $$1 on $chan | halt

" * Invalid parameters: $date "

What in God's name? -_________-;

Mpot #186537 23/09/07 07:06 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
commas are used to separate $identifier arguments, so the script parser thinks you're passing 3 arguments to $date: "mmm", "d" and "yy", rather than just one: "mmm,d,yy", to fix this set the format to a variable first:

Code:
var %dateformat = mmm,d,yy, %timeformat = h,n,s,TT
echo -a $date(%dateformat) $time(%timeformat)

hixxy #186540 23/09/07 07:08 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
That shouldn't be so, according to the help file on Time and Date Identifiers.


Last edited by Mpot; 23/09/07 07:15 PM.
Mpot #186543 23/09/07 07:12 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
That shouldn't be so? How not?

$date(dd/mm/yy) is perfectly fine, but $date(dd,mm,yy) is not because , is used to separate arguments in identifiers, so you're passing it 3 different arguments when it only takes one! - a date format.

hixxy #186544 23/09/07 07:15 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
I don't want arguments, I want a date format, and according to that help file, using commas is appropriate. See edit to earlier post, screenshot of file included.

Last edited by Mpot; 23/09/07 07:16 PM.
Mpot #186549 23/09/07 07:24 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
It doesn't say that commas are appropriate anywhere on that page, unless you're talking about the comma in $asctime() which does take two arguments.

Mpot #186551 23/09/07 07:26 PM
Joined: Dec 2002
Posts: 2,033
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,033
Just use $date($+(mmm,$chr(44),d,$chr(44),yy)) ?

RoCk #186554 23/09/07 07:41 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
Alright, then why is it working fine with $time but not with $date?

Mpot #186555 23/09/07 07:48 PM
Joined: Apr 2007
Posts: 228
M
Mpot Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2007
Posts: 228
Blargh, what can I put in this line

/write C:\IcyBot2\Scripts\op_log.txt $time(h,n,s,TT) on $date(mmm,d,yy) $+ : $nick used $$1 on $chan

To make the date and time work properly? I tried changing it to $time first instead of $date first, no good. Just got $time errors. The format I'd like for the time and date can be seen in that line.

Mpot #186559 23/09/07 08:11 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
I told you that earlier.

Code:
var %dateformat = mmm,d,yy, %timeformat = h,n,s,TT
echo -a $date(%dateformat) $time(%timeformat)

Page 1 of 4 1 2 3 4

Link Copied to Clipboard