Esempio n. 1
0
def telegramAssistant(telegramProcess):

    telegramCommand = sendCommand()

    if 'kill telegram' in telegramCommand:
        telegramProcess.kill()
        jasminResponse(_('Closing Telegram Sir.'))
        print 'Telegram Process: ', telegramProcess.pid

    elif 'open chat' in telegramCommand:
        reg_ex = re.search('open (.*) (.+)', telegramCommand)
        if reg_ex:
            chatName = reg_ex.group(2)
            print(chatName)
            keyboard = Controller()
            keyboard.type(chatName)
            keyboard.press(Key.enter)
            keyboard.release(Key.enter)
            time.sleep(0.8)
            keyboard.press(Key.ctrl_l)
            keyboard.press('f')
            keyboard.release('f')
            keyboard.release(Key.ctrl_l)
            time.sleep(0.5)
            keyboard.press(Key.ctrl_l)
            keyboard.press('a')
            keyboard.release('a')
            keyboard.release(Key.ctrl_l)
    
    if telegramCommand == 'kill telegram':
        return
    else:
        telegramAssistant(telegramProcess)
Esempio n. 2
0
def playSong():
    
    path = MUSIC_LIBRARY_PATH
    jasminResponse("What song should I play?")
    song_choice = sendCommand()
    
    if song_choice:
        song_found = 0
        url = "https://www.youtube.com/results?search_query=" + song_choice.replace(' ', '+')
        final_url = ''
        response = urllib2.urlopen(url)
        html = response.read()
        parsed_html = soup(html,"lxml")
        video_list = parsed_html.findAll(attrs={'class':'yt-uix-tile-link'})

        if len(video_list) > 0:

            final_url = 'https://www.youtube.com' + video_list[0]['href']

            if (final_url).startswith("https://www.youtube.com/watch?v="):
                song_found = 1
        
        os.chdir(path)
        ydl_opts = {}

        with youtube_dl.YoutubeDL(ydl_opts) as ydl:
            ydl.download([final_url])
        
        player = vlc.MediaPlayer(path)
        player.play()

        if song_found == 0:
            jasminResponse("I didn't find the song you are looking for.")
            playSong()
Esempio n. 3
0
def tellCurrentTime():
    now = datetime.datetime.now()
    jasminResponse(
        _('Current time is %(hour)d hours %(mins)d minutes') %
        ({
            'hour': now.hour,
            'mins': now.minute
        }))
Esempio n. 4
0
def openWebsite(command):
    reg_ex = re.search('open website (.+)', command)
    if reg_ex:
        domain = reg_ex.group(1)
        print(domain)
        url = url = 'https://www.' + domain
        webbrowser.open(url)
        jasminResponse(domain + _(' has been opened for you Sir.'))
Esempio n. 5
0
def openReddit(command):
    reg_ex = re.search('open reddit (.*)', command)
    url = 'https://www.reddit.com/'
    if reg_ex:
        subreddit = reg_ex.group(1)
        url = url + 'r/' + subreddit
    webbrowser.open(url)
    jasminResponse(_('The Reddit content has been opened for you Sir.'))
Esempio n. 6
0
def openApplication(input):

    if 'google chrome' in input:
        os.system('google-chrome')
        jasminResponse(_('Google Chrome was open for you Sir.'))
    elif 'launch app' in input:
        reg_ex = re.search('launch app (.*)', input)
        if reg_ex:
            appname = reg_ex.group(1)
            subprocess.Popen(appname)
        jasminResponse(_('I have launched the desired application'))
Esempio n. 7
0
def sayWeatherConditions(city):
    openWeatherMap = OWM(API_key=OWM_KEY)
    observation = openWeatherMap.weather_at_place(city)
    weather = observation.get_weather()
    status = weather.get_status()
    temperature = weather.get_temperature(unit='celsius')
    response = _("Current weather in %(city)s is %(status)s. The maximum temperature is %(temp_max)0.1f and the minimum temperature is %(temp_min)0.1f degree celcius") % ({
                  'city': city, 
                  'status': status, 
                  'temp_max': temperature['temp_max'], 
                  'temp_min': temperature['temp_min']
                  })
    jasminResponse(response)
Esempio n. 8
0
def sendEmail():
    jasminResponse(_('Who is the recipient?'))
    recipient = sendCommand()
    if 'myself' in recipient:
        jasminResponse(_('What should I say to him?'))
        body = sendCommand()
        jasminResponse(_('What is the subject?'))
        subject = sendCommand()
        content = 'Subject: {}\n\n{}'.format(subject,body)

        mail = smtplib.SMTP('smtp.gmail.com', 587)
        mail.ehlo()
        mail.starttls()
        mail.login(constants.EMAIL_ADDR, constants.EMAIL_SECRET)
        mail.sendmail(constants.EMAIL_ADDR, constants.EMAIL_RECIPIENT, content)
        mail.close()
        jasminResponse(_("Email has been sent successfully."))
    else:
        jasminResponse(_("I don't know what you mean!"))
Esempio n. 9
0
def openTelegram():
    telegramProcess = subprocess.Popen("telegram")
    jasminResponse(_('Telegram ready as always.'))
    print 'Telegram Process: ', telegramProcess.pid
    telegram.telegramAssistant(telegramProcess)