Skip to content

Commit

Permalink
Modify greet.py to be reload-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
thommey committed Oct 6, 2024
1 parent 28b1662 commit 4ea883d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/mod/python.mod/scripts/greet.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ def joinGreetUser(nick, host, handle, channel, **kwargs):
def joinGreetOp(nick, host, handle, channel, **kwargs):
putmsg(channel, f"{nick} is an operator on this channel!")

if 'GREET_BINDS' in globals():
for greetbind in GREET_BINDS:
greetbind.unbind()
del GREET_BINDS

GREET_BINDS = list()
# Call binds at the end of the script, not the top- the functions must be defined!
bind("join", "*", "*", joinGreetUser)
GREET_BINDS.append(bind("join", "*", "*", joinGreetUser))
# Again, arguments are separated with a comma. This bind requires the 'o' flag to be triggered.
bind("join", "o", "*", joinGreetOp)
GREET_BINDS.append(bind("join", "o", "*", joinGreetOp))

print('Loaded greet.py')

0 comments on commit 4ea883d

Please sign in to comment.