This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Determining the bot's own current nick?

Help for those learning Tcl or writing their own scripts.
Post Reply
l
level6
Voice
Posts: 6
Joined: Tue Mar 07, 2017 8:02 am
Location: DALLAS, TX, USA
Contact:

Determining the bot's own current nick?

Post by level6 »

Hi. New here, but have been using eggdrop since the 90s.

Is there any [built-in] way to determine the eggdrop bot's own nick at any given time?

What I really want is to allow it to become self-aware of its own attributes via getuser with the BOTFL, but those functions appear to be dependent on nick. If there is any way to get "my own" attributes on each bot, that would work, too.

My end game is to be able to write and distribute a single script for all bots on a botnet, then have leaf bots behave differently than hub bots using code in that script. I am just getting tired of maintaining two scripts for every thing (one for hubs, one for leaves). So, if I am missing some other obvious way to do this, please let me know.

Thanks!

Raymond.
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

Have you checked the ~/eggdrop/doc/tcl-commands.doc file?

The built-in method would be the $botnick variable. You can return your own handle with [matchattr [nick2hand $nick]] and your attributes using [chattr [nick2hand $nick] $chan]
Last edited by Get_A_Fix on Tue Mar 07, 2017 8:31 pm, edited 1 time in total.
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
l
level6
Voice
Posts: 6
Joined: Tue Mar 07, 2017 8:02 am
Location: DALLAS, TX, USA
Contact:

Post by level6 »

I did. But, the names of things are a little scattered and it makes it difficult to search. I was looking for "my" and "is". Coulda sworn I searched for "bot"... but now I feel dumb.

Thank you! That is exactly what I was looking for. You rock.
w
willyw
Revered One
Posts: 1197
Joined: Thu Jan 15, 2009 12:55 am

Re: Determining the bot's own current nick?

Post by willyw »

level6 wrote:Hi. New here, ...
Welcome.
Is there any [built-in] way to determine the eggdrop bot's own nick at any given time?
Wouldn't that be the global variable, botnick ?

http://www.eggheads.org/support/egghtml ... l#globvars


What I really want is to allow it to become self-aware of its own attributes via getuser with the BOTFL, but those functions appear to be dependent on nick. If there is any way to get "my own" attributes on each bot, that would work, too.
I think that I'm not understanding you.

Attributes are flags saved in an account on a bot. It seems like to do what you want, the bot would have to have an account on itself.

Why would the bot have itself in it's .user file?

My end game is to be able to write and distribute a single script for all bots on a botnet, then have leaf bots behave differently than hub bots using code in that script. I am just getting tired of maintaining two scripts for every thing (one for hubs, one for leaves). So, if I am missing some other obvious way to do this, please let me know.
What would trigger the behavior to which they would react differently?

If you don't care if others see your script(s), you might get more results if you posted them here with the /

Code: Select all

[code/]
/[/code/] tags.

Or:
http://paste.tclhelp.net/
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
l
level6
Voice
Posts: 6
Joined: Tue Mar 07, 2017 8:02 am
Location: DALLAS, TX, USA
Contact:

Post by level6 »

I was hoping to trigger that on the "h"ub vs. "l"eaf bot flags. I am seeing your point, now, though. If the bot currently running the script is not in users, then there will be no attributes to get. Bleh.

I was going for something like this:

Code: Select all

# not going to work...
set bothandle [nick2hand $botnick]

if {[set nfo [getuser $bothandle BOTFL]] != "" && [string match "*h*" $nfo]} {
 set ismaster=1
} else {
        set ismaster=0
       }

if {$ismaster}
{
 bind pub - .attack botnet_fruitattack_pub
 bind dcc - attack botnet_fruitattack
 putlog "Botnet Fruit Attacker v1.0 Loaded as MASTER!"
} else {
        bind bot - attack botnet_fruitattack
        putlog "Botnet Fruit Attacker v1.0 Loaded as SLAVE!"
       }

Then, in the procs:

Code: Select all

.
.
  if {$ismaster} {
    putlog "MASTER $botnick - Sending orders to all bots to Fruit Attack!"
    putallbots "attack $whotoattack $chan"
    dccbroadcast "MASTER $botnick - Command accepted.  I will $how $whotoattack with $what!"
    dccbroadcast "MASTER $botnick - Command sent to all bots!"
  } else {
          putlog "SLAVE $botnick - Command accepted.  I will $how $whotoattack with $what!"
          dccbroadcast "SLAVE $botnick - Command accepted.  I will $how $whotoattack with $what!"
         }

  putserv "PRIVMSG $chan : -=( $how $whotoattack with $what )=-"
.
.
I think I will just have to hardcode my own global assigning ismaster or isslave in a separate script on each bot and consider that part of the initial set-up. Then I could use that for the rest of my scripts.

Mostly, I just need to separate the binds and the putallbots so that the same script can be transferred across all bots.

Or, is this all just crazy talk? :)
l
level6
Voice
Posts: 6
Joined: Tue Mar 07, 2017 8:02 am
Location: DALLAS, TX, USA
Contact:

Post by level6 »

Bad TCL, for sure. Frankly, I struggle with TCL. But, that's neither here nor there.

So, this is what worked:

1) Either in your eggdrop,conf or in a separate script (botcfg.tcl or something) you load via eggdrop.conf:

Code: Select all

set ismaster 1
Change that to 0 on the slave bots, of course.

2) Then, in the script that is being .netupdate'd around, shared by all bots:

Code: Select all

proc botnet_fruitattack_pub {nick uhost handle chan argv} {
.
.
  global ismaster
  global botnick
.
.
  if { $ismaster == 1 } {
    putlog "MASTER $botnick - Sending orders to all bots to Fruit Attack!"
    putallbots "attack $whotoattack $chan"
    dccbroadcast "MASTER $botnick - Command accepted.  I will $how $whotoattack with $what!"
    dccbroadcast "MASTER $botnick - Command sent to all bots!"
  } else {
          putlog "SLAVE $botnick - Command accepted.  I will $how $whotoattack with $what!"
          dccbroadcast "SLAVE $botnick - Command accepted.  I will $how $whotoattack with $what!"
         }

  putserv "PRIVMSG $chan : -=( $how $whotoattack with $what )=-"
.
.
And, the dependent binds:

Code: Select all

if {$ismaster == 1} {
 bind pub - .attack botnet_fruitattack_pub
 bind dcc - attack botnet_fruitattack
 putlog "Botnet Fruit Attacker v1.0 Loaded as MASTER!"
} else {
        bind bot - attack botnet_fruitattack
        putlog "Botnet Fruit Attacker v1.0 Loaded as SLAVE!"
       }
Now, the botnet'ed bots will behave differently, using the same script.

Again, if you notice something screwy about my TCL code, sorry. I struggle with it. It's not that I hate it - TCL has its place.

Anyway, you guys really did help. Thanks.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

I can tell you that it is completely possible to add the bots own handle and attributes to its own user file.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
l
level6
Voice
Posts: 6
Joined: Tue Mar 07, 2017 8:02 am
Location: DALLAS, TX, USA
Contact:

Post by level6 »

Thanks, SpiKe^^. If I need more precision or granularity (maybe using the flags) it's great to know there is another possibility. But, for now, all my slave bots are equal and there is only one master, so this solution will work for me.

Code: Select all

[08:28:26] MASTER liar - Sending orders to all bots to Fruit Attack!
*** MASTER liar - Command accepted.  I will stabs tda with a basket of peaches!
*** MASTER liar - Command sent to all bots!
*** (liar_botnet_1) SLAVE liar_botnet_1 - Command accepted.  I will teabags tda with passion fruits!
*** (liar_botnet_2) SLAVE liar_botnet_2 - Command accepted.  I will pummels tda with bananas!
Perfect.
l
level6
Voice
Posts: 6
Joined: Tue Mar 07, 2017 8:02 am
Location: DALLAS, TX, USA
Contact:

Post by level6 »

Full script, in case anyone finds it useful... again, please excuse any sloppy TCL.

botnet_fruitattack_1.0.tcl:

Code: Select all

proc botnet_fruitattack_pub {nick uhost handle chan argv} {

  if {[regexp {[\{]} $argv]>0} {
    putserv "NOTICE $chan :ERROR\: OK!   Dumping my /etc/shadow file ...  please wait."
    return 0
  }
  if {[regexp {[\}]} $argv]>0} {
    putserv "NOTICE $chan :ERROR\: OK!   Dumping my /etc/shadow file ...  please wait."
    return 0
  }
  if {[regexp {[\']} $argv]>0} {
    putserv "NOTICE $chan :ERROR\: OK!   Dumping my /etc/shadow file ...  please wait."
    return 0
  }
  if {[regexp {[\"]} $argv]>0} {
    putserv "NOTICE $chan :ERROR\: OK!   Dumping my /etc/shadow file ...  please wait."
    return 0
  }
  if {[regexp {[\!]} $argv]>0} {
    putserv "NOTICE $chan :ERROR\: OK!   Dumping my /etc/shadow file ...  please wait."
    return 0
  }
  if {[regexp {[\`]} $argv]>0} {
    putserv "NOTICE $chan :ERROR\: OK!   Dumping my /etc/shadow file ...  please wait."
    return 0
  }

  set whotoattack [lindex $argv 0]

  global ismaster
  global botnick

  set verb {
  "rapes"
  "makes passionate love to"
  "pummels"
  "stabs"
  "plays hide-the-fruit with"
  "teabags"
  "socks the [censored] outta"
  "replaces the existance of"
  "shoots laser beams at"
  "makes emo poetry at"
  }

  set fruit {
  "apples"
  "bananas"
  "oranges"
  "mangos"
  "pinnapples"
  "pears"
  "passion fruits"
  "a bunch of grapes"
  "a bag of plums"
  "a basket of peaches"
  }

  if {$whotoattack == ""} {
    putserv "NOTICE $chan :ERROR\: Please supply a nick to attack. derp."
    return 0
  }

  if {$whotoattack == "spin"} {
    putserv "NOTICE $chan :ERROR\: Nawp.  Ain't gunna do eet.  derp."
    return 0
  }

  if {![onchan $whotoattack $chan]} {
    putserv "NOTICE $chan :ERROR\: No such person here, dummay."
    return 0
  }

  set how [lindex $verb [rand [llength $verb]]]
  set what [lindex $fruit [rand [llength $fruit]]]

  if { $ismaster == 1 } {
    putlog "MASTER $botnick - Sending orders to all bots to Fruit Attack!"
    putallbots "attack $whotoattack $chan"
    dccbroadcast "MASTER $botnick - Command accepted.  I will $how $whotoattack with $what!"
    dccbroadcast "MASTER $botnick - Command sent to all bots!"
  } else {
          putlog "SLAVE $botnick - Command accepted.  I will $how $whotoattack with $what!"
          dccbroadcast "SLAVE $botnick - Command accepted.  I will $how $whotoattack with $what!"
         }

  putserv "PRIVMSG $chan : -=( $how $whotoattack with $what )=-"

  return 1
}

proc botnet_fruitattack {handle idx argv} {

  if {[regexp {[\{]} $argv]>0} {
    putserv "NOTICE $chan :ERROR\: OK!   Dumping my /etc/shadow file ...  please wait."
    return 0
  }
  if {[regexp {[\}]} $argv]>0} {
    putserv "NOTICE $chan :ERROR\: OK!   Dumping my /etc/shadow file ...  please wait."
    return 0
  }
  if {[regexp {[\']} $argv]>0} {
    putserv "NOTICE $chan :ERROR\: OK!   Dumping my /etc/shadow file ...  please wait."
    return 0
  }
  if {[regexp {[\"]} $argv]>0} {
    putserv "NOTICE $chan :ERROR\: OK!   Dumping my /etc/shadow file ...  please wait."
    return 0
  }
  if {[regexp {[\!]} $argv]>0} {
    putserv "NOTICE $chan :ERROR\: OK!   Dumping my /etc/shadow file ...  please wait."
    return 0
  }
  if {[regexp {[\`]} $argv]>0} {
    putserv "NOTICE $chan :ERROR\: OK!   Dumping my /etc/shadow file ...  please wait."
    return 0
  }

  set whotoattack [lindex $argv 0]
  set chan "#LIEnet"

  global ismaster
  global botnick

  set verb {
  "rapes"
  "makes passionate love to"
  "pummels"
  "stabs"
  "plays hide-the-fruit with"
  "teabags"
  "socks the [censored] outta"
  }

  set fruit {
  "apples"
  "bananas"
  "oranges"
  "mangos"
  "pinnapples"
  "pears"
  "passion fruits"
  "grapes"
  }

  if {$whotoattack == ""} {
    putserv "NOTICE $chan :ERROR\: Please supply a nick to attack. derp."
    return 0
  }

  set how [lindex $verb [rand [llength $verb]]]
  set what [lindex $fruit [rand [llength $fruit]]]

  if { $ismaster == 1 } {
    putlog "MASTER $botnick - Sending orders to all bots to Fruit Attack!"
    putallbots "attack $whotoattack $chan"
    dccbroadcast "MASTER $botnick - Command accepted.  I will $how $whotoattack with $what!"
    dccbroadcast "MASTER $botnick - Command sent to all bots!"
  } else {
          putlog "SLAVE $botnick - Command accepted.  I will $how $whotoattack with $what!"
          dccbroadcast "SLAVE $botnick - Command accepted.  I will $how $whotoattack with $what!"
         }

  putserv "PRIVMSG $chan : -=( $how $whotoattack with $what )=-"

  return 1
}

if {$ismaster == 1} {
 bind pub - .attack botnet_fruitattack_pub
 bind dcc - attack botnet_fruitattack
 putlog "Botnet Fruit Attacker v1.0 Loaded as MASTER!"
} else {
        bind bot - attack botnet_fruitattack
        putlog "Botnet Fruit Attacker v1.0 Loaded as SLAVE!"
       }
Some things I know could use more dev:
1) I had to hardcode a channel in to get the DCC to work. Need to add an option to direct it to any channel, then make sure they are all on it, etc.. DCC bound commands do not include channel, of course.
2) There is probably a much easier one-liner to regexp for cleaning the input, but I had enough trouble finding how to just get "{" to match, so I was happy to make a lot of separate statements. Maybe this would work?:

if {[regexp {[\{\}\"\!\`\]} $argv]>0} {

There is probably a lot more "wrong" with it. Use at your own peril. But, it works.
Post Reply