better join/leave, griefprevention support
This commit is contained in:
parent
aeb14d12d9
commit
f08b284397
28
tcirc.py
28
tcirc.py
|
@ -89,7 +89,7 @@ def mc_to_irc():
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
latest_lines = file.readlines()
|
latest_lines = file.readlines()
|
||||||
for line in latest_lines:
|
for line in latest_lines:
|
||||||
if re.search('\[Async Chat Thread -.*?/INFO', line) is not None :
|
if re.search('\[Async Chat Thread -.*?/INFO', line) is not None and ': [GriefPrevention] ' not in line:
|
||||||
print('received ' + ''.join(line))
|
print('received ' + ''.join(line))
|
||||||
line = re.sub(r'', r'^[', line)
|
line = re.sub(r'', r'^[', line)
|
||||||
line = re.sub(r'\^.*?m', '', line)
|
line = re.sub(r'\^.*?m', '', line)
|
||||||
|
@ -126,10 +126,11 @@ def mc_to_irc():
|
||||||
print('sent ' + line)
|
print('sent ' + line)
|
||||||
irc.send(bytes('PRIVMSG ' + channel + ' :' + line, 'utf8'))
|
irc.send(bytes('PRIVMSG ' + channel + ' :' + line, 'utf8'))
|
||||||
|
|
||||||
elif 'left the game' in line and 'IRC ' not in line:
|
elif 'left the game' in line and '[Server thread/INFO]: [Rcon] ' not in line:
|
||||||
print('received ' + ''.join(line))
|
print('received ' + ''.join(line))
|
||||||
line = re.sub(r'', r'^[', line)
|
line = re.sub(r'', r'^[', line)
|
||||||
line = re.sub(r'\[.*?: ', '', line, 1)
|
line = re.sub(r'\[.*?: ', '', line, 1)
|
||||||
|
line = re.sub(r'left the game', 'logged off', line, 1)
|
||||||
line = re.sub(r'\[/.*?\]', '', line, 1)
|
line = re.sub(r'\[/.*?\]', '', line, 1)
|
||||||
line = re.sub(r'> ', '', line, 1)
|
line = re.sub(r'> ', '', line, 1)
|
||||||
line = re.sub(r'lost connection: Disconnected', 'disconnected', line, 1)
|
line = re.sub(r'lost connection: Disconnected', 'disconnected', line, 1)
|
||||||
|
@ -153,7 +154,7 @@ def mc_to_irc():
|
||||||
print('sent ' + line)
|
print('sent ' + line)
|
||||||
if '@tildeverse:' not in line:
|
if '@tildeverse:' not in line:
|
||||||
irc.send(bytes('PRIVMSG ' + channel + ' :' + line, 'utf8'))
|
irc.send(bytes('PRIVMSG ' + channel + ' :' + line, 'utf8'))
|
||||||
elif any(death in line for death in death_messages):
|
elif any(' ' + death + ' ' in line for death in death_messages) and 'Villager EntityVillager[\'' not in line:
|
||||||
line = re.sub(r'^\[.*\]: ', '', line, 1)
|
line = re.sub(r'^\[.*\]: ', '', line, 1)
|
||||||
print('sent ' + line)
|
print('sent ' + line)
|
||||||
irc.send(bytes('PRIVMSG ' + channel + ' :' + line, 'utf8'))
|
irc.send(bytes('PRIVMSG ' + channel + ' :' + line, 'utf8'))
|
||||||
|
@ -166,7 +167,7 @@ def irc_to_mc():
|
||||||
rcon_password_file = open('rcon_password', 'r')
|
rcon_password_file = open('rcon_password', 'r')
|
||||||
rcon_password = rcon_password_file.readline().strip()
|
rcon_password = rcon_password_file.readline().strip()
|
||||||
rcon_password_file.close()
|
rcon_password_file.close()
|
||||||
rcon.connect('209.182.234.192', 6668, rcon_password)
|
rcon.connect('0.0.0.0', 6668, rcon_password)
|
||||||
print('initiated rcon connection')
|
print('initiated rcon connection')
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
|
@ -234,12 +235,19 @@ def irc_to_mc():
|
||||||
|
|
||||||
|
|
||||||
elif 'JOIN' in text or 'PART' in text:
|
elif 'JOIN' in text or 'PART' in text:
|
||||||
text = re.sub(r':.*?\!', r'', text, 1)
|
print("-- JOIN EVENT --")
|
||||||
text = re.sub(r'@localhost', r'', text, 1)
|
print(text)
|
||||||
text = re.sub(r':WeeChat.*', r'', text, 1)
|
if 'PART' in text:
|
||||||
text = re.sub(r'JOIN', r'joined', text, 1)
|
text = re.search(r':.*!', text).group(0)
|
||||||
text = re.sub(r'PART', r'left', text, 1)
|
text = text[:-1]
|
||||||
rcon.command('say ' + text[:-2])
|
text = text[1:]
|
||||||
|
text = text + ' left irc'
|
||||||
|
if 'JOIN' in text:
|
||||||
|
text = re.search(r':.*!', text).group(0)
|
||||||
|
text = text[:-1]
|
||||||
|
text = text[1:]
|
||||||
|
text = text + ' joined irc'
|
||||||
|
rcon.command('say ' + text)
|
||||||
|
|
||||||
elif 'PING' in text:
|
elif 'PING' in text:
|
||||||
print('pinged by server, returning pong')
|
print('pinged by server, returning pong')
|
||||||
|
|
|
@ -89,7 +89,7 @@ def mc_to_irc():
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
latest_lines = file.readlines()
|
latest_lines = file.readlines()
|
||||||
for line in latest_lines:
|
for line in latest_lines:
|
||||||
if re.search('\[Async Chat Thread -.*?/INFO', line) is not None :
|
if re.search('\[Async Chat Thread -.*?/INFO', line) is not None and ': [GriefPrevention] ' not in line:
|
||||||
print('received ' + ''.join(line))
|
print('received ' + ''.join(line))
|
||||||
line = re.sub(r'', r'^[', line)
|
line = re.sub(r'', r'^[', line)
|
||||||
line = re.sub(r'\^.*?m', '', line)
|
line = re.sub(r'\^.*?m', '', line)
|
||||||
|
@ -126,10 +126,11 @@ def mc_to_irc():
|
||||||
print('sent ' + line)
|
print('sent ' + line)
|
||||||
irc.send(bytes('PRIVMSG ' + channel + ' :' + line, 'utf8'))
|
irc.send(bytes('PRIVMSG ' + channel + ' :' + line, 'utf8'))
|
||||||
|
|
||||||
elif 'left the game' in line and 'IRC ' not in line:
|
elif 'left the game' in line and '[Server thread/INFO]: [Rcon] ' not in line:
|
||||||
print('received ' + ''.join(line))
|
print('received ' + ''.join(line))
|
||||||
line = re.sub(r'', r'^[', line)
|
line = re.sub(r'', r'^[', line)
|
||||||
line = re.sub(r'\[.*?: ', '', line, 1)
|
line = re.sub(r'\[.*?: ', '', line, 1)
|
||||||
|
line = re.sub(r'left the game', 'logged off', line, 1)
|
||||||
line = re.sub(r'\[/.*?\]', '', line, 1)
|
line = re.sub(r'\[/.*?\]', '', line, 1)
|
||||||
line = re.sub(r'> ', '', line, 1)
|
line = re.sub(r'> ', '', line, 1)
|
||||||
line = re.sub(r'lost connection: Disconnected', 'disconnected', line, 1)
|
line = re.sub(r'lost connection: Disconnected', 'disconnected', line, 1)
|
||||||
|
@ -153,7 +154,7 @@ def mc_to_irc():
|
||||||
print('sent ' + line)
|
print('sent ' + line)
|
||||||
if '@tilde.town:' not in line:
|
if '@tilde.town:' not in line:
|
||||||
irc.send(bytes('PRIVMSG ' + channel + ' :' + line, 'utf8'))
|
irc.send(bytes('PRIVMSG ' + channel + ' :' + line, 'utf8'))
|
||||||
elif any(death in line for death in death_messages):
|
elif any(' ' + death + ' ' in line for death in death_messages) and 'Villager EntityVillager[\'' not in line:
|
||||||
line = re.sub(r'^\[.*\]: ', '', line, 1)
|
line = re.sub(r'^\[.*\]: ', '', line, 1)
|
||||||
print('sent ' + line)
|
print('sent ' + line)
|
||||||
irc.send(bytes('PRIVMSG ' + channel + ' :' + line, 'utf8'))
|
irc.send(bytes('PRIVMSG ' + channel + ' :' + line, 'utf8'))
|
||||||
|
@ -166,7 +167,7 @@ def irc_to_mc():
|
||||||
rcon_password_file = open('rcon_password', 'r')
|
rcon_password_file = open('rcon_password', 'r')
|
||||||
rcon_password = rcon_password_file.readline().strip()
|
rcon_password = rcon_password_file.readline().strip()
|
||||||
rcon_password_file.close()
|
rcon_password_file.close()
|
||||||
rcon.connect('209.182.234.192', 6668, rcon_password)
|
rcon.connect('0.0.0.0', 6668, rcon_password)
|
||||||
print('initiated rcon connection')
|
print('initiated rcon connection')
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
|
@ -234,13 +235,19 @@ def irc_to_mc():
|
||||||
|
|
||||||
|
|
||||||
elif 'JOIN' in text or 'PART' in text:
|
elif 'JOIN' in text or 'PART' in text:
|
||||||
text = re.sub(r':.*?\!', r'', text, 1)
|
print("-- JOIN EVENT --")
|
||||||
text = re.sub(r'@localhost', r'', text, 1)
|
print(text)
|
||||||
text = re.sub(r':WeeChat.*', r'', text, 1)
|
if 'PART' in text:
|
||||||
text = re.sub(r'JOIN', r'joined', text, 1)
|
text = re.search(r':.*!', text).group(0)
|
||||||
text = re.sub(r'PART', r'left', text, 1)
|
text = text[:-1]
|
||||||
rcon.command('say ' + text[:-2])
|
text = text[1:]
|
||||||
|
text = text + ' left irc'
|
||||||
|
elif 'JOIN' in text:
|
||||||
|
text = re.search(r':.*!', text).group(0)
|
||||||
|
text = text[:-1]
|
||||||
|
text = text[1:]
|
||||||
|
text = text + ' joined irc'
|
||||||
|
rcon.command('say ' + text)
|
||||||
elif 'PING' in text:
|
elif 'PING' in text:
|
||||||
print('pinged by server, returning pong')
|
print('pinged by server, returning pong')
|
||||||
irc.send(b'PONG ' + text.split()[1].encode() + b'\r\n')
|
irc.send(b'PONG ' + text.split()[1].encode() + b'\r\n')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user