Exemplo n.º 1
0
def main():
    """
    Sample application of supbot which takes in commands to run actions,
    and prints incoming events on screen
    made just to tests the library

    starts the bot then waits for input
    """
    args = docopt(__doc__)

    if args["--version"]:
        from supbot import __version__
        print("supbot v{}".format(__version__))
        return

    print("Loading...")

    kwargs = {}
    for k, v in args.items():
        kwargs[k.strip("-").replace("-", "_")] = v

    with Supbot(message_received=print_message,
                group_message_received=print_group_message,
                **kwargs) as supbot:
        start_loop(supbot, args["--no-prompt"])
Exemplo n.º 2
0
    def test_works_properly(self):

        with self.assertLogs(level='DEBUG') as cm:
            with Supbot(config["device_name"]) as supbot:
                supbot.send_message(config["contact_name"], "hi")
            self.assertIn(
                'DEBUG:supbot:sent message hi to {} successfully'.format(
                    config["contact_name"]), cm.output, "log not found")
Exemplo n.º 3
0
def main():
    """
    Sample application of supbot which takes in commands to run actions,
    and prints incoming events on screen
    made just to tests the library

    starts the bot then waits for input
    """
    args = docopt(__doc__)

    if args["--version"]:
        from supbot import __version__
        print("supbot v{}".format(__version__))
        return

    device_name = args["--device"]

    print(help_me)

    with Supbot(device_name=device_name,
                message_received=print_message) as supbot:
        start_loop(supbot)
Exemplo n.º 4
0
def main():
    """
    Sample application of supbot which takes in commands to run actions,
    and prints incoming events on screen
    made just to tests the library

    starts the bot then waits for input
    """
    args = docopt(__doc__)

    if args["--version"]:
        from supbot import __version__
        print("supbot v{}".format(__version__))
        return

    print("Loading...")

    with Supbot(message_received=print_message,
                no_server=args["--no-server"],
                port=args["--port"],
                device_name=args["--device"]) as supbot:
        start_loop(supbot, args["--no-prompt"])
Exemplo n.º 5
0
from supbot import Supbot
from supbot.action import Action

contact = "123456789"


def action_callback(action: Action):
    print(action)


with Supbot() as supbot:
    supbot.send_message(contact,
                        "hi",
                        action_complete_callback=action_callback)
    supbot.quit()
Exemplo n.º 6
0
from supbot import Supbot
from estrutura import aimlbot
import time

bot = aimlbot()


def message_received(contact_name: str, message: str):
    resposta = bot.login(message, contact_name)
    if type(resposta) == list:
        resposta = resposta[::-1]
        for x in resposta:
            supbot.send_message(contact_name, x)
            # time.sleep(300)
    elif resposta:
        supbot.send_message(contact_name, resposta)
    else:
        print("ERRO : ", resposta)


with Supbot(message_received=message_received) as supbot:
    supbot.wait_for_finish()
Exemplo n.º 7
0
"""
Simple example which resends messages sent to the bot
"""

from supbot import Supbot


def repeat_message(contact_name, message):
    """
    Supbot callbacks returns a reference for supbot's interface too
    :param contact_name:
    :param message:
    :return:
    """
    supbot.send_message(contact_name, message)


"""
Supbot requires to initialize before you can use its services, so it should never be used out of its scope,
you can use with-as statement in order to automatically initialize supbot.
After it is created, you can use its services within its block.
"""
with Supbot(message_received=repeat_message) as supbot:
    supbot.wait_for_finish()
Exemplo n.º 8
0
    elif parts[0] == "!help":
        supbot.send_message(
            group_name, """Hello! my name is DafqBot, powered by Supbot2 API
        user commands:
        !dc <message>: will send the message to discord
        @all: will tag everyone in the group
        !help: show this message again
        
        admin commands:
        !add <number> <discord-id>: will add user to the database
        !quit: quit the bot safely
        
        Apart form these commands, I also let my master know if someone hasn't interacted since a long time"""
        )


def forward_message(message):
    supbot.send_message(group_name, message)


def main():
    with supbot:
        supbot.wait_for_finish()


if __name__ == '__main__':
    supbot = Supbot(group_message_received=group_message, no_server=True)
    Thread(target=main).start()
    client = discord_client.MyClient(forward_message)
    client.run(discord_client.token)
Exemplo n.º 9
0
def prepare_consolidated_message(title, linkedin_url, twitter_url,
                                 facebook_url, instagram_url):
    message = title + "\n"
    if linkedin_url:
        message += "\n" + linkedin_template.format(linkedin_url)
    if twitter_url:
        message += "\n" + twitter_template.format(twitter_url)
    if facebook_url:
        message += "\n" + facebook_template.format(facebook_url)
    if instagram_url:
        message += "\n" + instagram_template.format(instagram_url)
    return message


def clear_title():
    global title
    title = ""


def clear_links():
    global linkedin_url, twitter_url, facebook_url, instagram_url
    linkedin_url = ""
    twitter_url = ""
    facebook_url = ""
    instagram_url = ""


if __name__ == "__main__":
    with Supbot(group_message_received=message_received) as supbot:
        supbot.wait_for_finish()