Browse Source

Use TCP for irccat

master
Chris Smith 5 years ago
parent
commit
74e7b7d8cf
2 changed files with 10 additions and 8 deletions
  1. 2
    1
      lineandsinker/services/__init__.py
  2. 8
    7
      lineandsinker/services/irccat.py

+ 2
- 1
lineandsinker/services/__init__.py View File

@@ -21,7 +21,8 @@ def gitea_factory():
21 21
 
22 22
 def irccat_factory():
23 23
     return IrcCat(
24
-        os.environ["LAS_IRCCAT_URL"],
24
+        os.environ["LAS_IRCCAT_HOST"],
25
+        int(os.environ["LAS_IRCCAT_PORT"]),
25 26
         os.environ["LAS_IRCCAT_CHANNEL"],
26 27
     )
27 28
 

+ 8
- 7
lineandsinker/services/irccat.py View File

@@ -1,17 +1,18 @@
1
-import requests
1
+import socket
2 2
 
3 3
 from .service import Service
4 4
 
5 5
 
6 6
 class IrcCat(Service):
7
-    def __init__(self, url, channel):
7
+    def __init__(self, host, port, channel):
8 8
         super().__init__("irccat")
9
-        self._url = url
9
+        self._host = host
10
+        self._port = port
10 11
         self._channel = channel
11 12
 
12 13
     def announce(self, message):
14
+        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
15
+        s.connect((self._host, self._port))
13 16
         for line in message.split("\n"):
14
-            requests.post(
15
-                self._url,
16
-                f"{self._channel}, {line}",
17
-            )
17
+            s.sendall(bf"{self._channel} {line}\n")
18
+        s.close()

Loading…
Cancel
Save