Well, assuming your bot is on the specified channel to be checked then you can insert this if statement to your code:
if ([color:red]nick-identifier[/color] ison [color:red]#channel[/color]) {
[color:red]Execute some commands here[/color]
}
Replace
nick-identifier with whatever is identifying the nick. Since you didn't specify, I will not assume it's $nick.
Replace
#channel with the channel to be checked