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.

Script executes on one bot but not on the other

Help for those learning Tcl or writing their own scripts.
Post Reply
m
mrNobody
Voice
Posts: 14
Joined: Mon Dec 02, 2013 4:49 am

Script executes on one bot but not on the other

Post by mrNobody »

Hi all,

I wrote a very simple script to set a mode to my channels. I have a production bot and a testbot on the same network. The testbot runs the script without any problems, but the production bot doesn't trigger it at all. I checked with .binds that the command is bound, and with .whois that I have the nescesarry flags.

this is the script:

Code: Select all

bind pub (m) !set mcm:set

proc mcm:set {nick host handle chan args} {
	set script [lindex [join $args] 0]
	set what [lindex [join $args] 1]
	if {$what == ""} {
		putserv "NOTICE $nick :Error. No settings specified. Use !set <script> <on|off>"
		return
	} elseif { $what == "on"} {
		set what "+"
		set notice "enabled"
	} else {
		set what "-"
		set notice "disabled"
	}
	channel set $chan $what$script
	puthelp "PRIVMSG $chan :$script $notice"
}
on testbot it runs as it is supposed to.
on productionbot it doesn't even trigger the command.
I'm owner of both bots, the command shows in both .binds commands but it only gets triggered on testbot.
Oh yeah, I also restarted the productionbot, didn't do the trick either.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Give this a try.

Code: Select all

bind pub m|m !set mcm:set

proc mcm:set {nick host handle chan text} {
	if {[scan $text {%s%s} script mode] != 2} {
		puthelp "NOTICE $nick :Error, no settings specified. Use !set <script> <on|off>"
	}
	catch {channel get $chan $script} err
	if {$err!=0} {
		puthelp "NOTICE $nick :Error, the $script setting doesn't exist!"
		return
	}
	switch -- [string tolower $mode] {
		"on" {
			if {[channel get $chan $script]} {
				puthelp "NOTICE $nick :Error, the $script setting is already enabled."
			} else {
				channel set $chan +$script
				puthelp "NOTICE $nick :The $script setting has been disabled."
			}
		}
		"off" {
			if {![channel get $chan $script]} {
				puthelp "NOTICE $nick :Error, the $script setting is already disabled."
			} else {
				channel set $chan -$script
				puthelp "NOTICE $nick :The $script setting has been disabled."
			}			
		}
	}
} 
Haven't tested so load it on test bot and see if it works. Reply back if you got any issues.
Once the game is over, the king and the pawn go back in the same box.
m
mrNobody
Voice
Posts: 14
Joined: Mon Dec 02, 2013 4:49 am

Post by mrNobody »

it returns error code 1

//edit:
If I remove the part that catches the error code it works on testbot

//edit2:
If I load it on the production bot, just like my own code, it doesn't execute.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

What versions of eggdrop and TCL you got there?
Once the game is over, the king and the pawn go back in the same box.
m
mrNobody
Voice
Posts: 14
Joined: Mon Dec 02, 2013 4:49 am

Post by mrNobody »

eggdrop 1.6.21, tcl version 8.5.11
It runs on a raspberry pi with debian linux. Both bots run on the same machine with virtually the same config file.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Where do you see that error code 1?
Once the game is over, the king and the pawn go back in the same box.
m
mrNobody
Voice
Posts: 14
Joined: Mon Dec 02, 2013 4:49 am

Post by mrNobody »

I made it putlog $err
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

And you don't get any notice from the bot with that error?
Once the game is over, the king and the pawn go back in the same box.
m
mrNobody
Voice
Posts: 14
Joined: Mon Dec 02, 2013 4:49 am

Post by mrNobody »

no, the bot stays otherwise silent
m
mrNobody
Voice
Posts: 14
Joined: Mon Dec 02, 2013 4:49 am

Post by mrNobody »

I found what was causing this problem, apparently my production bot had the wrong hostname for my user, so it didn't trigger the script. updated the hostname and now it works as it should, thanks for your help though!
Post Reply