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
5 years ago
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
Show 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 @@
...
@@ -5,6 +5,7 @@
-
Connecting to multiple channels and listening them
-
Connecting to multiple channels and listening them
-
Switching between channels
-
Switching between channels
-
Quitting channels
-
Quitting channels
-
Twitch Helix API
-
**MACROS**
-
**MACROS**
## Macros
## Macros
...
@@ -21,15 +22,21 @@ And then register with `Macros.macro`
...
@@ -21,15 +22,21 @@ And then register with `Macros.macro`
def
macro
(
*
blabla
):
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
```
py
def
on_gnu
(
publish
er
,
message
):
def
on_gnu
(
handl
er
,
message
):
lower_message
=
message
.
message
.
lower
()
lower_message
=
message
.
message
.
lower
()
author
=
message
.
author
author
=
message
.
author
if
"linux"
in
lower_message
and
"gnu"
not
in
lower_message
:
if
"linux"
in
lower_message
and
"gnu"
not
in
lower_message
:
...
...
```
```
Send with
`publisher`
Send with
`
handler.
publisher`
```
py
```
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) -> {...}
```
```
This diff is collapsed.
Click to expand it.
chatat/__main__.py
Dosyayı görüntüle @
61962e8c
...
@@ -26,7 +26,7 @@ class ChatInterface:
...
@@ -26,7 +26,7 @@ class ChatInterface:
)
)
self
.
channel
=
None
self
.
channel
=
None
self
.
macros
=
Macros
(
pubpen
)
self
.
macros
=
Macros
(
pubpen
,
self
.
helix
,
loop
)
self
.
pubpen
.
subscribe
(
"message"
,
self
.
macros
.
dispatch
)
self
.
pubpen
.
subscribe
(
"message"
,
self
.
macros
.
dispatch
)
def
__enter__
(
self
):
def
__enter__
(
self
):
...
...
This diff is collapsed.
Click to expand it.
chatat/macros.py
Dosyayı görüntüle @
61962e8c
...
@@ -5,12 +5,14 @@ from chatat.twitch import Actions
...
@@ -5,12 +5,14 @@ from chatat.twitch import Actions
class
Macros
:
class
Macros
:
macros
=
defaultdict
(
list
)
macros
=
defaultdict
(
list
)
def
__init__
(
self
,
pubpen
):
def
__init__
(
self
,
pubpen
,
helix
,
loop
):
self
.
pubpen
=
pubpen
self
.
publisher
=
pubpen
self
.
helix
=
helix
self
.
loop
=
loop
def
dispatch
(
self
,
message
):
def
dispatch
(
self
,
message
):
for
macro
in
self
.
macros
[
message
.
action
]:
for
macro
in
self
.
macros
[
message
.
action
]:
macro
(
self
.
pubpen
,
message
)
macro
(
self
,
message
)
@classmethod
@classmethod
def
macro
(
cls
,
on_event
):
def
macro
(
cls
,
on_event
):
...
...
This diff is collapsed.
Click to expand it.
example_macros.py
Dosyayı görüntüle @
61962e8c
...
@@ -3,8 +3,8 @@ from chatat.twitch import Actions
...
@@ -3,8 +3,8 @@ from chatat.twitch import Actions
@Macros.macro
(
Actions
.
PRIVMSG
)
@Macros.macro
(
Actions
.
PRIVMSG
)
def
on_gnu
(
publish
er
,
message
):
def
on_gnu
(
handl
er
,
message
):
lower_message
=
message
.
message
.
lower
()
lower_message
=
message
.
message
.
lower
()
author
=
message
.
author
author
=
message
.
author
if
"linux"
in
lower_message
and
"gnu"
not
in
lower_message
:
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"
)
This diff is collapsed.
Click to expand it.
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