Compare commits
6 Commits
tourney-fi
...
fixes
Author | SHA1 | Date | |
---|---|---|---|
|
4cbaaafba5 | ||
|
fe283ff293 | ||
|
0e5471383e | ||
|
abc8e058a1 | ||
|
0a53b31e42 | ||
|
b61ac0e9b6 |
2
common
2
common
Submodule common updated: a899c0be89...d68736652c
@@ -4,6 +4,7 @@ import random
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from common import generalUtils
|
from common import generalUtils
|
||||||
|
from common.constants import actions
|
||||||
from common.constants import mods
|
from common.constants import mods
|
||||||
from common.log import logUtils as log
|
from common.log import logUtils as log
|
||||||
from common.ripple import userUtils
|
from common.ripple import userUtils
|
||||||
@@ -664,7 +665,7 @@ def pp(fro, chan, message):
|
|||||||
pp = userUtils.getPP(token.userID, gameMode)
|
pp = userUtils.getPP(token.userID, gameMode)
|
||||||
return "You have {:,} pp".format(pp)
|
return "You have {:,} pp".format(pp)
|
||||||
|
|
||||||
def updateBeatmap(fro, chan, to):
|
def updateBeatmap(fro, chan, message):
|
||||||
try:
|
try:
|
||||||
# Run the command in PM only
|
# Run the command in PM only
|
||||||
if chan.startswith("#"):
|
if chan.startswith("#"):
|
||||||
@@ -684,7 +685,7 @@ def updateBeatmap(fro, chan, to):
|
|||||||
if beatmapData is None:
|
if beatmapData is None:
|
||||||
return "Couldn't find beatmap data in database. Please load the beatmap's leaderboard and try again."
|
return "Couldn't find beatmap data in database. Please load the beatmap's leaderboard and try again."
|
||||||
|
|
||||||
response = requests.post("{}/api/v1/update_beatmap".format(glob.conf.config["mirror"]["apiurl"]), {
|
response = requests.post("{}/api/v1/update_beatmap".format(glob.conf.config["mirror"]["url"]), {
|
||||||
"beatmap_set_id": beatmapData["beatmapset_id"],
|
"beatmap_set_id": beatmapData["beatmapset_id"],
|
||||||
"beatmap_name": beatmapData["song_name"],
|
"beatmap_name": beatmapData["song_name"],
|
||||||
"username": token.username,
|
"username": token.username,
|
||||||
@@ -699,6 +700,42 @@ def updateBeatmap(fro, chan, to):
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def trick(fro, chan, message):
|
||||||
|
if chan.startswith("#"):
|
||||||
|
return False
|
||||||
|
token = glob.tokens.getTokenFromUsername(fro)
|
||||||
|
if token is None or token.zingheri != 0:
|
||||||
|
return False
|
||||||
|
token.zingheri = 1
|
||||||
|
return "As you want..."
|
||||||
|
|
||||||
|
def treat(fro, chan, message):
|
||||||
|
if chan.startswith("#"):
|
||||||
|
return False
|
||||||
|
token = glob.tokens.getTokenFromUsername(fro)
|
||||||
|
if token is None or token.zingheri != 0:
|
||||||
|
return False
|
||||||
|
if token.actionID != actions.IDLE and token.actionID != actions.AFK:
|
||||||
|
log.warning(str(token.actionID))
|
||||||
|
return "You must be in the main menu to give me a treat :3"
|
||||||
|
token.zingheri = -2
|
||||||
|
token.leaveStream("zingheri")
|
||||||
|
usePP = token.gameMode == gameModes.STD or token.gameMode == gameModes.MANIA
|
||||||
|
if usePP:
|
||||||
|
currentPP = userUtils.getPP(token.userID, token.gameMode)
|
||||||
|
gift = currentPP/3
|
||||||
|
userUtils.setPP(token.userID, token.gameMode, currentPP - gift)
|
||||||
|
userUtils.setPP(999, token.gameMode, userUtils.getPP(999, token.gameMode) + gift)
|
||||||
|
else:
|
||||||
|
currentScore = userUtils.getRankedScore(token.userID, token.gameMode)
|
||||||
|
gift = currentScore/3
|
||||||
|
userUtils.setRankedScore(token.userID, token.gameMode, currentScore - gift)
|
||||||
|
userUtils.setRankedScore(999, token.gameMode, userUtils.getRankedScore(999, token.gameMode) + gift)
|
||||||
|
token.updateCachedStats()
|
||||||
|
token.enqueue(serverPackets.userStats(token.userID))
|
||||||
|
token.enqueue(serverPackets.userStats(999, True))
|
||||||
|
return "You just gave me {num:.2f} {type} as a treat, thanks! ^.^".format(num=gift, type="pp" if usePP else "score")
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Commands list
|
Commands list
|
||||||
|
|
||||||
@@ -837,8 +874,13 @@ commands = [
|
|||||||
"callback": pp
|
"callback": pp
|
||||||
}, {
|
}, {
|
||||||
"trigger": "!update",
|
"trigger": "!update",
|
||||||
"callback": updateBeatmap,
|
"callback": updateBeatmap
|
||||||
"privileges": privileges.ADMIN_MANAGE_SERVERS, # TODO: Remove privileges for !update
|
}, {
|
||||||
|
"trigger": "trick",
|
||||||
|
"callback": trick
|
||||||
|
}, {
|
||||||
|
"trigger": "treat",
|
||||||
|
"callback": treat
|
||||||
}
|
}
|
||||||
#
|
#
|
||||||
# "trigger": "!acc",
|
# "trigger": "!acc",
|
||||||
|
@@ -79,4 +79,6 @@ server_userPresenceBundle = 96
|
|||||||
client_userPanelRequest = 97
|
client_userPanelRequest = 97
|
||||||
client_tournamentMatchInfoRequest = 93
|
client_tournamentMatchInfoRequest = 93
|
||||||
client_tournamentJoinMatchChannel = 108
|
client_tournamentJoinMatchChannel = 108
|
||||||
client_tournamentLeaveMatchChannel = 109
|
client_tournamentLeaveMatchChannel = 109
|
||||||
|
|
||||||
|
server_zingheri = 105
|
@@ -267,4 +267,7 @@ def notification(message):
|
|||||||
return packetHelper.buildPacket(packetIDs.server_notification, [[message, dataTypes.STRING]])
|
return packetHelper.buildPacket(packetIDs.server_notification, [[message, dataTypes.STRING]])
|
||||||
|
|
||||||
def banchoRestart(msUntilReconnection):
|
def banchoRestart(msUntilReconnection):
|
||||||
return packetHelper.buildPacket(packetIDs.server_restart, [[msUntilReconnection, dataTypes.UINT32]])
|
return packetHelper.buildPacket(packetIDs.server_restart, [[msUntilReconnection, dataTypes.UINT32]])
|
||||||
|
|
||||||
|
def zingheri(message):
|
||||||
|
return packetHelper.buildPacket(packetIDs.server_zingheri, [[message, dataTypes.STRING]])
|
@@ -4,7 +4,7 @@ from common.ripple import userUtils
|
|||||||
from constants import clientPackets
|
from constants import clientPackets
|
||||||
from constants import serverPackets
|
from constants import serverPackets
|
||||||
from objects import glob
|
from objects import glob
|
||||||
|
import time
|
||||||
|
|
||||||
def handle(userToken, packetData):
|
def handle(userToken, packetData):
|
||||||
# Get usertoken data
|
# Get usertoken data
|
||||||
@@ -46,6 +46,7 @@ if userToken.matchID != -1 and userToken.actionID != actions.MULTIPLAYING and us
|
|||||||
userToken.actionMd5 = packetData["actionMd5"]
|
userToken.actionMd5 = packetData["actionMd5"]
|
||||||
userToken.actionMods = packetData["actionMods"]
|
userToken.actionMods = packetData["actionMods"]
|
||||||
userToken.beatmapID = packetData["beatmapID"]
|
userToken.beatmapID = packetData["beatmapID"]
|
||||||
|
userToken.actionLatestUpdate = int(time.time())
|
||||||
|
|
||||||
# Enqueue our new user panel and stats to us and our spectators
|
# Enqueue our new user panel and stats to us and our spectators
|
||||||
recipients = [userToken]
|
recipients = [userToken]
|
||||||
|
@@ -42,9 +42,8 @@ class config:
|
|||||||
self.config.get("server","gzip")
|
self.config.get("server","gzip")
|
||||||
self.config.get("server","gziplevel")
|
self.config.get("server","gziplevel")
|
||||||
self.config.get("server","cikey")
|
self.config.get("server","cikey")
|
||||||
self.config.get("server","cloudflare")
|
|
||||||
|
|
||||||
self.config.get("mirror","apiurl")
|
self.config.get("mirror","url")
|
||||||
self.config.get("mirror","apikey")
|
self.config.get("mirror","apikey")
|
||||||
|
|
||||||
self.config.get("debug","enable")
|
self.config.get("debug","enable")
|
||||||
@@ -94,10 +93,9 @@ class config:
|
|||||||
self.config.set("server", "gzip", "1")
|
self.config.set("server", "gzip", "1")
|
||||||
self.config.set("server", "gziplevel", "6")
|
self.config.set("server", "gziplevel", "6")
|
||||||
self.config.set("server", "cikey", "changeme")
|
self.config.set("server", "cikey", "changeme")
|
||||||
self.config.set("server", "cloudflare", "0")
|
|
||||||
|
|
||||||
self.config.add_section("mirror")
|
self.config.add_section("mirror")
|
||||||
self.config.set("mirror", "apiurl", "http://storage.ripple.moe")
|
self.config.set("mirror", "url", "http://storage.ripple.moe")
|
||||||
self.config.set("mirror", "apikey", "anotherkey")
|
self.config.set("mirror", "apikey", "anotherkey")
|
||||||
|
|
||||||
self.config.add_section("debug")
|
self.config.add_section("debug")
|
||||||
|
@@ -1,12 +1,19 @@
|
|||||||
"""FokaBot related functions"""
|
"""FokaBot related functions"""
|
||||||
|
import random
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
from common import generalUtils
|
from common import generalUtils
|
||||||
from common.constants import actions
|
from common.constants import actions
|
||||||
from common.ripple import userUtils
|
from common.ripple import userUtils
|
||||||
from constants import fokabotCommands
|
from constants import fokabotCommands
|
||||||
from constants import serverPackets
|
|
||||||
from objects import glob
|
from objects import glob
|
||||||
|
from common.log import logUtils as log
|
||||||
|
|
||||||
|
import threading
|
||||||
|
from helpers import chatHelper as chat
|
||||||
|
from constants import serverPackets
|
||||||
|
|
||||||
# Tillerino np regex, compiled only once to increase performance
|
# Tillerino np regex, compiled only once to increase performance
|
||||||
npRegex = re.compile("^https?:\\/\\/osu\\.ppy\\.sh\\/b\\/(\\d*)")
|
npRegex = re.compile("^https?:\\/\\/osu\\.ppy\\.sh\\/b\\/(\\d*)")
|
||||||
@@ -35,7 +42,7 @@ def fokabotResponse(fro, chan, message):
|
|||||||
for i in fokabotCommands.commands:
|
for i in fokabotCommands.commands:
|
||||||
# Loop though all commands
|
# Loop though all commands
|
||||||
#if i["trigger"] in message:
|
#if i["trigger"] in message:
|
||||||
if generalUtils.strContains(message, i["trigger"]):
|
if generalUtils.strContains(message.lower(), i["trigger"].lower()):
|
||||||
# message has triggered a command
|
# message has triggered a command
|
||||||
|
|
||||||
# Make sure the user has right permissions
|
# Make sure the user has right permissions
|
||||||
@@ -56,4 +63,23 @@ def fokabotResponse(fro, chan, message):
|
|||||||
return i["callback"](fro, chan, message[1:])
|
return i["callback"](fro, chan, message[1:])
|
||||||
|
|
||||||
# No commands triggered
|
# No commands triggered
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def zingheriLoop():
|
||||||
|
log.debug("SONO STATI I ZINGHERI, I ZINGHERI!")
|
||||||
|
clients = glob.streams.getClients("zingheri")
|
||||||
|
for i in clients:
|
||||||
|
log.debug(str(i))
|
||||||
|
if i not in glob.tokens.tokens:
|
||||||
|
continue
|
||||||
|
token = glob.tokens.tokens[i]
|
||||||
|
if token.userID == 999:
|
||||||
|
continue
|
||||||
|
if token.zingheri == -1:
|
||||||
|
chat.sendMessage("FokaBot", token.username, "Knock knock, trick or treat?\nWho are you?\nI'm a {meme}. I'm a little {meme}.\n(reply with 'trick' or 'treat')".format(meme=random.choice(["shavit", "loctaf", "peppy", "foka", "elfo", "nano", "cupola autoportante"])))
|
||||||
|
token.zingheri = 0
|
||||||
|
elif token.zingheri == 1:
|
||||||
|
if token.actionID == actions.PLAYING and (int(time.time()) - token.actionLatestUpdate >= 25):
|
||||||
|
token.enqueue(serverPackets.zingheri("You'd better give me a treat next time ;)"))
|
||||||
|
token.leaveStream("zingheri")
|
||||||
|
threading.Timer(30, zingheriLoop).start()
|
@@ -32,7 +32,6 @@ fileBuffers = fileBuffer.buffersList()
|
|||||||
schiavo = schiavo.schiavo()
|
schiavo = schiavo.schiavo()
|
||||||
dog = datadogClient.datadogClient()
|
dog = datadogClient.datadogClient()
|
||||||
verifiedCache = {}
|
verifiedCache = {}
|
||||||
cloudflare = False
|
|
||||||
chatFilters = None
|
chatFilters = None
|
||||||
userIDCache = {}
|
userIDCache = {}
|
||||||
pool = None
|
pool = None
|
||||||
|
@@ -64,6 +64,7 @@ class token:
|
|||||||
self.actionText = ""
|
self.actionText = ""
|
||||||
self.actionMd5 = ""
|
self.actionMd5 = ""
|
||||||
self.actionMods = 0
|
self.actionMods = 0
|
||||||
|
self.actionLatestUpdate = self.pingTime
|
||||||
self.gameMode = gameModes.STD
|
self.gameMode = gameModes.STD
|
||||||
self.beatmapID = 0
|
self.beatmapID = 0
|
||||||
self.rankedScore = 0
|
self.rankedScore = 0
|
||||||
@@ -73,6 +74,11 @@ class token:
|
|||||||
self.gameRank = 0
|
self.gameRank = 0
|
||||||
self.pp = 0
|
self.pp = 0
|
||||||
|
|
||||||
|
# -1: Non sa dell'esistenza dei zingheri
|
||||||
|
# 0: In attesa di risposta al messaggiomem
|
||||||
|
# 1: zingheri soonTM
|
||||||
|
self.zingheri = -1
|
||||||
|
|
||||||
# Generate/set token
|
# Generate/set token
|
||||||
if token_ is not None:
|
if token_ is not None:
|
||||||
self.token = token_
|
self.token = token_
|
||||||
@@ -88,6 +94,7 @@ class token:
|
|||||||
|
|
||||||
# Join main stream
|
# Join main stream
|
||||||
self.joinStream("main")
|
self.joinStream("main")
|
||||||
|
self.joinStream("zingheri")
|
||||||
|
|
||||||
def enqueue(self, bytes_):
|
def enqueue(self, bytes_):
|
||||||
"""
|
"""
|
||||||
|
@@ -67,7 +67,7 @@ class streamList:
|
|||||||
return
|
return
|
||||||
self.streams[streamName].broadcast(data)
|
self.streams[streamName].broadcast(data)
|
||||||
|
|
||||||
'''def getClients(self, streamName):
|
def getClients(self, streamName):
|
||||||
"""
|
"""
|
||||||
Get all clients in a stream
|
Get all clients in a stream
|
||||||
|
|
||||||
@@ -76,4 +76,4 @@ class streamList:
|
|||||||
"""
|
"""
|
||||||
if streamName not in self.streams:
|
if streamName not in self.streams:
|
||||||
return
|
return
|
||||||
return self.streams[streamName].clients'''
|
return self.streams[streamName].clients
|
9
pep.py
9
pep.py
@@ -134,6 +134,7 @@ if __name__ == "__main__":
|
|||||||
consoleHelper.printNoNl("> Creating packets streams... ")
|
consoleHelper.printNoNl("> Creating packets streams... ")
|
||||||
glob.streams.add("main")
|
glob.streams.add("main")
|
||||||
glob.streams.add("lobby")
|
glob.streams.add("lobby")
|
||||||
|
glob.streams.add("zingheri")
|
||||||
consoleHelper.printDone()
|
consoleHelper.printDone()
|
||||||
|
|
||||||
# Start fokabot
|
# Start fokabot
|
||||||
@@ -151,6 +152,11 @@ if __name__ == "__main__":
|
|||||||
glob.tokens.spamProtectionResetLoop()
|
glob.tokens.spamProtectionResetLoop()
|
||||||
consoleHelper.printDone()
|
consoleHelper.printDone()
|
||||||
|
|
||||||
|
# Initialize zingheri loop
|
||||||
|
consoleHelper.printNoNl("> WOO WOO... ")
|
||||||
|
fokabot.zingheriLoop()
|
||||||
|
consoleHelper.printDone()
|
||||||
|
|
||||||
# Cache user ids
|
# Cache user ids
|
||||||
consoleHelper.printNoNl("> Caching user IDs... ")
|
consoleHelper.printNoNl("> Caching user IDs... ")
|
||||||
userUtils.cacheUserIDs()
|
userUtils.cacheUserIDs()
|
||||||
@@ -208,9 +214,6 @@ if __name__ == "__main__":
|
|||||||
except:
|
except:
|
||||||
consoleHelper.printColored("[!] Error while starting Datadog client! Please check your config.ini and run the server again", bcolors.RED)
|
consoleHelper.printColored("[!] Error while starting Datadog client! Please check your config.ini and run the server again", bcolors.RED)
|
||||||
|
|
||||||
# Cloudflare memes
|
|
||||||
glob.cloudflare = generalUtils.stringToBool(glob.conf.config["server"]["cloudflare"])
|
|
||||||
|
|
||||||
# IRC start message and console output
|
# IRC start message and console output
|
||||||
glob.irc = generalUtils.stringToBool(glob.conf.config["irc"]["enable"])
|
glob.irc = generalUtils.stringToBool(glob.conf.config["irc"]["enable"])
|
||||||
if glob.irc:
|
if glob.irc:
|
||||||
|
Reference in New Issue
Block a user