Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
chatat
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
chatat
Commits
871d8966
Kaydet (Commit)
871d8966
authored
May 30, 2019
tarafından
Batuhan Taşkaya
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
singleton channels
üst
3cd0460c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
5 deletions
+24
-5
.pre-commit-config.yaml
.pre-commit-config.yaml
+1
-0
client.py
chatat/client.py
+7
-1
twitch.py
chatat/twitch.py
+16
-4
No files found.
.pre-commit-config.yaml
Dosyayı görüntüle @
871d8966
...
@@ -25,3 +25,4 @@ repos:
...
@@ -25,3 +25,4 @@ repos:
rev
:
master
rev
:
master
hooks
:
hooks
:
-
id
:
mypy
-
id
:
mypy
stages
:
[
manual
]
chatat/client.py
Dosyayı görüntüle @
871d8966
...
@@ -7,7 +7,7 @@ from typing import Optional, Sequence
...
@@ -7,7 +7,7 @@ from typing import Optional, Sequence
from
chatat.twitch
import
Auth
,
Channel
,
Message
from
chatat.twitch
import
Auth
,
Channel
,
Message
class
Twitch
Chat
Protocol
(
asyncio
.
Protocol
):
class
TwitchProtocol
(
asyncio
.
Protocol
):
def
__init__
(
def
__init__
(
self
,
auth
:
Auth
,
channels
:
Sequence
[
Channel
],
on_con_lost
:
asyncio
.
Future
self
,
auth
:
Auth
,
channels
:
Sequence
[
Channel
],
on_con_lost
:
asyncio
.
Future
)
->
None
:
)
->
None
:
...
@@ -27,6 +27,12 @@ class TwitchChatProtocol(asyncio.Protocol):
...
@@ -27,6 +27,12 @@ class TwitchChatProtocol(asyncio.Protocol):
handler
.
setFormatter
(
formatter
)
handler
.
setFormatter
(
formatter
)
self
.
logger
.
addHandler
(
handler
)
self
.
logger
.
addHandler
(
handler
)
class
TwitchHelixProtocol
(
TwitchProtocol
):
pass
class
TwitchChatProtocol
(
TwitchProtocol
):
def
_send
(
self
,
cmd
:
str
,
value
:
str
)
->
None
:
def
_send
(
self
,
cmd
:
str
,
value
:
str
)
->
None
:
request
=
f
"{cmd.upper()} {value}
\r\n
"
request
=
f
"{cmd.upper()} {value}
\r\n
"
self
.
transport
.
write
(
request
.
encode
(
"utf-8"
))
self
.
transport
.
write
(
request
.
encode
(
"utf-8"
))
...
...
chatat/twitch.py
Dosyayı görüntüle @
871d8966
...
@@ -5,7 +5,7 @@ import os
...
@@ -5,7 +5,7 @@ import os
import
re
import
re
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
from
enum
import
Enum
,
auto
from
enum
import
Enum
,
auto
from
typing
import
Optional
,
Union
from
typing
import
Any
,
Dict
,
Optional
,
Tuple
,
Union
PATTERN
=
re
.
compile
(
r"^:(.*?)!(.*?@.*?\.tmi\.twitch\.tv) (.*?) #(.*?) :(.*?)$"
)
PATTERN
=
re
.
compile
(
r"^:(.*?)!(.*?@.*?\.tmi\.twitch\.tv) (.*?) #(.*?) :(.*?)$"
)
...
@@ -17,18 +17,30 @@ class Actions(Enum):
...
@@ -17,18 +17,30 @@ class Actions(Enum):
@dataclass
@dataclass
class
Auth
:
class
Auth
:
username
:
str
username
:
str
password
:
str
oauthtok
:
str
oauthtok
:
str
client_id
:
str
client_secret
:
str
@classmethod
@classmethod
def
from_json
(
cls
,
file
:
os
.
PathLike
):
def
from_json
(
cls
,
file
:
os
.
PathLike
):
with
open
(
os
.
fspath
(
file
))
as
f
:
with
open
(
os
.
fspath
(
file
))
as
f
:
content
=
json
.
loads
(
f
.
read
())
content
=
json
.
loads
(
f
.
read
())
return
cls
(
**
content
)
return
cls
(
**
content
[
"chat"
],
**
content
[
"helix"
])
# type: ignore
class
SingleableChannel
:
def
__init_subclass__
(
cls
:
SingleableChannel
)
->
None
:
cls
.
_singletons
:
Dict
[
Tuple
[
Any
,
...
],
SingleableChannel
]
=
{}
def
__new__
(
cls
:
SingleableChannel
,
*
args
)
->
SingleableChannel
:
if
not
cls
.
_singletons
.
get
(
args
):
cls
.
_singletons
[
args
]
=
super
()
.
__new__
(
cls
)
return
cls
.
_singletons
[
args
]
@dataclass
@dataclass
class
Channel
:
class
Channel
(
SingleableChannel
)
:
name
:
str
name
:
str
def
__str__
(
self
):
def
__str__
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment