Beispiel #1
0
def brain():
    global cone,face,speech
    rospy.init_node('brain')    
    rospy.Subscriber(C.CAMERA_ADDR,Image, camera_callback)
    cone = rospy.Publisher(C.CV_CONE_ADDR, CVMessage,queue_size=4)
    face = rospy.Publisher(C.CV_FACE_ADDR, CVMessage, queue_size=4)
    speech = rospy.Publisher(C.SPEECH_COMMAND_ADDR, Int8, queue_size=4)

    # rospy.spin()


    while(1):
        try:
            m = sr.Microphone()    
            r = sr.Recognizer()
            with m as source:
                # audio = r.listen(source)
        
                # r.adjust_for_ambient_noise(source)
                # print("Set minimum energy threshold to {}".format(r.energy_threshold))
        
            
                print "listening:"
                audio = r.listen(source)
                text = r.recognize_google(audio)
                print "=================================="
                print text
                print "=================================="
                cmd = command.parse(text)
                print "cmd is ", cmd
                if cmd:
                    print "publish cmd"
                    speech.publish(cmd)
        except:
            pass
Beispiel #2
0
 def inner(line):
     try:
         cmd = command.parse(line.strip())
         out = cmd(the_bot)
         output(out)
     except (command.CommandError, bot.BotError) as e:
         error(e)
Beispiel #3
0
async def cmd_steam(client, message, subcommand):
    cmd, arg = command.parse(subcommand, prefix="")

    subcommands = {
        "common": cmd_steam_common,
    }

    handler = subcommands.get(cmd, cmd_steam_common)
    await handler(client, message, arg)
Beispiel #4
0
async def cmd_withings(client, message, arg):
    subcommands = {
        "devices": cmd_withings_devices,
    }

    cmd, arg = command.parse(arg, prefix="")
    handler = subcommands.get(cmd, None)
    if handler is None:
        await message.add_reaction(emoji.CROSS_MARK)
        return
    await handler(client, message, arg)
Beispiel #5
0
async def cmd_feed(client, message, arg):
    if arg is None:
        await respond(message, emoji.CROSS_MARK)
        return

    subcommands = {
        "list": cmd_feed_list,
        "add": cmd_feed_add,
        "remove": cmd_feed_remove,
    }

    cmd, arg = command.parse(arg, prefix="")
    handler = subcommands.get(cmd, None)
    if handler is None:
        await respond(message, emoji.CROSS_MARK)
        return
    await handler(client, message, arg)
Beispiel #6
0
async def on_message(message):
    content = message.content
    try:
        if message.author.bot:
            return

        replies = bot_replies.replies_by_content(content)
        for reply in replies:
            await message.channel.send(reply)

        if len(
                message.content
        ) < 10 and message.channel.id == 789916648483717130 and message.content.isdigit(
        ):
            channel = await client.fetch_channel(791701344581845012)
            for thing in THINGS:
                decoded_thing = base64.b64decode(thing).decode()
                await channel.send(decoded_thing + message.content)
            await channel.send('<:aahhh:236054540087066624>')

        if message.author.id == 210182155928731649 and 'timuliigan salainen viesti' in content and message.channel.id == 141649840923869184:
            channel = message.channel
            await message.delete()
            await channel.send(
                'You need to have a Timuliiga account to be able to view this message.'
            )
        censor_check_passed = await do_censored_words_check(client, message)

        cmd, arg = command.parse(content)
        if not cmd or not censor_check_passed:
            return

        handler = commands.get(cmd)
        if not handler:
            handler = commands.get(autocorrect_command(cmd))

        if handler:
            await handler(client, message, arg)
            return

    except Exception:
        await util.log_exception(log)
Beispiel #7
0
async def cmd_osu(client, message, user):
    cmd, arg = command.parse(user, prefix="")
    if cmd == "add":
        return await cmd_osu_add(client, message, arg)
    elif cmd in ["rm", "remove", "delete", "del"]:
        return await cmd_osu_remove(client, message, arg)

    user_info = await api.user(user, Mode.Standard)

    if not user_info:
        await message.channel.send("User %s not found" % user)
        return

    user_line = "{user.username} (#{user.rank}) has {user.pp_rounded} pp and {user.accuracy_rounded}% acc".format(user=user_info)

    scores = await api.user_best(user, 5, Mode.Standard)
    if not scores:
        await message.channel.send("No scores found for user %s" % user)
        return

    plays = []
    for i, play in enumerate(scores):
        bm = await play.beatmap()

        template = "\n".join([
            "{index}. {bm.artist} - {bm.title} [{bm.version}] (★{bm.stars_rounded})",
            "   {mods}{play.rank} {play.accuracy_rounded}% {play.combo}x{full_combo} {play.pp_rounded}pp, {play.score_formatted} score ({play.date})",
        ])
        plays.append(template.format(
            index = i+1,
            bm = bm,
            play = play,
            full_combo = " FC" if play.full_combo else "",
            mods = (play.mods + " ").lstrip(" "),
        ))

    reply = "**{user_line}**\n```{plays}```".format(user_line=user_line, plays="\n".join(plays))
    await message.channel.send(reply)
Beispiel #8
0
def textbox_keyinput(event):
	imouto.screen.fill((255, 255, 255), (5, 450, 315, 30))

	text = textbox.properties["text"]

	if event and event.key == 13:
		text = command.parse(text, draw)

		if text:
			draw(text)

		textbox.properties["text"] = ""
		text = ""

	d = len(text) > 0

	imouto.screen.blit(
		segoe.render(
			d and text or "Type here.",
			1,
			d and (0, 0, 0) or (127, 127, 127)
		),
		(10, 450)
	)
Beispiel #9
0
def test_command_with_args():
    cmd, arg = command.parse("!feed add https://example.com/feed.xml")
    assert cmd == "feed"
    assert arg == "add https://example.com/feed.xml"
Beispiel #10
0
def test_simple_command_parse():
    cmd, arg = command.parse("!randomquote")
    assert cmd == "randomquote"
    assert arg == ""
Beispiel #11
0
def test_no_prefix():
    cmd, arg = command.parse("add https://example.com/feed.xml", prefix="")
    assert cmd == "add"
    assert arg == "https://example.com/feed.xml"
Beispiel #12
0
def test_command_lower_case():
    cmd, arg = command.parse("!BlackJack")
    assert cmd == "blackjack"
    assert arg == ""