def handle_command(command, channel):
    """
        Executes bot command if the command is known
    """
    # Default response is help text for the user
    default_response = "Not sure what you mean. Try *{}*.".format(
        EXAMPLE_COMMAND)

    # Finds and executes the given command, filling in response
    response = None
    # This is where you start to implement more commands!
    if command.startswith(EXAMPLE_COMMAND):
        response = "Sure...write some more code then I can do that!"
    if 'weather' in command:
        response = weather.current_weather()
        #print(response)
    if 'joke' in command:
        response = jokes.get_joke()
    if 'quote' in command or 'motivation' in command:
        response = quotes.get_quote()
        #print(response)
    # Sends the response back to the channel
    slack_client.api_call("chat.postMessage",
                          channel=channel,
                          text=response or default_response)
Example #2
0
def inspire(update, context):
    """Send a quote"""

    quote = quotes.get_quote()
    lad_bot.send_message(chat_id=update.effective_chat.id, text=f"{r.choice(msgs).replace('_', 'quote')}, 
    {update.message.from_user.first_name}:", disable_notification=True)
    sleep(1)
    lad_bot.send_message(chat_id=update.effective_chat.id, text=f"<i><b>{quote}</b></i>", parse_mode='HTML', disable_notification=True)

    print(f"{update.message.from_user.first_name} {update.message.from_user.last_name} 
    (username: {update.message.from_user.username}) was inspired.")
Example #3
0
def main_content(fonts):
    f_list = ""
    for font in fonts:
        f_with_ext = os.path.basename(font)
        f_without_ext = os.path.splitext(f_with_ext)[0]
        f_list = f_list + '''
        <li>
            <p class = "font-title">{}</p>
            <p class = "font-preview" contenteditable = "true" spellcheck="false" style = "font-family : {};">{}</p>
        </li>
        '''.format(str(f_without_ext[0:35]), str(f_without_ext),
                   quotes.get_quote())
    return f_list
Example #4
0
File: io.py Project: milosi92/xbot
def read(bot):
	global Bot
	Bot = bot
	if bot.remote['nick'] and bot.remote['nick'] != bot.nick:
		if bot.remote['message'].startswith("!"):
			args = bot.remote['message'][1:].rstrip().split(" ")
			command = args[0].lower()
			alibrary = {
				'reload':		lambda: bot._reload(args),
				'voice':		lambda: voice(args),
				'nick':			lambda: cnick(args),
				'release':		lambda: release(args),
				'identify':		lambda: ident(),
				'join':			lambda: join(args),
				'part':			lambda: part(args),
				'kick':			lambda: kick(args),
				'mode':			lambda: mode(args),
				'perms':		lambda: perms(args),
				'eval':			lambda: reply(bot.remote['sendee'], eval.parse(bot, args)),
				'raw':			lambda: raw(args)
			}
			clibrary = {
				'topic':		lambda: topic(bot, args),
				'help':			lambda: "Available commands: %s" % ', '.join(sorted(clibrary.keys())),
				'abort':		lambda: abort(args),
				'time':			lambda: time(bot, args),
				'say':			lambda: say(bot, args),
				'calc':			lambda: wolframalpha.wa(bot, args),
				'go':			lambda: googleapi.search(bot, args),
				'wiki':			lambda: wikipedia.wiki(bot, args),
				'tell':			lambda: tell.answer(bot, args),
				'twss':			lambda: fun.twss(bot, args),
				'cookie':		lambda: fun.cookie(bot, args),
				'choose':		lambda: fun.choose(bot, args),
				'8ball':		lambda: fun.m8b(bot, args),
				'quotes':		lambda: quotes.get_quote(bot, args),
				'js':			lambda: js.execute(bot, args),
				'benis':		lambda: fun.benis(bot, args),
				'tr':			lambda: translate.translate(bot, args),
				'nab':			lambda: fun.nab(bot, args),
				'frites':		lambda: fun.frites(bot, args),
				'etym':			lambda: etymology.etym(bot, args),
				'mrpass':		lambda: fun.monsieurp(bot, args),
				'sysinfo':		lambda: fun.sysinfo(bot, args),
				'ud':			lambda: ud.ud(bot, args)
			}
			if bot.remote['nick'].lower() not in bot.inv['banned']:
				if command in alibrary:
					if bot.remote['host'] in [host.strip() for host in bot.config.get(bot.network, 'admin_hostnames').split(',')]:
						alibrary[command]()
						bot.previous['user'] = bot.remote['sendee']
					else:
						if bot.voice:
							reply(bot.remote['sendee'], "%s: Can't do that, noob." % bot.remote['nick'])
				elif bot.voice and command in clibrary:
					result = execute(command, clibrary[command])
					bot.previous['user'] = bot.remote['sendee']
					if result:
						reply(bot.remote['sendee'], result)
		elif bot.remote['message'].startswith("\x01") and bot.remote['message'].endswith("\x01"):
			type = bot.remote['message'][1:-1].split()[0]
			args = bot.remote['message'][1:-1].split()[1:]
			if type != "ACTION":
				ctcp(type, args)
		elif bot.remote['mid'] == "INVITE" and bot.remote['nick'].lower() not in bot.inv['banned']:
			join(bot.remote['message'])
		else:
			if bot.init['registered'] and not bot.init['identified']:
				if bot.remote['nick'] == "NickServ":
					if "registered" in bot.remote['message']:
						bot._login()
					elif "identified" in bot.remote['message']:
						bot.init['identified'] = True
						__import__('time').sleep(3)
						autojoin()

			if bot.voice:
				# start scanning messages for certain data
				result = execute(None, scanner.scan, bot)
				if result:
					reply(bot.remote['sendee'], result)

	else:
		if (bot.remote['mid'].startswith("4") or bot.remote['mid'].startswith("5")) and bot.remote['mid'] != "462":
			reply(bot.previous.get('user') or bot.admin, "Message from %s: Error #%s: %s" % (bot.remote['server'], bot.remote['mid'], bot.remote['message']))
		if not bot.init['joined'] and not bot.init['registered']:
			autojoin()
Example #5
0
def upload_insta(path):
    InstagramAPI.login()
    caption = get_quote()
    InstagramAPI.uploadPhoto(path, caption=caption)
Example #6
0
import time
from datetime import datetime
from PIL import Image
import pygame
from pygame.locals import *
from quotes import get_quote
import os
port_GPIO_BLUE = 19
port_GPIO_YELLOW = 13
port_GPIO_GREEN = 6
port_GPIO_RED = 5
up_face_script = "/home/pi/livrogne_backup/photomaton/graphAPI/up_facebook.js"
last_photo = ""
last_insta_photo = ""
last_face_photo = ""
print(get_quote())
GPIO.setmode(GPIO.BCM)

pygame.init()
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
width, height = screen.get_size()

user, pwd = 'livrognebar', 'azerty123'
InstagramAPI = InstagramAPI(user, pwd)


def upload_face(path):
    os.system(up_face_script + " " + path)


def upload_insta(path):
Example #7
0
def home():
    quote = get_quote()
    return f"{quote[0]} -- {quote[1]}"
Example #8
0
def json_quote():
    quote = get_quote()
    return {'quote': quote[0], 'author': quote[1]}
Example #9
0
File: io.py Project: ejrh/xbot
def read(bot):
	global Bot
	Bot = bot
	if bot.remote['nick'] and bot.remote['nick'] != bot.nick:
		if bot.remote['message'].startswith("!"):
			args = bot.remote['message'][1:].rstrip().split(" ")
			command = args[0].lower()
			alibrary = {
				'reload':		lambda: bot._reload(args),
				'voice':		lambda: voice(args),
				'nick':			lambda: cnick(args),
				'release':		lambda: release(args),
				'identify':		lambda: ident(),
				'join':			lambda: join(args),
				'part':			lambda: part(args),
				'kick':			lambda: kick(args),
				'mode':			lambda: mode(args),
				'perms':		lambda: perms(args),
				'eval':			lambda: reply(bot.remote['sendee'], eval.parse(bot, args)),
				'raw':			lambda: raw(args)
			}
			clibrary = {
				'topic':		lambda: topic(bot, args),
				'help':			lambda: "Available commands: %s" % ', '.join(sorted(clibrary.keys())),
				'time':			lambda: time(bot, args),
				'say':			lambda: say(bot, args),
				'calc':			lambda: wolframalpha.wa(bot, args),
				'go':			lambda: googleapi.search(bot, args),
				'lookup':		lambda: dnstools.lookup(bot, args),
				'wiki':			lambda: dnstools.wiki(bot, args),
				'tell':			lambda: tell.answer(bot, args),
				'twss':			lambda: fun.twss(bot, args),
				'cookie':		lambda: fun.cookie(bot, args),
				'spin':			lambda: fun.spin(bot, args),
				'man':			lambda: man.man(bot, args),
				'choose':		lambda: fun.choose(bot, args),
				'8ball':		lambda: fun.m8b(bot, args),
				'ghetto':		lambda: fun.ghetto(bot, args),
				'sortinghat': 	lambda: fun.sorting_hat(bot, args),
				'lotto':		lambda: lotto.get_results(bot, args),
				'quotes':		lambda: quotes.get_quote(bot, args),
				'imdb':			lambda: imdb.info(bot, args),
				'usage':		lambda: usage.usage(bot, args),
				'maxx':			lambda: maxx.times(bot, args),
				'js':			lambda: js.execute(bot, args)
			}
			if bot.remote['nick'].lower() not in bot.inv['banned']:
				if command in alibrary:
					if bot.remote['host'] in [host.strip() for host in bot.config.get(bot.network, 'admin_hostnames').split(',')]:
						alibrary[command]()
						bot.previous['user'] = bot.remote['sendee']
					else:
						if bot.voice:
							reply(bot.remote['sendee'], "%s: Can't do that, noob." % bot.remote['nick'])
				elif bot.voice and command in clibrary:
					try: result = clibrary[command]()
					except __import__('urllib2').HTTPError: result = "!%s: derping the herp" % args[0]
					except (__import__('urllib2').URLError, __import__('socket').timeout): result = "!%s: response timeout exceeded." % args[0]
					bot.previous['user'] = bot.remote['sendee']
					if result:
						reply(bot.remote['sendee'], result)
		elif bot.remote['message'].startswith("\x01") and bot.remote['message'].endswith("\x01"):
			type = bot.remote['message'][1:-1].split()[0]
			args = bot.remote['message'][1:-1].split()[1:]
			if type != "ACTION":
				ctcp(type, args)
		else:
			if bot.init['registered'] and not bot.init['identified']:
				if bot.remote['nick'] == "NickServ":
					if "registered" in bot.remote['message']:
						bot._login()
					elif "identified" in bot.remote['message']:
						bot.init['identified'] = True
						__import__('time').sleep(3)
						autojoin()
			
			if bot.voice:
				# start scanning messages for certain data
				try: response = scanner.scan(bot)
				except (__import__('urllib2').URLError, __import__('socket').timeout): response = "fetch: response timeout exceeded."
				if response:
					reply(bot.remote['sendee'], response)

	else:
		if (bot.remote['mid'].startswith("4") or bot.remote['mid'].startswith("5")) and bot.remote['mid'] != "462":
			reply(bot.previous['user'], "Message from %s: Error #%s: %s" % (bot.remote['server'], bot.remote['mid'], bot.remote['message']))
		if not bot.init['joined'] and not bot.init['registered']:
			autojoin()
Example #10
0
from twilio.rest import Client
from quotes import get_quote
import requests

message = get_quote()

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'AC4061e8f2577e9ccdf3bd0bee5158b191'
auth_token = 'd078e586a4e7e12cc50321d73b3632d0'
client = Client(account_sid, auth_token)

message = client.messages \
                .create(
                     body=message,
                     from_='+18315402050',
                     to='+14087592181'
                 )

print(message.sid)