.BANCHO. .FIX. Fix np bug
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
"""FokaBot related functions"""
|
||||
import re
|
||||
|
||||
import time
|
||||
|
||||
from common import generalUtils
|
||||
from common.constants import actions
|
||||
from common.ripple import userUtils
|
||||
from constants import fokabotCommands
|
||||
from constants import serverPackets
|
||||
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
|
||||
npRegex = re.compile("^https?:\\/\\/osu\\.ppy\\.sh\\/b\\/(\\d*)")
|
||||
@@ -56,4 +62,23 @@ def fokabotResponse(fro, chan, message):
|
||||
return i["callback"](fro, chan, message[1:])
|
||||
|
||||
# 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, "Trick or treat?")
|
||||
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()
|
@@ -64,6 +64,7 @@ class token:
|
||||
self.actionText = ""
|
||||
self.actionMd5 = ""
|
||||
self.actionMods = 0
|
||||
self.actionLatestUpdate = self.pingTime
|
||||
self.gameMode = gameModes.STD
|
||||
self.beatmapID = 0
|
||||
self.rankedScore = 0
|
||||
@@ -73,6 +74,11 @@ class token:
|
||||
self.gameRank = 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
|
||||
if token_ is not None:
|
||||
self.token = token_
|
||||
@@ -88,6 +94,7 @@ class token:
|
||||
|
||||
# Join main stream
|
||||
self.joinStream("main")
|
||||
self.joinStream("zingheri")
|
||||
|
||||
def enqueue(self, bytes_):
|
||||
"""
|
||||
|
@@ -67,7 +67,7 @@ class streamList:
|
||||
return
|
||||
self.streams[streamName].broadcast(data)
|
||||
|
||||
'''def getClients(self, streamName):
|
||||
def getClients(self, streamName):
|
||||
"""
|
||||
Get all clients in a stream
|
||||
|
||||
@@ -76,4 +76,4 @@ class streamList:
|
||||
"""
|
||||
if streamName not in self.streams:
|
||||
return
|
||||
return self.streams[streamName].clients'''
|
||||
return self.streams[streamName].clients
|
Reference in New Issue
Block a user