eggdrop icon indicating copy to clipboard operation
eggdrop copied to clipboard

botonchan errors if channel record missing

Open vanosg opened this issue 4 years ago • 6 comments

Found by: Nikopol

    #foo        :   2 members, enforcing "+tn"
    #bar       :   1 member, enforcing "+tn"
.tcl botonchan #goo
Tcl error: illegal channel: #goo

Would it be worth considering making botonchan return a -1, instead of an error in this case? I think such a change could still be considered backwards compatible. In any case, docs should be updated to reflect the requirement to use a channel with a valid channel record for it

vanosg avatar Mar 06 '20 21:03 vanosg

Yes, it would follow the logic as it exists for :

getchanidle <nickname> <channel>
Returns: number of minutes that person has been idle; -1 if the specified user isn't on the channel

Module: irc

hand2idx <handle>
Returns: the idx (a number greater than or equal to zero) for the user given if the user is on the party line in chat mode (even if she is currently on a channel or in chat off), the file area, or in the control of a script. -1 is returned if no idx is found. If the user is on multiple times, the oldest idx is returned.

Module: core

notes <user> [numberlist]
Returns: -1 if no such user, -2 if notefile failure. If a numberlist is not specified, the number of notes stored for the user is returned. Otherwise, a list of sublists containing information about notes stored for the user is returned. Each sublist is in the format of:

{<from> <timestamp> <note text>}
Module: notes
erasenotes <user> <numberlist>
Description: erases some or all stored notes for a user. Use '-' to erase all notes.

Returns: -1 if no such user, -2 if notefile failure, 0 if no such note, or number of erased notes.

Module: notes
listnotes <user> <numberlist>
Description: lists existing notes according to the numberlist (ex: "2-4;8;16-")

Returns: -1 if no such user, -2 if notefile failure, 0 if no such note, list of existing notes.

Module: notes

etc ...

ZarTek-Creole avatar Oct 02 '20 13:10 ZarTek-Creole

The counter-examples are onchan/isop/isvoice/... all the channel related commands need [validchan $text] && [... $text] for user-input channel names that could be invalid

thommey avatar Nov 01 '20 15:11 thommey

I follow @thommey in this: keep consistency with same themed functions. So either leave it be, or change them all. I don't see how this would be backward compatible though as you go from TCL_ERROR to TCL_OK?

Cizzle avatar Jan 17 '21 23:01 Cizzle

I think we would still leave it as TCL_ERROR, but return a -1 instead of a text string so that you could use something like (if botonchan < 1) to aid scripts (if such a change were to be made)

vanosg avatar Jan 18 '21 02:01 vanosg

You can't use it like that, TCL_ERROR is a hard error that aborts the script unless it's specifically in a [catch] block which defeats the purpose of returning -1. This would be highly inconsistent with all our other commands.

I vote to close this as NOTABUG because any change breaks backwards compatibility and consistency, and this is documented behavior.

Tcl core commands also raise errors on invalid input (non-existing file, etc.)

thommey avatar Jan 18 '21 08:01 thommey

Is this documented?

botonchan [channel]

  Returns: 1 if the bot is on the specified channel (or any channel if
  no channel is specified); 0 otherwise

Cizzle avatar Jan 18 '21 09:01 Cizzle