Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python.mod: add dir(eggdrop.tcl) #1596

Merged
merged 4 commits into from
Aug 7, 2024
Merged

Conversation

michaelortmann
Copy link
Member

@michaelortmann michaelortmann commented May 30, 2024

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
Copy link
Member

thommey commented Jun 2, 2024

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
Copy link
Member Author

michaelortmann commented Jun 2, 2024

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 which functions exactly to include/exclude: 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 :)

@michaelortmann michaelortmann changed the title Add dir(eggdrop.tcl) python.mod: add dir(eggdrop.tcl) Jul 8, 2024
@vanosg vanosg added the Python label Jul 16, 2024
Copy link
Member

@thommey thommey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion:

Use a Python Set instead of a list (to automatically wipe duplicates), then add "info commands" and "info procs" to it, but ignore the ones starting with "*"

@michaelortmann
Copy link
Member Author

Use a Python Set instead of a list

I was using a list instead of set on purpose, because thats the default return type of dir:

https://docs.python.org/3/library/functions.html#dir

example:

>>> type(dir())
<class 'list'>

do you still want to return a set?

@thommey
Copy link
Member

thommey commented Jul 27, 2024

no, you are right, list is fine then, but it should still be [info commands] and [info procs] but without the ones starting with *

@michaelortmann
Copy link
Member Author

no, you are right, list is fine then, but it should still be [info commands] and [info procs] but without the ones starting with *

but when filtering with starting * what about remaining strings containing : like filt:dcc_action ?

@thommey
Copy link
Member

thommey commented Aug 1, 2024

Those should stay in - a lot of scripts have their commands this way too and it's not "internal" commands

Copy link
Member

@thommey thommey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great PR, thanks!

@vanosg vanosg merged commit e9aead7 into eggheads:develop Aug 7, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants