.HIDE. Merge branch 'master' of git.zxq.co:ripple/pep.py
This commit is contained in:
commit
f8c1f49170
|
@ -11,6 +11,9 @@ import json
|
|||
from constants import mods
|
||||
from helpers import generalFunctions
|
||||
|
||||
from helpers import consoleHelper
|
||||
from constants import bcolors
|
||||
|
||||
"""
|
||||
Commands callbacks
|
||||
|
||||
|
@ -46,6 +49,8 @@ def faq(fro, chan, message):
|
|||
return "Check the server status (here!)[https://ripple.moe/index.php?p=27]"
|
||||
elif message[0] == "english":
|
||||
return "Please keep this channel in english."
|
||||
else:
|
||||
return False
|
||||
|
||||
def roll(fro, chan, message):
|
||||
maxPoints = 100
|
||||
|
@ -63,6 +68,16 @@ def alert(fro, chan, message):
|
|||
glob.tokens.enqueueAll(serverPackets.notification(' '.join(message[:])))
|
||||
return False
|
||||
|
||||
def alertUser(fro, chan, message):
|
||||
target = message[0].replace("_", " ")
|
||||
|
||||
targetToken = glob.tokens.getTokenFromUsername(target)
|
||||
if targetToken != None:
|
||||
targetToken.enqueue(serverPackets.notification(' '.join(message[1:])))
|
||||
return False
|
||||
else:
|
||||
return "User offline."
|
||||
|
||||
def moderated(fro, chan, message):
|
||||
try:
|
||||
# Make sure we are in a channel and not PM
|
||||
|
@ -341,7 +356,7 @@ def getPPMessage(userID):
|
|||
return msg
|
||||
except requests.exceptions.RequestException:
|
||||
# RequestException
|
||||
return "API Timeout."
|
||||
return "API Timeout. Please try again in a few seconds."
|
||||
except exceptions.apiException:
|
||||
# API error
|
||||
return "Unknown error in LETS API call. Please tell this to a dev."
|
||||
|
@ -476,6 +491,10 @@ def tillerinoLast(fro, chan, message):
|
|||
print(a)
|
||||
return False
|
||||
|
||||
def mm00(fro, chan, message):
|
||||
random.seed()
|
||||
return random.choice(["meme", "MA MAURO ESISTE?"])
|
||||
|
||||
"""
|
||||
Commands list
|
||||
|
||||
|
@ -484,8 +503,18 @@ callback: function to call when the command is triggered. Optional.
|
|||
response: text to return when the command is triggered. Optional.
|
||||
syntax: command syntax. Arguments must be separated by spaces (eg: <arg1> <arg2>)
|
||||
minRank: minimum rank to execute that command. Optional (default = 1)
|
||||
rank: EXACT rank used to execute that command. Optional.
|
||||
|
||||
You MUST set trigger and callback/response, or the command won't work.
|
||||
RANKS:
|
||||
1: Normal user
|
||||
2: Supporter
|
||||
3: Developer
|
||||
4: Community manager
|
||||
|
||||
NOTES:
|
||||
- You CAN'T use both rank and minRank at the same time.
|
||||
- If both rank and minrank are **not** present, everyone will be able to run that command.
|
||||
- You MUST set trigger and callback/response, or the command won't work.
|
||||
"""
|
||||
commands = [
|
||||
{
|
||||
|
@ -507,19 +536,24 @@ commands = [
|
|||
"callback": ask
|
||||
}, {
|
||||
"trigger": "!mm00",
|
||||
"response": random.choice(["meme", "MA MAURO ESISTE?"])
|
||||
"callback": mm00
|
||||
}, {
|
||||
"trigger": "!alert",
|
||||
"syntax": "<message>",
|
||||
"minRank": 4,
|
||||
"minRank": 3,
|
||||
"callback": alert
|
||||
}, {
|
||||
"trigger": "!alertuser",
|
||||
"syntax": "<username> <message>",
|
||||
"minRank": 3,
|
||||
"callback": alertUser,
|
||||
}, {
|
||||
"trigger": "!moderated",
|
||||
"minRank": 3,
|
||||
"callback": moderated
|
||||
}, {
|
||||
"trigger": "!kickall",
|
||||
"minRank": 4,
|
||||
"rank": 3,
|
||||
"callback": kickAll
|
||||
}, {
|
||||
"trigger": "!kick",
|
||||
|
@ -542,11 +576,11 @@ commands = [
|
|||
"callback": removeSilence
|
||||
}, {
|
||||
"trigger": "!system restart",
|
||||
"minRank": 4,
|
||||
"rank": 3,
|
||||
"callback": systemRestart
|
||||
}, {
|
||||
"trigger": "!system shutdown",
|
||||
"minRank": 4,
|
||||
"rank": 3,
|
||||
"callback": systemShutdown
|
||||
}, {
|
||||
"trigger": "!system reload",
|
||||
|
@ -554,11 +588,11 @@ commands = [
|
|||
"callback": systemReload
|
||||
}, {
|
||||
"trigger": "!system maintenance",
|
||||
"minRank": 3,
|
||||
"rank": 3,
|
||||
"callback": systemMaintenance
|
||||
}, {
|
||||
"trigger": "!system status",
|
||||
"minRank": 3,
|
||||
"rank": 3,
|
||||
"callback": systemStatus
|
||||
}, {
|
||||
"trigger": "!ban",
|
||||
|
@ -595,5 +629,6 @@ commands = [
|
|||
for cmd in commands:
|
||||
cmd.setdefault("syntax", "")
|
||||
cmd.setdefault("minRank", 1)
|
||||
cmd.setdefault("rank", None)
|
||||
cmd.setdefault("callback", None)
|
||||
cmd.setdefault("response", "u w0t m8?")
|
||||
|
|
|
@ -101,9 +101,9 @@ def userPanel(userID):
|
|||
if username == "FokaBot":
|
||||
userRank = userRanks.MOD
|
||||
elif rank == 4:
|
||||
userRank = userRanks.ADMIN
|
||||
elif rank == 3:
|
||||
userRank = userRanks.MOD
|
||||
elif rank == 3:
|
||||
userRank = userRanks.ADMIN
|
||||
elif rank == 2:
|
||||
userRank = userRanks.SUPPORTER
|
||||
else:
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Bancho user ranks"""
|
||||
# TODO: Uppercase, maybe?
|
||||
NORMAL = 0
|
||||
PLAYER = 1
|
||||
SUPPORTER = 4
|
||||
|
|
|
@ -51,3 +51,7 @@ def readableMods(__mods):
|
|||
r += "SO"
|
||||
|
||||
return r
|
||||
|
||||
|
||||
def strContains(s, w):
|
||||
return (' ' + w + ' ') in (' ' + s + ' ')
|
||||
|
|
|
@ -5,6 +5,7 @@ from constants import actions
|
|||
from constants import serverPackets
|
||||
from constants import fokabotCommands
|
||||
import re
|
||||
from helpers import generalFunctions
|
||||
|
||||
# Tillerino np regex, compiled only once to increase performance
|
||||
npRegex = re.compile("^https?:\\/\\/osu\\.ppy\\.sh\\/b\\/(\\d*)")
|
||||
|
@ -35,14 +36,21 @@ def fokabotResponse(fro, chan, message):
|
|||
|
||||
for i in fokabotCommands.commands:
|
||||
# Loop though all commands
|
||||
if i["trigger"] in message:
|
||||
#if i["trigger"] in message:
|
||||
if generalFunctions.strContains(message, i["trigger"]):
|
||||
# message has triggered a command
|
||||
|
||||
# Make sure the user has right permissions
|
||||
if i["minRank"] > 1:
|
||||
# Get rank from db only if minrank > 1, so we save some CPU
|
||||
if userHelper.getRankPrivileges(userHelper.getID(fro)) < i["minRank"]:
|
||||
if i["rank"] != None:
|
||||
# Rank = x
|
||||
if userHelper.getRankPrivileges(userHelper.getID(fro)) != i["rank"]:
|
||||
return False
|
||||
else:
|
||||
# Rank > x
|
||||
if i["minRank"] > 1:
|
||||
# Get rank from db only if minrank > 1, so we save some CPU
|
||||
if userHelper.getRankPrivileges(userHelper.getID(fro)) < i["minRank"]:
|
||||
return False
|
||||
|
||||
# Check argument number
|
||||
message = message.split(" ")
|
||||
|
|
Loading…
Reference in New Issue
Block a user