2023-06-26 15:31:30 +00:00
#!/usr/bin/python3
2023-12-15 20:50:27 +00:00
import traceback
2023-06-26 15:31:30 +00:00
import pinhook . plugin
import util . tilde
@pinhook.plugin.command ( ' &tildescore ' , help_text = ' See how many tildes you have with ju. ' )
@pinhook.plugin.command ( ' &ts ' , help_text = ' Alias -- &tildescore ' )
def tildescore_plugin ( msg ) :
return pinhook . plugin . message ( util . tilde . show_tildescore ( msg . nick ) )
@pinhook.plugin.command ( ' &jackpot ' , help_text = ' See the current jackpot. ' )
def jackpot_plugin ( msg ) :
return pinhook . plugin . message ( util . tilde . show_jackpot ( ) )
@pinhook.plugin.command ( ' !tilde ' , help_text = ' Alias -- &tilde ' )
@pinhook.plugin.command ( ' &tilde ' , help_text = ' Play the tildegame! ' )
def tilde_plugin ( msg ) :
if util . tilde . ADMIN_ONLY and msg . nick not in msg . ops :
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 ) )
2024-10-27 11:11:14 +00:00
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 )
2023-06-26 15:31:30 +00:00
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
2024-10-27 11:11:14 +00:00
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 ( ' ! ' ) :
2023-12-15 20:50:27 +00:00
try :
2024-10-27 11:11:14 +00:00
chalres = util . tilde . challenge_response ( user_nick , msg . timestamp , msg . text )
2023-12-15 20:50:27 +00:00
print ( chalres )
resp = pinhook . plugin . message ( str ( chalres [ 0 ] ) )
return resp
except Exception as e :
print ( traceback . format_exc ( ) )
return pinhook . plugin . message ( str ( e ) )
2023-06-26 15:31:30 +00:00
2024-10-27 11:11:14 +00:00
@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 )