2016-05-18 17:12:46 +00:00
from objects import glob
from constants import clientPackets
from constants import serverPackets
from helpers import userHelper
2016-06-04 10:44:54 +00:00
from helpers import logHelper as log
2016-06-15 09:49:06 +00:00
from constants import actions
2016-04-19 17:40:59 +00:00
def handle ( userToken , packetData ) :
# Get usertoken data
userID = userToken . userID
username = userToken . username
2016-05-04 21:41:33 +00:00
# Make sure we are not banned
if userHelper . getAllowed ( userID ) == 0 :
userToken . enqueue ( serverPackets . loginBanned ( ) )
return
2016-04-19 17:40:59 +00:00
# Change action packet
packetData = clientPackets . userActionChange ( packetData )
# Update our action id, text and md5
userToken . actionID = packetData [ " actionID " ]
userToken . actionText = packetData [ " actionText " ]
userToken . actionMd5 = packetData [ " actionMd5 " ]
userToken . actionMods = packetData [ " actionMods " ]
userToken . gameMode = packetData [ " gameMode " ]
2016-06-15 09:49:06 +00:00
# Send osu!direct alert if needed
# NOTE: Remove this when osu!direct will be fixed
if userToken . actionID == actions . osuDirect and userToken . osuDirectAlert == False :
userToken . osuDirectAlert = True
userToken . enqueue ( serverPackets . sendMessage ( " FokaBot " , userToken . username , " Sup! osu!direct works, kinda. To download a beatmap, you have to click the \" View listing \" button (the last one) instead of \" Download \" . However, if you are on the stable (fallback) branch, it should work also with the \" Download \" button. We ' ll fix that bug as soon as possibleTM. " ) )
2016-04-19 17:40:59 +00:00
# Enqueue our new user panel and stats to everyone
glob . tokens . enqueueAll ( serverPackets . userPanel ( userID ) )
glob . tokens . enqueueAll ( serverPackets . userStats ( userID ) )
# Console output
2016-06-04 10:44:54 +00:00
log . info ( " {} changed action: {} [ {} ][ {} ] " . format ( username , str ( userToken . actionID ) , userToken . actionText , userToken . actionMd5 ) )