Beispiel #1
0
def disable(chat):
    try:
        options = chat.plugin_options.get(plugin_name='penis')
    except DoesNotExist:
        raise SocialCreditError('Plugin is already disabled.')
    chat.plugin_options.remove(options)
    chat.plugin_options.save()
Beispiel #2
0
def enable(chat):
    try:
        options = chat.plugin_options.get(plugin_name='penis')
    except DoesNotExist:
        pass
    else:
        raise SocialCreditError('Plugin is already enabled.')
    chat.plugin_options.create(plugin_name='penis')
    chat.plugin_options.save()
def check_limit(sender, document, created):
    issuer = document.issuer
    try:
        options = issuer.plugin_options.get(plugin_name='transaction_limit')
    except DoesNotExist:
        # plugin must be disabled, skipping
        return
    if not options.transactions_left:
        raise SocialCreditError('Transaction limit exceeded.')
    options.transactions_left -= 1
    issuer.plugin_options.save()
def disable(chat):
    try:
        options = chat.plugin_options.get(plugin_name='chatinfo')
    except DoesNotExist:
        raise SocialCreditError('Plugin is already disabled.')
    chat.plugin_options.remove(options)
    chat.plugin_options.save()
    ChatPeriodicTask.objects.get(
        chat=chat,
        plugin_name='chatinfo',
        module='post_chat_info',
    ).delete()
def enable(chat):
    try:
        options = chat.plugin_options.get(plugin_name='chatinfo')
    except DoesNotExist:
        pass
    else:
        raise SocialCreditError('Plugin is already enabled.')
    chat.plugin_options.create(plugin_name='chatinfo')
    chat.plugin_options.save()
    ChatPeriodicTask(
        chat=chat,
        plugin_name='chatinfo',
        module='post_chat_info',
        time=DEFAULT_TIME,
    ).save()
def disable(chat):
    try:
        options = chat.plugin_options.get(plugin_name='transaction_limit')
    except DoesNotExist:
        raise SocialCreditError('Plugin is already disabled.')
    profiles = chat.get_profiles()
    chat.plugin_options.remove(options)
    chat.plugin_options.save()
    for profile in profiles:
        profile_options = profile.plugin_options.get(
            plugin_name='transaction_limit')
        profile.plugin_options.remove(profile_options)
        profile.plugin_options.save()

    ChatPeriodicTask.objects.get(
        chat=chat,
        plugin_name='transaction_limit',
        module='reset_transactions',
    ).delete()
def enable(chat):
    try:
        options = chat.plugin_options.get(plugin_name='transaction_limit')
    except DoesNotExist:
        pass
    else:
        raise SocialCreditError('Plugin is already enabled.')
    chat_options = TransactionLimitChatOptions(plugin_name='transaction_limit',
                                               limit=DEFAULT_LIMIT)
    profiles = chat.get_profiles()
    chat.plugin_options.append(chat_options)
    chat.plugin_options.save()
    for profile in profiles:
        profile_option = TransactionLimitProfileOptions(
            plugin_name='transaction_limit', transactions_left=DEFAULT_LIMIT)
        profile.plugin_options.append(profile_option)
        profile.plugin_options.save()
    ChatPeriodicTask(
        chat=chat,
        plugin_name='transaction_limit',
        module='reset_transactions',
        time=DEFAULT_TIME,
    ).save()