Beispiel #1
0
 def __init__(self):
   BotMod.__init__(self, "audio")
   self.cmds = [
     BotCmd("ping",callee=self.cmd_ping),
     BotCmd("query_state",callee=self.cmd_query_state),
     BotCmd("query_active",callee=self.cmd_query_active),
     BotCmd("query_location",callee=self.cmd_query_location),
     BotCmd("query_listen_url",callee=self.cmd_query_listen_url)
   ]
   listen_url = 'http://%H:8000/pifon'
   location_name = '%h'
   self.opts = [
     BotOptField('sim', bool, False, desc='enable level simulator'),
     BotOptField('trace', bool, False, desc='enable level tracing'),
     BotOptField('listen_url', str, listen_url, desc='url of audio stream'),
     BotOptField('location', str, location_name, desc='location of audio source'),
     BotOptField('alevel', int, 1, val_range=[1,100], desc='audio level to reach in attack phase [1-100]'),
     BotOptField('slevel', int, 1, val_range=[1,100], desc='audio level to stay below in sustain phase [1-100]'),
     BotOptField('attack', int, 3, val_range=[1,10], desc='period [1s] of loudness required to start playback'),
     BotOptField('sustain', int, 10, val_range=[0,60], desc='period [1s] of silence required to stop playback'),
     BotOptField('respite', int, 10, val_range=[0,60], desc='delay [1s] after playback to wait for next'),
     BotOptField('update', int, 5, val_range=[1,60], desc='update interval of current peak level [100ms]')
   ]
   self.events = [
     ConnectEvent(self.on_connected),
     DisconnectEvent(self.on_disconnected),
     TickEvent(self.on_tick)
   ]
   self._setup_tags()
Beispiel #2
0
 def __init__(self, name="info", listener=None, tick=1):
     BotMod.__init__(self, name)
     self.events = [
         ConnectEvent(self.on_connect),
         DisconnectEvent(self.on_disconnect),
         PeerConnectEvent(self.on_peer_connect),
         PeerDisconnectEvent(self.on_peer_disconnect),
         ModListEvent(self.on_modlist),
         PeerModListEvent(self.on_peer_modlist),
         TickEvent(self.on_tick),
         StartEvent(self.on_start),
         StopEvent(self.on_stop),
         # custom events
         BotEvent("audio", "level", arg_types=(int, int, int), callee=self.event_audio_level),
         BotEvent("audio", "state", arg_types=(str,), callee=self.event_audio_state),
         BotEvent("audio", "active", arg_types=(bool,), callee=self.event_audio_active),
         BotEvent("audio", "listen_url", arg_types=(str,), callee=self.event_audio_listen_url),
         BotEvent("audio", "location", arg_types=(str,), callee=self.event_audio_location),
         BotEvent("pinger", "check", arg_types=(str, str), callee=self.event_pinger_check),
         BotEvent("player", "play", arg_types=(str, str), callee=self.event_player_play),
         BotEvent("player", "stop", arg_types=(str,), callee=self.event_player_stop),
         BotEvent("player", "mode", arg_types=(str, str), callee=self.event_player_mode),
         BotEvent("player", "chime", arg_types=(bool,), callee=self.event_player_chime),
     ]
     self.audios = {}
     self.pending_audios = {}
     self.players = {}
     self.pending_players = {}
     self.listener = listener
     self.tick = tick
     self.ping_lost = []
     self.non_idle_audios = []
     self.primary_non_idle_audio = None
     self.active_audios = []
     self.primary_active_audio = None
Beispiel #3
0
 def __init__(self):
     BotMod.__init__(self, "pinger")
     self.cmds = [BotCmd("query", arg_types=(str,), callee=self.cmd_query)]
     self.opts = [BotOptField("interval", int, 10, desc="check interval for pings")]
     self.events = [
         BotEvent("bot", "pong", callee=self.event_pong),
         PeerConnectEvent(self.on_peer_connect),
         PeerDisconnectEvent(self.on_peer_disconnect),
         PeerModListEvent(self.on_peer_modlist),
         TickEvent(self.on_tick),
     ]
     self.ping_map = {}
Beispiel #4
0
 def __init__(self):
     BotMod.__init__(self, "pinger")
     self.cmds = [BotCmd("query", arg_types=(str, ), callee=self.cmd_query)]
     self.opts = [
         BotOptField("interval", int, 10, desc="check interval for pings"),
     ]
     self.events = [
         BotEvent("bot", "pong", callee=self.event_pong),
         PeerConnectEvent(self.on_peer_connect),
         PeerDisconnectEvent(self.on_peer_disconnect),
         PeerModListEvent(self.on_peer_modlist),
         TickEvent(self.on_tick)
     ]
     self.ping_map = {}
Beispiel #5
0
 def __init__(self):
   BotMod.__init__(self, "test")
   self.cmds = [
     BotCmd("hello",callee=self.cmd_hello)
   ]
   self.opts = [
     BotOptField("abool",bool,True,desc="a boolean"),
     BotOptField("anint",int,42, val_range=[1,100], desc="an integer"),
     BotOptField("astr",str,"hoo!", desc="a string")
   ]
   self.events = [
     BotEvent("echo","hello",callee=self.event_echo_hello),
     ConnectEvent(self.on_connect),
     DisconnectEvent(self.on_disconnect),
     TickEvent(self.on_tick)
   ]
Beispiel #6
0
 def __init__(self):
   BotMod.__init__(self, "player")
   self.cmds = [
     BotCmd("mute",callee=self.cmd_mute),
     BotCmd("monitor",callee=self.cmd_monitor),
     BotCmd("listen",callee=self.cmd_listen,arg_types=(str,)),
     BotCmd("chime",callee=self.cmd_chime,arg_types=(bool,)),
     BotCmd("query_mode",callee=self.cmd_query_mode),
     BotCmd("query_chime",callee=self.cmd_query_chime)
   ]
   self.events = [
     PeerModListEvent(self.on_peer_modlist),
     PeerDisconnectEvent(self.on_peer_disconnected),
     StopEvent(self.on_stop),
     BotEvent("audio","active",callee=self.on_player_active,arg_types=(bool,)),
     BotEvent("audio","listen_url",callee=self.on_player_listen_url,arg_types=(str,)),
   ]
   self.audio_peers = []
Beispiel #7
0
 def __init__(self):
     BotMod.__init__(self, "player")
     self.cmds = [
         BotCmd("mute", callee=self.cmd_mute),
         BotCmd("monitor", callee=self.cmd_monitor),
         BotCmd("listen", callee=self.cmd_listen, arg_types=(str, )),
         BotCmd("chime", callee=self.cmd_chime, arg_types=(bool, )),
         BotCmd("query_mode", callee=self.cmd_query_mode),
         BotCmd("query_chime", callee=self.cmd_query_chime)
     ]
     self.events = [
         PeerModListEvent(self.on_peer_modlist),
         PeerDisconnectEvent(self.on_peer_disconnected),
         StopEvent(self.on_stop),
         BotEvent("audio",
                  "active",
                  callee=self.on_player_active,
                  arg_types=(bool, )),
         BotEvent("audio",
                  "listen_url",
                  callee=self.on_player_listen_url,
                  arg_types=(str, )),
     ]
     self.audio_peers = []
Beispiel #8
0
 def __init__(self):
   BotMod.__init__(self, "echo")
   self.cmds = [
     BotCmd("echo",callee=self.cmd_echo)
   ]
Beispiel #9
0
 def __init__(self, name="info", listener=None, tick=1):
     BotMod.__init__(self, name)
     self.events = [
         ConnectEvent(self.on_connect),
         DisconnectEvent(self.on_disconnect),
         PeerConnectEvent(self.on_peer_connect),
         PeerDisconnectEvent(self.on_peer_disconnect),
         ModListEvent(self.on_modlist),
         PeerModListEvent(self.on_peer_modlist),
         TickEvent(self.on_tick),
         StartEvent(self.on_start),
         StopEvent(self.on_stop),
         # custom events
         BotEvent("audio",
                  "level",
                  arg_types=(int, int, int),
                  callee=self.event_audio_level),
         BotEvent("audio",
                  "state",
                  arg_types=(str, ),
                  callee=self.event_audio_state),
         BotEvent("audio",
                  "active",
                  arg_types=(bool, ),
                  callee=self.event_audio_active),
         BotEvent("audio",
                  "listen_url",
                  arg_types=(str, ),
                  callee=self.event_audio_listen_url),
         BotEvent("audio",
                  "location",
                  arg_types=(str, ),
                  callee=self.event_audio_location),
         BotEvent("pinger",
                  "check",
                  arg_types=(str, str),
                  callee=self.event_pinger_check),
         BotEvent("player",
                  "play",
                  arg_types=(str, str),
                  callee=self.event_player_play),
         BotEvent("player",
                  "stop",
                  arg_types=(str, ),
                  callee=self.event_player_stop),
         BotEvent("player",
                  "mode",
                  arg_types=(str, str),
                  callee=self.event_player_mode),
         BotEvent("player",
                  "chime",
                  arg_types=(bool, ),
                  callee=self.event_player_chime)
     ]
     self.audios = {}
     self.pending_audios = {}
     self.players = {}
     self.pending_players = {}
     self.listener = listener
     self.tick = tick
     self.ping_lost = []
     self.non_idle_audios = []
     self.primary_non_idle_audio = None
     self.active_audios = []
     self.primary_active_audio = None
Beispiel #10
0
 def __init__(self):
     BotMod.__init__(self, "echo")
     self.cmds = [BotCmd("echo", callee=self.cmd_echo)]