Example #1
0
def info():
    if app.debug:
        cfg = app.config
    else:
        cfg = "N/A"
    fmt = """Path:
{path}

Config:
{cfg}

Locale database - Custom:
{loc1}
Locale database - Default:
{loc2}

Registry - Post Handlers:
{ph}

Registry - Topic Handlers:
{th}

Registry - Nickping Handlers:
{np}
""".format(path=pformat(sys.path), cfg=pformat(cfg), ph=pformat(registry.post_created_registry),
            th=pformat(registry.topic_created_registry), np=pformat(registry.nick_ping_registry),
            loc2=pformat(Locale.get().def_msgs), loc1=pformat(Locale.get().msgs))
    return fmt, 200, {"Content-Type": "text/plain"}
Example #2
0
from taciturn.registry import nick_ping_registry
from taciturn.locale import Locale

from app import celery, client, __version__
from flask_babel import gettext

loc = Locale.get()


@celery.task
def username_ping(data: list):
    # Get the raw data from the request.
    post, user_misc, user = data
    post_data = post['raw']
    post_lines = post_data.split('\n')
    # Check the lines
    for line in post_lines:
        # Check if it starts with our nickname
        if line.startswith("@{}".format(client.api_username)):
            nline = line.split(" ")
            # Check if there's a command
            if len(nline) <= 1:
                return
            else:
                # Get the command and args
                command = nline[1]
                args = nline[1:]
                if command in nick_ping_registry:
                    # Call function
                    nick_ping_registry[command](data, *args)
                    return