From 119e3a251f52ac3de10827c2e628ce660c392bca Mon Sep 17 00:00:00 2001 From: Julian Marcos Date: Sun, 27 Oct 2024 11:11:14 +0000 Subject: [PATCH] Implement support for users instead of nicks --- plugins/tilde.py | 18 ++++++++++++++---- requirements.txt | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/tilde.py b/plugins/tilde.py index 702dab2..283ee3b 100644 --- a/plugins/tilde.py +++ b/plugins/tilde.py @@ -20,17 +20,23 @@ def tilde_plugin(msg): return if msg.channel != util.tilde.GOOD_CHAN and not util.tilde.DEBUG: return pinhook.plugin.message("{} is a meanie and gets no tildes. **ju only gives out tildes in the {} channel.**".format(msg.nick, util.tilde.GOOD_CHAN)) - if msg.nick not in util.tilde.challenges: - challenge = util.tilde.challenge(msg.channel, msg.nick, msg.timestamp) + user_nick = msg.nick + if util.tilde.use_ident(msg.nick, msg.user): + user_nick = msg.user + if user_nick not in util.tilde.challenges: + challenge = util.tilde.challenge(msg.channel, user_nick, msg.timestamp) return pinhook.plugin.message(challenge) @pinhook.plugin.listener('tilde_guess') def tilde_guess_plugin(msg): if util.tilde.ADMIN_ONLY and msg.nick not in msg.ops: return - if msg.nick in util.tilde.challenges and (msg.channel == util.tilde.GOOD_CHAN or util.tilde.DEBUG) and not msg.text.startswith('!'): + user_nick = msg.nick + if util.tilde.use_ident(msg.nick, msg.user): + user_nick = msg.user + if user_nick in util.tilde.challenges and (msg.channel == util.tilde.GOOD_CHAN or util.tilde.DEBUG) and not msg.text.startswith('!'): try: - chalres = util.tilde.challenge_response(msg.nick, msg.timestamp, msg.text) + chalres = util.tilde.challenge_response(user_nick, msg.timestamp, msg.text) print(chalres) resp = pinhook.plugin.message(str(chalres[0])) return resp @@ -38,3 +44,7 @@ def tilde_guess_plugin(msg): print(traceback.format_exc()) return pinhook.plugin.message(str(e)) +@pinhook.plugin.command('&tildeident', help_text='Use your ident instead of your nickname or the inverse') +def tilde_plugin(msg): + response = util.tilde.modify_ident(msg.nick, msg.user) + return pinhook.plugin.message(response) diff --git a/requirements.txt b/requirements.txt index ec85b7a..01b63d0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ emoji~=0.4.5 geopy~=1.11.0 markovify~=0.7.1 nltk>~3.4.5 -pinhook~=1.10 +pinhook~=1.10.1 python-forecastio~=1.3.5 requests>~2.20.0 tvdb-api~=1.10