communication.tin

communication.tin
#python
 
from pyLib import communication
 
#gts
 
#action {^EMOTE:%1:EMOTE$} {
	#echo {%s} {%1};
	#line {strip} {
		#regexp {%1} {^%w %+$} {
			#if {!&communicationIgnoreList[&1]} {
				#line {log} {communication/says.txt} {&0};
			}
		}
	};
	#line {gag}
}
 
#action {^{TELL|SAY|NARRATE|PRAY}:%2:{@@}$} {
	#echo {%s} {%2};
	#line {strip} {
		#regexp {%2} {^{(The voice of )?}%w {(narrates|says|prays|tells you|tells the group|whispers to you[,]?|asks you)} '%+'$} {
			#if {!&communicationIgnoreList[&3]} {
				#if {"%1" == "PRAY"} {#line {log} {communication/prays.txt} {&0}};
				#elseif {"%1" == "SAY"} {#line {log} {communication/says.txt} {&0}};
				#elseif {"%1" == "TELL"} {
					#line {log} {communication/tells.txt} {&0};
					#if {"&5" == "tells you"} {#var {replyTo} {&3}};
					playsound tells.wav
				};
				#elseif {"%1" == "NARRATE"} {
					#line {log} {communication/narrates.txt} {&0};
					playsound narrates.wav
				}
			}
		}
	};
	#line {gag}
}
 
#alias {pl} {#python communication.review("prays", "%0")}
#alias {nl} {#python communication.review("narrates", "%0")}
#alias {sl} {#python communication.review("says", "%0")}
#alias {tl} {#python communication.review("tells", "%0")}
 
#alias {rep} {
	#if {"$replyTo" != ""} {#send {tell $replyTo %0}};
	#else {#echo {No one to reply to.}}
}
 
#var {replyTo} {}
 
#var communicationIgnoreList[Aldereon] {true}
#var communicationIgnoreList[Anarwen] {true}
#var communicationIgnoreList[Angdil] {true}
#var communicationIgnoreList[Barliman] {true}
#var communicationIgnoreList[Celeborn] {true}
#var communicationIgnoreList[Celebrindal] {true}
#var communicationIgnoreList[Ciryariel] {true}
#var communicationIgnoreList[Clint] {true}
#var communicationIgnoreList[Curundil] {true}
#var communicationIgnoreList[Daegil] {true}
#var communicationIgnoreList[Ecthelion] {true}
#var communicationIgnoreList[Elrond] {true}
#var communicationIgnoreList[Erienal] {true}
#var communicationIgnoreList[Fardur] {true}
#var communicationIgnoreList[Galadriel] {true}
#var communicationIgnoreList[Grinder] {true}
#var communicationIgnoreList[Haldir] {true}
#var communicationIgnoreList[Huor] {true}
#var communicationIgnoreList[Nagrorh] {true}
#var communicationIgnoreList[Nordri] {true}
#var communicationIgnoreList[Orophin] {true}
#var communicationIgnoreList[Sarion] {true}
#var communicationIgnoreList[Sauron] {true}
#var communicationIgnoreList[Gramps] {true}
communication.py
from .tintin import TinTin
 
permutations = {
  'N': [('Forostar', 'north'), ('Orrostar', 'east'), ('Hyarrostar', 'southeast'), ('Hyarnustar', 'southwest'), ('Andustar', 'west')],
  'E': [('Andustar', 'north'), ('Forostar', 'east'), ('Orrostar', 'southeast'), ('Hyarrostar', 'southwest'), ('Hyarnustar', 'west')],
  'SE': [('Hyarnustar', 'north'), ('Andustar', 'east'), ('Forostar', 'southeast'), ('Orrostar', 'southwest'), ('Hyarrostar', 'west')],
  'SW': [('Hyarrostar', 'north'), ('Hyarnustar', 'east'), ('Andustar', 'southeast'), ('Forostar', 'southwest'), ('Orrostar', 'west')],
  'W': [('Orrostar', 'north'), ('Hyarrostar', 'east'), ('Hyarnustar', 'southeast'), ('Andustar', 'southwest'), ('Forostar', 'west')],
}
 
def send_dirs(d):
  p = permutations.get(d.upper(), None)
  if not p:
    TinTin.echo("Haven't heard of a direction named {0}.  Try N, E, S, W, SE, or SW".format(d), 'mume')
    return
  for move in p:
    TinTin.send('move {0} {1}'.format(move[0], move[1]), 'mume')
  TinTin.send('move mittalmar centre', 'mume')
tintin.py
class TinTin(object):
	@staticmethod
	def execute(command, session="gts"):
		print("tintin_execute ({0}) {1}".format(session, command))
 
	@staticmethod
	def ticker(name, command, seconds, session="gts"):
		print("tintin_ticker ({0}) ({1}) ({2}) ({3})".format(session, name, command, seconds))
 
	@staticmethod
	def delay(name, command, seconds, session="gts"):
		print("tintin_delay ({0}) ({1}) ({2}) ({3})".format(session, name, command, seconds))
 
	@staticmethod
	def var(name, value, session="gts"):
		print("tintin_var ({0}) ({1}) ({2})".format(session, name, value))
 
	@staticmethod
	def send(command, session="gts"):
		print("tintin_send ({0}) {1}".format(session, command))
 
	@staticmethod
	def showme(command, session="gts"):
		print("tintin_showme ({0}) {1}".format(session, command))
 
	@staticmethod
	def echo(*args):
		if len(args) >= 2:
			session = args[-1]
			commands = ["({0})".format(command) for command in args[:-1]]
		else:
			session = "gts"
			commands = ["({0})".format(command) for command in args]
		commands = "{0}{1}".format(" ".join(commands), " ()" * (20-len(commands)))
		print("tintin_echo ({0}) {1}".format(session, commands))
  • tin/communication.tin.txt
  • Last modified: 2022-09-12 15:57
  • by Admin