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
61962e8c
Kaydet (Commit)
61962e8c
authored
May 31, 2019
tarafından
Batuhan Taşkaya
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Helix API support for macros
üst
66f090ba
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
10 deletions
+19
-10
README.md
README.md
+11
-4
__main__.py
chatat/__main__.py
+1
-1
macros.py
chatat/macros.py
+5
-3
example_macros.py
example_macros.py
+2
-2
No files found.
README.md
Dosyayı görüntüle @
61962e8c
...
...
@@ -5,6 +5,7 @@
-
Connecting to multiple channels and listening them
-
Switching between channels
-
Quitting channels
-
Twitch Helix API
-
**MACROS**
## Macros
...
...
@@ -21,15 +22,21 @@ And then register with `Macros.macro`
def
macro
(
*
blabla
):
...
```
The macro takes
`
publisher`
(for publishing action
s) and
`message`
(a
`chatat.twitch.Message`
object that holds message / author etc.)
The macro takes
`
handler`
(for accessing service
s) and
`message`
(a
`chatat.twitch.Message`
object that holds message / author etc.)
```
py
def
on_gnu
(
publish
er
,
message
):
def
on_gnu
(
handl
er
,
message
):
lower_message
=
message
.
message
.
lower
()
author
=
message
.
author
if
"linux"
in
lower_message
and
"gnu"
not
in
lower_message
:
...
```
Send with
`publisher`
Send with
`
handler.
publisher`
```
py
publisher
.
publish
(
"outgoing"
,
f
"{author} dude; not linux, GNU/Linux"
)
handler
.
publisher
.
publish
(
"outgoing"
,
f
"{author} dude; not linux, GNU/Linux"
)
```
### Helix API
Current version supports usage of Twitch Helix API with a little wrapper.
```
await handler.helix.get(endpoint, **params) -> JSON Response
await handler.helix.get("streams", game_id=33214) -> {...}
```
chatat/__main__.py
Dosyayı görüntüle @
61962e8c
...
...
@@ -26,7 +26,7 @@ class ChatInterface:
)
self
.
channel
=
None
self
.
macros
=
Macros
(
pubpen
)
self
.
macros
=
Macros
(
pubpen
,
self
.
helix
,
loop
)
self
.
pubpen
.
subscribe
(
"message"
,
self
.
macros
.
dispatch
)
def
__enter__
(
self
):
...
...
chatat/macros.py
Dosyayı görüntüle @
61962e8c
...
...
@@ -5,12 +5,14 @@ from chatat.twitch import Actions
class
Macros
:
macros
=
defaultdict
(
list
)
def
__init__
(
self
,
pubpen
):
self
.
pubpen
=
pubpen
def
__init__
(
self
,
pubpen
,
helix
,
loop
):
self
.
publisher
=
pubpen
self
.
helix
=
helix
self
.
loop
=
loop
def
dispatch
(
self
,
message
):
for
macro
in
self
.
macros
[
message
.
action
]:
macro
(
self
.
pubpen
,
message
)
macro
(
self
,
message
)
@classmethod
def
macro
(
cls
,
on_event
):
...
...
example_macros.py
Dosyayı görüntüle @
61962e8c
...
...
@@ -3,8 +3,8 @@ from chatat.twitch import Actions
@Macros.macro
(
Actions
.
PRIVMSG
)
def
on_gnu
(
publish
er
,
message
):
def
on_gnu
(
handl
er
,
message
):
lower_message
=
message
.
message
.
lower
()
author
=
message
.
author
if
"linux"
in
lower_message
and
"gnu"
not
in
lower_message
:
publisher
.
publish
(
"outgoing"
,
f
"{author} dude; not linux, GNU/Linux"
)
handler
.
publisher
.
publish
(
"outgoing"
,
f
"{author} dude; not linux, GNU/Linux"
)
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