summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Perry <nathan@meta.sc>2016-04-27 20:05:13 -0400
committerNathan Perry <nathan@meta.sc>2016-04-27 20:05:13 -0400
commitb5cf5bfaf4f56719dd0755a3c93f4ab768231173 (patch)
tree752844b2fb20aeafbf11cb58d5ed665d99056ffb
parent775b1162ac6be51d6375b21e00132e7185e48e0a (diff)
hopefully stabilize by catching exceptions
-rwxr-xr-x[-rw-r--r--].gitignore1
-rwxr-xr-x[-rw-r--r--]bot.py28
2 files changed, 27 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index f51256b..e9da0b3 100644..100755
--- a/.gitignore
+++ b/.gitignore
@@ -62,3 +62,4 @@ target/
.ipynb_checkpoints
config.yml
+*.out
diff --git a/bot.py b/bot.py
index 919f396..d573dba 100644..100755
--- a/bot.py
+++ b/bot.py
@@ -61,6 +61,7 @@ async def on_message(message):
'sudoku': stop_client,
'pause': pause,
'resume': resume,
+ 'help': partial(print_help, message.channel),
'list': partial(list_queued, message.channel),
'queue': partial(list_queued, message.channel),
}
@@ -129,6 +130,23 @@ async def stop_client():
await stop_player()
+async def print_help(channel):
+ help_msg = """wew lad. you should know these commands already.
+
+Usage: `!thulani [command]`
+
+commands:
+**help**:\t\t\t\tprint this help message
+**[url]**:\t\t\t a url with media that thulani can play. queued up to play after everything that's already waiting.
+**list, queue**:\tlist items in the queue, as well as the currently-playing item.
+**pause**:\t\t\tpause sound.
+**resume**:\t\t resume sound.
+**die**:\t\t\t\t empty the queue and stop playing.
+**skip**:\t\t\t skip the current item."""
+
+ ensure_future(client.send_message(channel, help_msg))
+
+
async def enqueue_video(url, message):
await connect_voice()
@@ -244,7 +262,12 @@ async def run_video():
else:
break
- await connect_voice()
+ try:
+ await connect_voice()
+ except Exception:
+ logger.exception('waiting to connect voice')
+ ensure_future(run_video())
+ return
if not client.is_voice_connected():
raise Exception('unable to connect to voice!')
@@ -272,12 +295,13 @@ async def run_video():
if has_slept:
vid_logger.debug('awoken')
- ensure_future(run_video())
+ ensure_future(run_video())
ensure_future(run_video())
loop = get_event_loop()
+loop.set_debug(True)
try:
loop.run_until_complete(client.start(config['username'], config['password']))
except KeyboardInterrupt: