tBKwtWS 8 ani în urmă
părinte
comite
36374cf9d1

+ 1 - 1
irc/commands/admin.py

@@ -360,4 +360,4 @@ def do_command(self, connection, event):
                     connection.privmsg(replyto, "Insufficient tuples.")
                 else:
                     for channel in self.channels:
-                        connection.mode(channel, "+b *!*@" + trigger.split()[0])
+                        connection.mode(channel, "+b *!*@" + trigger.split()[1])

+ 37 - 26
webgui/stats/templates/stats/network.html

@@ -5,8 +5,8 @@
 {% block keywords %}{{ network }},irc network{% endblock %}
 {% block keywords-not %}{% endblock %}
 {% block content %}
-    <article class="ui text container">
-        <header class="ui five statistics">
+    <article class="ui container">
+        <header class="ui six statistics">
             <a class="statistic" href="/">
                 <div class="value">
                     <i class="hashtag icon"></i> {{ channels|length }}
@@ -48,41 +48,52 @@
                 </div>
             </a>
         </header>
-        <section class="ui basic segment container">
-            <div class="ui basic segment">
-                <div class="ui celled selection link list">
-                    {% for network in networks %}
-                        <a class="item" href="{% url 'stats:network' network.name %}">
-                            <div class="right floated content">
-                                {% if network.password %}<i class="privacy icon" alt="NickServ password saved"></i>{% endif %}
-                                {% if network.use_ssl %}<i class="protect icon" title="Encrypted connection"></i>{% endif %}
-                                </div>
-                            <i class="middle aligned server icon"></i>
-                            <div class="content">
-                                <div class="header">
-                                    <div class="content" href="{% url 'stats:network' network.name %}">{{ network.name }}</div>
-                                </div>
-                                <div class="description">
-                                    {{ network.host }}:{{ network.port }}
+        <section class="ui segment container">
+                <div class="ui centered card">
+                    <div class="content">
+                        <div class="header">
+                        <i class="settings icon"></i>
+                            Configuration
+                            {% if {{ network.password }} or {{ network.use_ssl }} %}
+                                <div class="right floated content">
+                                    {% if {{ network.password }} %}
+                                        <i class="privacy icon"></i>
+                                    {% endif %}
                                 </div>
+                            {% endif %}
+                        </div>
+                        <h4 class="ui sub header">
+                            <i class="cloud icon"></i>
+                            {{ network }}
+                        </h4>
+                        <div class="meta">
+                            {{ network.host }}:{{ network.port }} {{ network.home_channel }}
+                        </div>
+                        <div class="description">
+                            <div class="ui basic label">
+                                <i class="id card icon"></i>
+                                {{ network.username }}
+                            </div>
+                            <div class="ui basic label">
+                                <i class="terminal icon"></i>
+                            {{ network.command_character }}
                             </div>
-                        </a>
-                    {% endfor %}
+                            <div class="ui basic label">
+                                <i class="help icon"></i>
+                                {{ network.help_character }}
+                            </div>
+                        </div>
+                    </div>
                 </div>
-            </div>
         </section>
     </article>
     <article class="ui container segment">
-        <header class="ui icon header">
-            <i class="sitemap icon"></i>
-            {{ network }}
-        </header>
         
     </article>
 {% endblock %}
 {% block breadcrumbs %}
     <i class="sitemap icon"></i>
-    <a class"section" href="{% url 'stats:networks' %}">Networks</a>
+    <a class="section" href="{% url 'stats:networks' %}">Networks</a>
     <div class="divider"> / </div>
     <i class="sitemap icon"></i>
     <div class="active section">{{ network }}</div>

+ 5 - 5
webgui/stats/templates/stats/networks.html

@@ -9,8 +9,8 @@
 {% block keywords %}irc networks{% endblock %}
 {% block keywords-not %}{% endblock %}
 {% block content %}
-    <article class="ui text container">
-        <header class="ui four statistics">
+    <article class="ui container">
+        <header class="ui five statistics">
             <div class="statistic">
                 <div class="value">
                     <i class="sitemap icon"></i> {{ networks|length }}
@@ -44,14 +44,14 @@
                 </div>
             </a>
         </header>
-        <section class="ui basic segment container">
-            <div class="ui basic segment">
+        <section class="ui basic text segment container">
+            <div class="ui basic  segment">
                 <div class="ui celled selection link list">
                     {% for network in networks %}
                         <a class="item" href="{% url 'stats:network' network.name %}">
                             <div class="right floated content">
                                 {% if network.password %}<i class="privacy icon" alt="NickServ password saved"></i>{% endif %}
-                                {% if network.use_ssl %}<i class="protect icon" title="Encrypted connection"></i>{% endif %}
+                                {% if network.use_ssl %}<i class="lock icon" title="Encrypted connection"></i>{% endif %}
                                 </div>
                             <i class="middle aligned server icon"></i>
                             <div class="content">

+ 22 - 7
webgui/stats/views.py

@@ -1,21 +1,17 @@
-from postgres import Postgres
 from django.shortcuts import render, get_list_or_404, get_object_or_404
+from django.conf import settings
 from .models import Networks, Channels, Users
 from webgui.common import convert_units
+db = settings.BOT_DB
 
 def networks(request):
     networks = get_list_or_404(Networks.objects.all())
     channels = Channels.objects.all()
     users = Users.objects.all()
-    db = Postgres("postgres://pyRot:4h8q(.@localhost/pyRot")
     messages = db.all("SELECT channel_network, messages, actions, notices FROM messages")
     
-    #foo = db.all("SELECT * FROM messages WHERE channel_network='GamerGalaxy'")
-    #print(foo)
-    
     networklist = {}
     for network in networks:
-        #print(db.all("SELECT messages, actions, notices FROM messages WHERE channel_network='" + str(network) + "'"))
         networklist[network.name] = {'channels': 0, 'users': 0, 'messages': 0}
     for user in users:
         networklist[user.network.name]['users'] += 1
@@ -39,5 +35,24 @@ def networks(request):
 
 def network(request, network_name):
     network = get_object_or_404(Networks, name=network_name)
-    context = {'network': network}
+    channels = Channels.objects.filter(network=network_name)
+    users = Users.objects.filter(network=network_name)
+    records = db.all("SELECT messages, actions, notices FROM messages WHERE channel_network='" + network_name + "'")
+    print(records)
+    totalmessages = 0
+    totalactions = 0
+    totalnotices = 0
+    for record in records:
+        totalmessages += record[0]
+        totalactions += record[1]
+        totalnotices += record[2]
+    
+    context = {
+        'network': network,
+        'channels': channels,
+        'users': users,
+        'totalmessages': totalmessages,
+        'totalactions': totalactions,
+        'totalnotices': totalnotices,
+    }
     return render(request, 'stats/network.html', context)

+ 7 - 7
webgui/webgui/common/convert_units.py

@@ -1,16 +1,16 @@
 def shorten_number (number):
     if len(str(number)) > 20:
-        number = str(number /1000000000000000000) +"E"
+        number = str(int(number /1000000000000000000)) +"E"
     if len(str(number)) > 17:
-        number = str(number /1000000000000000) +"P"
+        number = str(int(number /1000000000000000)) +"P"
     if len(str(number)) > 14:
-        number = str(number /1000000000000) +"T"
+        number = str(int(number /1000000000000)) +"T"
     if len(str(number)) > 11:
-        number = str(number /1000000000) +"G"
+        number = str(int(number /1000000000)) +"G"
     if len(str(number)) > 8:
-        number = str(number /1000000) +"M"
+        number = str(int(number /1000000)) +"M"
     if len(str(number)) > 5:
-        number = str(number /1000) + "K"
+        number = str(int(number /1000)) + "K"
     if len(str(number)) > 4:
-        number = str(number /100) + "h"
+        number = str(int(number /100)) + "h"
     return str(number)

+ 3 - 0
webgui/webgui/settings.py

@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/2.0/ref/settings/
 """
 
 import os
+from postgres import Postgres
 
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -94,6 +95,8 @@ DATABASES = {
     }, 
 }
 
+BOT_DB = Postgres("postgres://pyRot:4h8q(.@localhost/pyRot")
+
 DATABASE_ROUTERS = ['webgui.routers.BotRouter', ]
 
 # Password validation