Add !bloodcat command, automatically send bloodcat links in #spectator
This commit is contained in:
parent
925d55bb16
commit
cb6d828fd9
|
@ -20,6 +20,16 @@ from objects import glob
|
|||
from helpers import chatHelper as chat
|
||||
from common.web import cheesegull
|
||||
|
||||
|
||||
def bloodcatMessage(beatmapID):
|
||||
beatmap = glob.db.fetch("SELECT song_name, beatmapset_id FROM beatmaps WHERE beatmap_id = %s LIMIT 1", [beatmapID])
|
||||
if beatmap is None:
|
||||
return "Sorry, I'm not able to provide a download link for this map :("
|
||||
return "Download [https://bloodcat.com/osu/s/{} {}] from Bloodcat".format(
|
||||
beatmap["beatmapset_id"],
|
||||
beatmap["song_name"],
|
||||
)
|
||||
|
||||
"""
|
||||
Commands callbacks
|
||||
|
||||
|
@ -448,6 +458,15 @@ def getPPMessage(userID, just_data = False):
|
|||
|
||||
def tillerinoNp(fro, chan, message):
|
||||
try:
|
||||
# Bloodcat trigger for #spect_
|
||||
if chan.startswith("#spect_"):
|
||||
spectatorHostUserID = getSpectatorHostUserIDFromChannel(chan)
|
||||
spectatorHostToken = glob.tokens.getTokenFromUserID(spectatorHostUserID, ignoreIRC=True)
|
||||
if spectatorHostToken is None:
|
||||
return False
|
||||
print("FIFIFI " * 10, message)
|
||||
return bloodcatMessage(spectatorHostToken.beatmapID)
|
||||
|
||||
# Run the command in PM only
|
||||
if chan.startswith("#"):
|
||||
return False
|
||||
|
@ -761,18 +780,27 @@ def report(fro, chan, message):
|
|||
token.enqueue(serverPackets.notification(msg))
|
||||
return False
|
||||
|
||||
def multiplayer(fro, chan, message):
|
||||
def getMatchIDFromChannel(chan):
|
||||
if not chan.lower().startswith("#multi_"):
|
||||
raise exceptions.wrongChannelException()
|
||||
parts = chan.lower().split("_")
|
||||
if len(parts) < 2 or not parts[1].isdigit():
|
||||
raise exceptions.wrongChannelException()
|
||||
matchID = int(parts[1])
|
||||
if matchID not in glob.matches.matches:
|
||||
raise exceptions.matchNotFoundException()
|
||||
return matchID
|
||||
def getMatchIDFromChannel(chan):
|
||||
if not chan.lower().startswith("#multi_"):
|
||||
raise exceptions.wrongChannelException()
|
||||
parts = chan.lower().split("_")
|
||||
if len(parts) < 2 or not parts[1].isdigit():
|
||||
raise exceptions.wrongChannelException()
|
||||
matchID = int(parts[1])
|
||||
if matchID not in glob.matches.matches:
|
||||
raise exceptions.matchNotFoundException()
|
||||
return matchID
|
||||
|
||||
def getSpectatorHostUserIDFromChannel(chan):
|
||||
if not chan.lower().startswith("#spect_"):
|
||||
raise exceptions.wrongChannelException()
|
||||
parts = chan.lower().split("_")
|
||||
if len(parts) < 2 or not parts[1].isdigit():
|
||||
raise exceptions.wrongChannelException()
|
||||
userID = int(parts[1])
|
||||
return userID
|
||||
|
||||
def multiplayer(fro, chan, message):
|
||||
def mpMake():
|
||||
if len(message) < 2:
|
||||
raise exceptions.invalidArgumentsException("Wrong syntax: !mp make <name>")
|
||||
|
@ -1167,7 +1195,26 @@ def rtx(fro, chan, message):
|
|||
userToken.enqueue(serverPackets.rtx(message))
|
||||
return ":ok_hand:"
|
||||
|
||||
def bloodcat(fro, chan, message):
|
||||
try:
|
||||
matchID = getMatchIDFromChannel(chan)
|
||||
except exceptions.wrongChannelException:
|
||||
matchID = None
|
||||
try:
|
||||
spectatorHostUserID = getSpectatorHostUserIDFromChannel(chan)
|
||||
except exceptions.wrongChannelException:
|
||||
spectatorHostUserID = None
|
||||
|
||||
if matchID is not None:
|
||||
if matchID not in glob.matches.matches:
|
||||
return "This match doesn't seem to exist... Or does it...?"
|
||||
beatmapID = glob.matches.matches[matchID].beatmapID
|
||||
else:
|
||||
spectatorHostToken = glob.tokens.getTokenFromUserID(spectatorHostUserID, ignoreIRC=True)
|
||||
if spectatorHostToken is None:
|
||||
return "The spectator host is offline."
|
||||
beatmapID = spectatorHostToken.beatmapID
|
||||
return bloodcatMessage(beatmapID)
|
||||
|
||||
|
||||
"""
|
||||
|
@ -1319,6 +1366,9 @@ commands = [
|
|||
"privileges": privileges.ADMIN_MANAGE_USERS,
|
||||
"syntax": "<username> <message>",
|
||||
"callback": rtx
|
||||
}, {
|
||||
"trigger": "!bloodcat",
|
||||
"callback": bloodcat
|
||||
}
|
||||
#
|
||||
# "trigger": "!acc",
|
||||
|
|
|
@ -67,6 +67,7 @@ class match:
|
|||
self._lock = threading.Lock()
|
||||
self.createTime = int(time.time())
|
||||
self.vinseID = None
|
||||
self.bloodcatAlert = False
|
||||
|
||||
# Create all slots and reset them
|
||||
self.slots = []
|
||||
|
@ -441,6 +442,16 @@ class match:
|
|||
chat.sendMessage("FokaBot", chanName, "Match history available [{} here]".format(
|
||||
"https://vinse.ripple.moe/match/{}".format(self.vinseID)
|
||||
))
|
||||
if not self.bloodcatAlert:
|
||||
chat.sendMessage(
|
||||
"FokaBot",
|
||||
chanName,
|
||||
"Oh by the way, in case you're playing unranked or broken maps "
|
||||
"that are now available through ripple's osu!direct, you can "
|
||||
"type '!bloodcat' in the chat to get a download link for the "
|
||||
"currently selected map from Bloodcat!"
|
||||
)
|
||||
self.bloodcatAlert = True
|
||||
|
||||
# If this is a tournament match, then we send a notification in the chat
|
||||
# saying that the match has completed.
|
||||
|
|
Loading…
Reference in New Issue
Block a user