.BANCHO. Compile tillerino regex only once
This commit is contained in:
parent
7b89822e69
commit
e483a92a2c
|
@ -6,15 +6,10 @@ from constants import exceptions
|
||||||
from helpers import userHelper
|
from helpers import userHelper
|
||||||
import time
|
import time
|
||||||
from helpers import systemHelper
|
from helpers import systemHelper
|
||||||
import re
|
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
from constants import mods
|
from constants import mods
|
||||||
from helpers import generalFunctions
|
from helpers import generalFunctions
|
||||||
import sys
|
|
||||||
import traceback
|
|
||||||
from helpers import consoleHelper
|
|
||||||
from constants import bcolors
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Commands callbacks
|
Commands callbacks
|
||||||
|
@ -328,7 +323,7 @@ def getPPMessage(userID):
|
||||||
return "Error in LETS API call ({}). Please tell this to a dev.".format(data["message"])
|
return "Error in LETS API call ({}). Please tell this to a dev.".format(data["message"])
|
||||||
else:
|
else:
|
||||||
raise exceptions.apiException
|
raise exceptions.apiException
|
||||||
|
|
||||||
# Return response in chat
|
# Return response in chat
|
||||||
# Song name and mods
|
# Song name and mods
|
||||||
msg = "{song}{plus}{mods} ".format(song=data["song_name"], plus="+" if token.tillerino[1] > 0 else "", mods=generalFunctions.readableMods(token.tillerino[1]))
|
msg = "{song}{plus}{mods} ".format(song=data["song_name"], plus="+" if token.tillerino[1] > 0 else "", mods=generalFunctions.readableMods(token.tillerino[1]))
|
||||||
|
@ -370,8 +365,7 @@ def tillerinoNp(fro, chan, message):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Get beatmap id from URL
|
# Get beatmap id from URL
|
||||||
p = re.compile("^https?:\\/\\/osu\\.ppy\\.sh\\/b\\/(\\d*)")
|
beatmapID = fokabot.npRegex.search(beatmapURL).groups(0)[0]
|
||||||
beatmapID = p.search(beatmapURL).groups(0)[0]
|
|
||||||
|
|
||||||
# Update latest tillerino song for current token
|
# Update latest tillerino song for current token
|
||||||
token = glob.tokens.getTokenFromUsername(fro)
|
token = glob.tokens.getTokenFromUsername(fro)
|
||||||
|
|
|
@ -4,6 +4,10 @@ from objects import glob
|
||||||
from constants import actions
|
from constants import actions
|
||||||
from constants import serverPackets
|
from constants import serverPackets
|
||||||
from constants import fokabotCommands
|
from constants import fokabotCommands
|
||||||
|
import re
|
||||||
|
|
||||||
|
# Tillerino np regex, compiled only once to increase performance
|
||||||
|
npRegex = re.compile("^https?:\\/\\/osu\\.ppy\\.sh\\/b\\/(\\d*)")
|
||||||
|
|
||||||
def connect():
|
def connect():
|
||||||
"""Add FokaBot to connected users and send userpanel/stats packet to everyone"""
|
"""Add FokaBot to connected users and send userpanel/stats packet to everyone"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user