mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 02:09:41 +00:00
Added CC-Nanotrasen, an IRC bot made by Skibiliano and given to us by him under CC-BY-SA 3.0 licensing WHAT DOES THIS MEAN? It means all servers running this SVN now have the option to use an easy to configure IRC bot capable of relaying adminhelps from ingame to the server/channel of their choice. - Runs on python 2.6 scripts with psyco support - Relaying can be toggled from config.txt (so you don't runtime with every adminhelp if you decide not to use it) - Comes with a bunch of other useful and fun tools too - Added a new global proc, send2irc(msg,msg2) YOU'LL NEVER GUESS WHAT IT DOES CONSIDERING WHAT I JUST MENTIONED ----msg and msg2 are just what text gets relayed to irc, separated by a |, for instance send2irc(hello, world) would come out as "CC_NanoTrasen: Hello | World git-svn-id: http://tgstation13.googlecode.com/svn/trunk@2783 316c924e-a436-60f5-8080-3fe189b3f50e
71 lines
2.5 KiB
Python
71 lines
2.5 KiB
Python
### EXPERIMENTAL PROTOTYPE ###
|
|
# e = 2.7182818284590452353602874713526624977572
|
|
# pi = math.pi
|
|
from __future__ import division #PYTHON Y U NO TELL ME THIS BEFORE
|
|
import math
|
|
import random
|
|
import re
|
|
e = "2.7182818284590452353602874713526624977572"
|
|
pi = str(math.pi)
|
|
global pre
|
|
pre = len("maths ")
|
|
def maths(influx,prefix="!",sender="NaN",debug=True,method="n"):
|
|
global pre
|
|
influx = influx.lower()
|
|
influx = influx[len(prefix)+pre:]
|
|
influx = influx.replace("pie",pi+"*"+e)
|
|
influx = influx.replace("e*",e+"*")
|
|
influx = influx.replace("*e","*"+e)
|
|
influx = influx.replace("pi",pi)
|
|
if debug:
|
|
print sender+":"+prefix+"maths"
|
|
if influx.count("**") == 0 and influx.count('"') == 0 and influx.count("'") == 0 and influx.count(";") == 0 and influx.count(":") == 0:
|
|
influx_low = influx.lower()
|
|
influx_hi = influx.upper()
|
|
if "0b" in influx_low:
|
|
influx_low = re.sub("0b[0-1]*","",influx_low)
|
|
influx_hi = re.sub("0B[0-1]*","",influx_hi)
|
|
if "0x" in influx_low:
|
|
influx_low = re.sub("0x[a-f0-9]*","",influx_low)
|
|
influx_hi = re.sub("0X[A-F0-9]*","",influx_hi)
|
|
if "rand" in influx_low:
|
|
influx_low = re.sub("rand","",influx_low)
|
|
influx_hi = re.sub("RAND","",influx_hi)
|
|
if influx_low == influx_hi:
|
|
influx = re.sub("rand","random.random()",influx)
|
|
try:
|
|
result = eval(influx.lower())
|
|
except ZeroDivisionError:
|
|
return "Divide by zero detected."
|
|
except SyntaxError:
|
|
return "Syntax Error detected."
|
|
except TypeError:
|
|
return "Type Error detected."
|
|
except:
|
|
return "Unknown Error detected."
|
|
else:
|
|
if method == "n": #Normal
|
|
return result
|
|
elif method == "i": #Forced Int
|
|
return int(result)
|
|
elif method == "h": #Hex
|
|
try:
|
|
if "L" in hex(result)[2:]:
|
|
return hex(result)[2:-1]
|
|
else:
|
|
return hex(result)[2:].upper()
|
|
except TypeError:
|
|
return "That value (%s) cannot be interpreted properly using !hmaths" %(str(result))
|
|
elif method == "b": #Binary
|
|
try:
|
|
return bin(result)[2:].upper()
|
|
except TypeError:
|
|
return "That value (%s) cannot be interpreted properly using !bmaths" %(str(result))
|
|
else:
|
|
return result
|
|
else:
|
|
return "What are you trying to make me do again?"
|
|
else:
|
|
return "Those are likely to make me hang"
|
|
|