else
RCON relay 1
This commit is contained in:
parent
2b61c627ae
commit
51be494124
2 changed files with 123 additions and 0 deletions
54
Marketeer/marketeer.pyw
Normal file
54
Marketeer/marketeer.pyw
Normal file
|
@ -0,0 +1,54 @@
|
|||
import tkinter
|
||||
|
||||
class Marketeer:
|
||||
def __init__(self):
|
||||
self.t = tkinter.Tk()
|
||||
self.t.grid_propagate(0)
|
||||
self.t.title("Marketeer")
|
||||
|
||||
self.multiplier = 1.15
|
||||
self.current = tkinter.StringVar()
|
||||
self.entry = tkinter.Entry(self.t, textvariable=self.current)
|
||||
self.entry.configure(relief="flat")
|
||||
self.entry.place(x=40, y=40)
|
||||
self.entry.bind("<Return>", self.clear)
|
||||
self.entry.focus_set()
|
||||
self.current.trace("w", self.update)
|
||||
|
||||
self.output = tkinter.Label(self.t)
|
||||
self.output.place(x=30, y=90)
|
||||
|
||||
self.dolladollabill = tkinter.Label(self.t, text="$")
|
||||
self.dolladollabill.place(x=30, y=40)
|
||||
self.indicator = tkinter.Label(self.t, text="x %0.2f"%self.multiplier)
|
||||
self.indicator.place(x=60, y=64)
|
||||
self.isreversed = tkinter.IntVar()
|
||||
self.reversal = tkinter.Checkbutton(self.t, variable=self.isreversed, command=self.updatemultiplier)
|
||||
self.reversal.place(x=110, y=64)
|
||||
self.t.mainloop()
|
||||
|
||||
def update(self, *bull):
|
||||
current = self.current.get()
|
||||
try:
|
||||
current = float(current)
|
||||
current *= self.multiplier
|
||||
current = "$ %0.3f"% round(current, 2)
|
||||
self.output.configure(text=current)
|
||||
except:
|
||||
pass
|
||||
if current == "":
|
||||
self.output.configure(text="")
|
||||
|
||||
def updatemultiplier(self, *bull):
|
||||
rev = self.isreversed.get()
|
||||
if rev == 1:
|
||||
self.multiplier = (1 / 1.15)
|
||||
else:
|
||||
self.multiplier = 1.15
|
||||
self.indicator.configure(text="x %0.2f" % self.multiplier)
|
||||
self.update()
|
||||
|
||||
def clear(self, *bull):
|
||||
self.entry.delete(0, "end")
|
||||
|
||||
marketeer = Marketeer()
|
69
RCONRelay/rconrelay.py
Normal file
69
RCONRelay/rconrelay.py
Normal file
|
@ -0,0 +1,69 @@
|
|||
import socket
|
||||
import time
|
||||
import traceback
|
||||
|
||||
|
||||
class RCONRelay:
|
||||
def __init__(self):
|
||||
self.whitelist = ["joined team", "say", "killed", "suicide", "changed name"]
|
||||
self.blacklist = ["say_team"]
|
||||
self.weaponmap = {
|
||||
"tf_projectile_rocket": "Rocket Launcher",
|
||||
"tf_projectile_pipe_remote": "Sticky Bomb",
|
||||
"obj_sentrygun": "Sentry lvl 1",
|
||||
"obj_sentrygun2": "Sentry lvl 2",
|
||||
"obj_sentrygun3": "Sentry lvl 3",
|
||||
"shotgun_pyro": "Shotgun",
|
||||
"shotgun_soldier": "Shotgun",
|
||||
"shotgun_primary": "Shotgun"
|
||||
}
|
||||
|
||||
self.ip = ""
|
||||
self.port = 32768
|
||||
|
||||
def start(self):
|
||||
self.rcon = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
#self.rcon.settimeout(60)
|
||||
self.rcon.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
||||
self.rcon.bind((self.ip, self.port))
|
||||
print("Listening...")
|
||||
while True:
|
||||
chatdata = self.rcon.recvfrom(1024)
|
||||
#print(chatdata)
|
||||
self.processchat(chatdata)
|
||||
|
||||
def processchat(self, chatdata):
|
||||
chat = chatdata[0]
|
||||
chat = chat.decode("utf-8", "ignore")
|
||||
chat = chat[3:-2]
|
||||
timestamp = chat[:21]
|
||||
if "killed" in chat:
|
||||
quotesplit = chat.split('"')
|
||||
killerinfo = quotesplit[1]
|
||||
victiminfo = quotesplit[3]
|
||||
weaponinfo = quotesplit[5]
|
||||
weaponinfo = self.weaponmap.get(weaponinfo, weaponinfo)
|
||||
misc = '"'.join(quotesplit[6:])
|
||||
headshot = True if "(customkill \"headshot\")" in misc else False
|
||||
chat = "%s] %s killed %s with %s" % (timestamp, killerinfo, victiminfo, weaponinfo)
|
||||
if headshot:
|
||||
chat += " (Headshot)"
|
||||
|
||||
elif "committed suicide with \"world\" (attacker_position" in chat:
|
||||
quotesplit = chat.split('"')
|
||||
victiminfo = quotesplit[1]
|
||||
chat = "%s] %s committed suicide" % (timestamp, victiminfo)
|
||||
|
||||
if any(white.lower() in chat.lower() for white in self.whitelist):
|
||||
if not any(ban.lower() in chat.lower() for ban in self.blacklist):
|
||||
print(chat)
|
||||
|
||||
def weaponmapping(self, chat):
|
||||
for key in self.weaponmap:
|
||||
val = self.weaponmap[key]
|
||||
chat = chat.replace(key, val)
|
||||
return chat
|
||||
|
||||
|
||||
rcon = RCONRelay()
|
||||
rcon.start()
|
Loading…
Reference in a new issue