def cmd_help(*args): """ Returns a list of available commands for the requesting user. :param args: [specified user, arguments for command] :type args: list :return: list of available commands that the current user has permission to execute :rtype: str """ user = args[0] help_msg = "Commands:\n" for cmd in _CMD_NAMES: if cm.has_permission(user, cmd): cmd_description = cm.sms()[cmd + '_description'] if cmd_description: help_msg += cmd_description + "\n" return help_msg
def cmd_vote(*args): """Casts a vote for the next song to be played :param args: [specified user, arguments for command] :type args: list :return: unknown command response :rtype: str """ user = args[0] args = args[1] if args.isdigit(): song_num = int(args) if user != 'Me' and 0 < song_num <= len(cm.songs()): song = cm.songs()[song_num - 1] song[2].add(user) logging.info('Song requested: ' + str(song)) return 'Thank you for requesting "' + song[0] \ + '", we\'ll notify you when it starts!' else: return cm.sms()['unknown_command_response']
def cmd_volume(*args): """Changes the system volume. :param args: [specified user, arguments for command] :type args: list :return: volume request result :rtype: str """ # Sanitize the input before passing to volume script args = args[1] if '-' in args: sanitized_cmd = '-' elif '+' in args: sanitized_cmd = '+' elif args.isdigit(): vol = int(args) if vol < 0 or vol > 100: return 'volume must be between 0 and 100' sanitized_cmd = str(vol) else: return cm.sms()['volume_description'] # Execute the sanitized command and handle result volscript = cm.HOME_DIR + '/bin/vol' output, error = subprocess.Popen(volscript + ' ' + sanitized_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() if error: logging.warn('volume request failed: ' + str(error)) return 'volume request failed' else: return 'volume = ' + str(output)
""" import argparse import commands import csv import fcntl import logging import sys import time from BeautifulSoup import BeautifulSoup import configuration_manager as cm from googlevoice import Voice # SMS Configurations _CONFIG = cm.sms() # First check to make sure SMS is enabled if _CONFIG['enable'].lower() != 'true': sys.exit() VOICE = Voice() """Setup your username and password in ~/.gvoice (or /root/.gvoice when running as root) file as follows to avoid being asked for your email and password each time: [auth] email=<google voice email address> password=<google voice password> """ # make sure we are logged in