eggheads / eggdrop

The Eggdrop IRC Bot
GNU General Public License v2.0
494 stars 88 forks source link

Add dir(eggdrop.tcl) #1596

Open michaelortmann opened 1 month ago

michaelortmann commented 1 month ago

Found by: (thommey or vanosg, asthere was a TODO comment i picked up) Patch by: michaelortmann Fixes:

One-line summary: Add dir(eggdrop.tcl)

Additional description (if needed):

Test cases demonstrating functionality (if applicable): Before:

.load python
.py print(dir(eggdrop.tcl))
[00:56:10] tcl: builtin dcc call: *dcc:python -HQ 1 print(dir(eggdrop.tcl))
['__doc__', '__getattr__', '__loader__', '__name__', '__package__', '__spec__']
Python: None

After:

.load python
.py print(dir(eggdrop.tcl))
[00:51:42] tcl: builtin dcc call: *dcc:python -HQ 1 print(dir(eggdrop.tcl))
['a2t_ascii2text', 'account2nicks', 'accounttracking', 'addbot', 'addchanrec', 'addlang', 'addlangsection', 'adduser', 'after', 'append', 'apply', 'array', 'auto_execok', 'auto_import', 'auto_load', 'auto_load_index', 'auto_qualify', 'backup', 'banlist', 'binary', 'bind', 'binds', 'boot', 'botattr', 'botishalfop', 'botisop', 'botisvoice', 'botlist', 'botonchan', 'bots', 'break', 'callevent', 'cap', 'case', 'catch', 'cd', 'chan', 'chanbans', 'chandname2name', 'chanexempts', 'chaninvites', 'chanlist', 'channame2dname', 'channel', 'channels', 'chansettype', 'chattr', 'checkmodule', 'chhandle', 'chnick', 'cleanarg', 'clearqueue', 'clock', 'close', 'compressfile', 'concat', 'connect', 'console', 'continue', 'control', 'coroutine', 'countusers', 'cp', 'ctime', 'dcc_chuserinfo', 'dcc_setuserinfo', 'dccbroadcast', 'dccdumpfile', 'dcclist', 'dccputchan', 'dccsend', 'dccsimul', 'dccused', 'delchanrec', 'delhost', 'dellang', 'dellangsection', 'deludef', 'deluser', 'dict', 'die', 'dnslookup', 'dumpfile', 'duration', 'echo', 'egg_string_tolower', 'egg_string_totitle', 'egg_string_toupper', 'encoding', 'encpass2', 'eof', 'erasenotes', 'error', 'eval', 'exec', 'exemptlist', 'exit', 'expr', 'fblocked', 'fconfigure', 'fcopy', 'file', 'fileevent', 'fileresend', 'filesend', 'finduser', 'flush', 'flushmode', 'for', 'foreach', 'format', 'getaccount', 'getchan', 'getchanhost', 'getchanidle', 'getchaninfo', 'getchanjoin', 'getchanmode', 'getdccaway', 'getdccidle', 'getdesc', 'getdirs', 'getfileq', 'getfiles', 'getfilesendtime', 'getflags', 'getgots', 'getlink', 'getowner', 'getpwd', 'gets', 'getting-users', 'getudefs', 'getuser', 'glob', 'global', 'hand2idx', 'hand2nick', 'hand2nicks', 'handonchan', 'haschanrec', 'hide', 'idx2hand', 'if', 'ignorelist', 'inchain', 'incr', 'info', 'init_dccwhois', 'interp', 'invitelist', 'isaway', 'isban', 'isbansticky', 'isbotnick', 'ischanban', 'ischanexempt', 'ischaninvite', 'ischanjuped', 'iscommand', 'iscompressed', 'isdynamic', 'isexempt', 'isexemptsticky', 'ishalfop', 'isidentified', 'isignore', 'isinvite', 'isinvitesticky', 'isircbot', 'islinked', 'isnumber', 'iso', 'isop', 'ispermban', 'ispermexempt', 'isperminvite', 'ispermowner', 'istls', 'isupport', 'isvoice', 'join', 'jump', 'killban', 'killchanban', 'killchanexempt', 'killchaninvite', 'killdcc', 'killdccall', 'killdccbut', 'killexempt', 'killignore', 'killinvite', 'killtimer', 'killutimer', 'language', 'lappend', 'lassign', 'lindex', 'link', 'linsert', 'list', 'listen', 'listnotes', 'llength', 'lmap', 'load', 'loadchannels', 'loadhelp', 'loadmodule', 'logfile', 'lrange', 'lrepeat', 'lreplace', 'lreverse', 'lsearch', 'lset', 'lsort', 'maskhost', 'matchaddr', 'matchattr', 'matchban', 'matchbotattr', 'matchbotattrany', 'matchchanattr', 'matchcidr', 'matchexempt', 'matchinvite', 'matchstr', 'md5', 'mkdir', 'modules', 'monitor', 'msg_setuserinfo', 'mv', 'myip', 'namespace', 'newban', 'newchanban', 'newchanexempt', 'newchaninvite', 'newexempt', 'newignore', 'newinvite', 'nick2hand', 'notes', 'number_to_number', 'onchan', 'onchansplit', 'open', 'ordnumber', 'package', 'page', 'passwdok', 'pid', 'proc', 'pushmode', 'putact', 'putallbots', 'putbot', 'putchan', 'putcmdlog', 'putdcc', 'putdccall', 'putdccbut', 'putdccraw', 'puthelp', 'putidx', 'putkick', 'putlog', 'putloglev', 'putmsg', 'putnotc', 'putnow', 'putquick', 'puts', 'putserv', 'putxferlog', 'pwd', 'pysource', 'queuesize', 'quotepong_bind', 'quotepong_servermsg', 'quotepong_unbind', 'rand', 'randstring', 'read', 'realtime', 'refreshchan', 'regexp', 'regsub', 'rehash', 'relang', 'reload', 'reloadhelp', 'rename', 'renudef', 'resetbans', 'resetchan', 'resetchanidle', 'resetchanjoin', 'resetconsole', 'resetexempts', 'resetinvites', 'restart', 'return', 'rfcequal', 'rmdir', 'save', 'savechannels', 'scan', 'seek', 'sendnote', 'server', 'set', 'setchan', 'setchaninfo', 'setdccaway', 'setdesc', 'setflags', 'setlaston', 'setlink', 'setowner', 'setpwd', 'setudef', 'setuser', 'share', 'showfields', 'socket', 'socklist', 'source', 'split', 'starttls', 'status', 'stick', 'stickban', 'stickexempt', 'stickinvite', 'storenote', 'strcmp', 'strftime', 'stricmp', 'stridx', 'string', 'strip', 'stripcodes', 'strlen', 'strlwr', 'strupr', 'subst', 'switch', 'tagmsg', 'tailcall', 'tclLog', 'tell', 'testip', 'throw', 'time', 'timer', 'timerexists', 'timers', 'tlsstatus', 'topic', 'trace', 'traffic', 'try', 'unames', 'unbind', 'uncompressfile', 'unhide', 'unixtime', 'unknown', 'unlink', 'unload', 'unloadhelp', 'unloadmodule', 'unset', 'unshare', 'unstick', 'unstickban', 'unstickexempt', 'unstickinvite', 'update', 'uplevel', 'upvar', 'userlist', 'utimer', 'utimerexists', 'utimers', 'validchan', 'valididx', 'validuser', 'variable', 'vwait', 'washalfop', 'wasop', 'while', 'whom', 'yield', 'yieldto', 'zlib']
Python: None
thommey commented 4 weeks ago

Very nice addition!

info commands is all C implemented functions and you filter them by excluding the ones with ":" in their name to hide the implicit bind functions *raw:gotjoin etc.? If that's true, the "official" way would be to hide the ones starting with *.

info procs would be all Tcl implemented functions, not sure if we want to include that or not.

michaelortmann commented 4 weeks ago

At first i had it filtered for *, but then i saw remaining : in function names. so, i switched to that, which excludes a superset compared to the set of functions starting with * for it didnt occur to me, that : is an allowed char in a function name for python top be able to call it. so i was fast filtering for : here. maybe too fast? if those funcs are callable, we could switch back to * in beginning, yeah.

regarding whichn functions exactly to include/excude: this PR aimed to be very simple. few lines of code enabling a new feature. you are free to take it from here and go the extra mile :)