コード例 #1
0
    def __init__(self):
        client_id = settings.DISCORD_APP_ID

        intents = discord.Intents.default()
        intents.members = True

        super().__init__(
            command_prefix="!",
            description=description,
            intents=intents,
        )

        self.redis = None
        self.redis = self.loop.run_until_complete(aioredis.create_pool(getattr(settings, "BROKER_URL", "redis://localhost:6379/0"), minsize=5, maxsize=10))
        print('redis pool started', self.redis)
        self.client_id = client_id
        self.session = aiohttp.ClientSession(loop=self.loop)
        self.tasks = []

        self.message_connection = Connection(getattr(settings, "BROKER_URL", 'redis://localhost:6379/0'))
        queues = []
        for que in queue_keys:
            queues.append(Queue(que))
        self.message_consumer = Consumer(self.message_connection, queues, callbacks=[self.on_queue_message], accept=['json'])

        django.setup()

        for hook in hooks.get_hooks("discord_cogs_hook"):
            for cog in hook():
                try:
                    self.load_extension(cog)
                except Exception as e:
                    print(f"Failed to load cog {cog}", file=sys.stderr)
                    traceback.print_exc()
コード例 #2
0
ファイル: admin.py プロジェクト: Kaezon/allianceauth
 def __init__(self, *args, **kwargs):
     super(NameFormatConfigForm, self).__init__(*args, **kwargs)
     SERVICE_CHOICES = [(s.name, s.name) for h in hooks.get_hooks('services_hook') for s in [h()]]
     if self.instance.id:
         current_choice = (self.instance.service_name, self.instance.service_name)
         if current_choice not in SERVICE_CHOICES:
             SERVICE_CHOICES.append(current_choice)
     self.fields['service_name'] = forms.ChoiceField(choices=SERVICE_CHOICES)
コード例 #3
0
 def get_hooks(self):
     if self.all_hooks is None:
         hook_array = set()
         _hooks = hooks.get_hooks("secure_group_filters")
         for app_hook in _hooks:
             for filter_model in app_hook():
                 if filter_model not in hook_array:
                     hook_array.add(filter_model)
         self.all_hooks = hook_array
     return self.all_hooks
コード例 #4
0
ファイル: views.py プロジェクト: Kaezon/allianceauth
def services_view(request):
    logger.debug("services_view called by user %s" % request.user)
    char = request.user.profile.main_character
    context = {'service_ctrls': []}
    for fn in get_hooks('services_hook'):
        # Render hooked services controls
        svc = fn()
        if svc.show_service_ctrl(request.user):
            context['service_ctrls'].append(svc.render_services_ctrl(request))

    return render(request, 'services/services.html', context=context)
コード例 #5
0
def services_view(request):
    logger.debug("services_view called by user %s" % request.user)
    char = request.user.profile.main_character
    context = {'service_ctrls': []}
    for fn in get_hooks('services_hook'):
        # Render hooked services controls
        svc = fn()
        if svc.show_service_ctrl(request.user):
            context['service_ctrls'].append(svc.render_services_ctrl(request))

    return render(request, 'services/services.html', context=context)
コード例 #6
0
 def __init__(self, *args, **kwargs):
     super(NameFormatConfigForm, self).__init__(*args, **kwargs)
     SERVICE_CHOICES = [(s.name, s.name)
                        for h in hooks.get_hooks('services_hook')
                        for s in [h()]]
     if self.instance.id:
         current_choice = (self.instance.service_name,
                           self.instance.service_name)
         if current_choice not in SERVICE_CHOICES:
             SERVICE_CHOICES.append(current_choice)
     self.fields['service_name'] = forms.ChoiceField(
         choices=SERVICE_CHOICES)
コード例 #7
0
    def get_actions(self, request):
        actions = super(BaseUserAdmin, self).get_actions(request)

        for hook in get_hooks('services_hook'):
            svc = hook()
            # Check update_groups is redefined/overloaded
            if svc.update_groups.__module__ != ServicesHook.update_groups.__module__:
                action = make_service_hooks_update_groups_action(svc)
                actions[action.__name__] = (action, action.__name__,
                                            action.short_description)
            # Create sync nickname action if service implements it
            if svc.sync_nickname.__module__ != ServicesHook.sync_nickname.__module__:
                action = make_service_hooks_sync_nickname_action(svc)
                actions[action.__name__] = (action, action.__name__,
                                            action.short_description)

        return actions
コード例 #8
0
ファイル: admin.py プロジェクト: Kaezon/allianceauth
    def get_actions(self, request):
        actions = super(BaseUserAdmin, self).get_actions(request)

        for hook in get_hooks('services_hook'):
            svc = hook()
            # Check update_groups is redefined/overloaded
            if svc.update_groups.__module__ != ServicesHook.update_groups.__module__:
                action = make_service_hooks_update_groups_action(svc)
                actions[action.__name__] = (action,
                                            action.__name__,
                                            action.short_description)
            # Create sync nickname action if service implements it
            if svc.sync_nickname.__module__ != ServicesHook.sync_nickname.__module__:
                action = make_service_hooks_sync_nickname_action(svc)
                actions[action.__name__] = (action,
                                            action.__name__,
                                            action.short_description)

        return actions
コード例 #9
0
ファイル: urls.py プロジェクト: tnisarghu/allianceauth
    # Authentication
    url(r'', include(allianceauth.authentication.urls)),
    url(r'^account/login/$', TemplateView.as_view(template_name='public/login.html'), name='auth_login_user'),
    url(r'^account/', include(hmac_urls)),

    # Admin urls
    url(r'^admin/', admin.site.urls),

    # SSO
    url(r'^sso/', include((esi.urls, 'esi'), namespace='esi')),
    url(r'^sso/login$', allianceauth.authentication.views.sso_login, name='auth_sso_login'),

    # Notifications
    url(r'', include(allianceauth.notifications.urls)),

    # Groups
    url(r'', include(allianceauth.groupmanagement.urls)),

    # Services
    url(r'', decorate_url_patterns(allianceauth.services.urls.urlpatterns, main_character_required)),

    # Night mode
    url(r'^night/', views.NightModeRedirectView.as_view(), name='nightmode')
]


# Append app urls
app_urls = get_hooks('url_hook')
for app in app_urls:
    urlpatterns += [url(r'', decorate_url_patterns([app().include_pattern], main_character_required))]
コード例 #10
0
 def get_services():
     for fn in get_hooks('services_hook'):
         yield fn()
コード例 #11
0
def menu_items(context):
    request = context['request']

    return {
        'menu_items': process_menu_items(get_hooks('menu_item_hook'), request),
    }
コード例 #12
0
ファイル: hooks.py プロジェクト: Kaezon/allianceauth
 def get_services():
     for fn in get_hooks('services_hook'):
         yield fn()
コード例 #13
0
from django.conf.urls import include, url
from allianceauth.hooks import get_hooks

from . import views

urlpatterns = [
    # Services
    url(r'^services/', include(([
        url(r'^$', views.services_view, name='services'),
        # Tools
        url(r'^tool/fleet_formatter_tool/$', views.fleet_formatter_view, name='fleet_format_tool'),
    ], 'services'), namespace='services')),
]

# Append hooked service urls
services = get_hooks('services_hook')
for svc in services:
    urlpatterns += svc().urlpatterns