-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_ubuntu_ko_gui.py
52 lines (43 loc) · 1.51 KB
/
get_ubuntu_ko_gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import codecs
import re
import sys
import urllib.request
import emoji
from _datetime import datetime
from PyQt5.QtWidgets import (QWidget, QPushButton,QLabel,
QHBoxLayout, QVBoxLayout, QApplication, QTextEdit)
ver = "1.0.0"
class UKI(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
refresh_button = QPushButton("Refresh ubuntu-ko")
info_label = QLabel()
refresh_button.clicked.connect(self.refresh_button_pushed)
self.output = QTextEdit()
h_box1 = QHBoxLayout()
h_box2 = QHBoxLayout()
h_box3 = QHBoxLayout()
h_box1.addWidget(refresh_button)
h_box2.addWidget(info_label)
h_box3.addWidget(self.output)
v_box = QVBoxLayout()
v_box.addLayout(h_box1)
v_box.addLayout(h_box2)
v_box.addLayout(h_box3)
self.setLayout(v_box)
self.setGeometry(1400, 300, 500, 700)
self.setWindowTitle('Ubuntu-Ko Irc in PyQt')
self.show()
def refresh_button_pushed(self):
today_date = datetime.today().strftime("%Y/%m/%d")
u = ("https://irclogs.ubuntu.com/" + today_date + "/%23ubuntu-ko.txt")
down = urllib.request.urlretrieve(u, "ubuntu-ko.txt")
f = codecs.open("ubuntu-ko.txt", "r", "utf-8")
text = f.read()
filter_slack = emoji.emojize(re.sub("<bridgebot>", "[Slack]", text))
self.output.setText(filter_slack)
app = QApplication(sys.argv)
ex = UKI()
sys.exit(app.exec_())