Adding commands
to register your own commands use the Command decorator:
Command console
If the Command Server is disabled in the config the Command Console cannot be used
Command whitelist
Command whitelist is a optional feature that only allows certain commands to be used (specified in the config)
it is disabled by default, but can be enabled by setting use_command_whitelist to true in configs/config.json
Config
the default config values are:
Database support
to enabled database support
Dummycommands
this class is basically a command that does nothing when executed, its mainly use is to be used as base command for
sub-command-only commands
it has all the same options as a regular Command
when a dummy command is executed it looks for sub-commands with a matching name as the first argument passed to it
if no command is found then it will say in chat the available sub-commands
but if a command is found it executes that command
say you want a command to greet someone, but you always want to pass the language, you can do this:
Features
- Object-oriented relationships
- Smart caching
- New Twitch API (Helix)
- VOD chat from Twitch API v5
How to stream text data from twitch with sockets in python
We’re setting the log level to DEBUG, which allows all levels of logging to be written to the file. The format
is how we want each line to look, which will be the time we recorded the line and message from the channel separated by an em dash. The datefmt
is how we want the time portion of the format
to be recorded (example below).
Finally, we pass a FileHandler
to handlers
. We could give it multiple handlers to, for example we could add another handler that prints messages to the console. In this case, we’re logging to chat.log, which will be created by the handler. Since we’re passing a plain filename without a path, the handler will create this file in the current directory. Later on we’ll make this filename dynamic to create separate logs for different channels.
Let’s log the response we received earlier to test it out:
Managing permissions using chat commands
to add a permission group: !addgroup <group>, ex: !addgroup donators
Overriding events on mods
Visit the mods wiki page
on this repo’s wiki to view how to do it via Mods
- all overridable events are:
Quick start
for a reference for builtin command look at the
wiki HERE
Required oauth scopes for pubsub topics
|____________________________|______________________________|
| TOPIC | REQUIRED OAUTH SCOPE |
|____________________________|______________________________|
followers -> channel_editor
polls -> channel_editor
bits -> bits:read
bits badge notification -> bits:read
channel points -> channel:read:redemptions
community channel points -> (not sure, seems to be included in the irc oauth)
channel subscriptions -> channel_subscriptions
chat (aka moderation actions) -> channel:moderate
whispers -> whispers:read
channel subscriptions -> channel_subscriptions
the [PubSubTopics.channel_points] is the list of scopes to add to the authorization request url
after the URL is printed, copy it and visit/send the url to owner of the channel that you want pubsub access to
in the case of it being your own channel its much more simple, since you just need to visit it on your main account and
copy the oauth access code
Step 1: creating a developer application
to create a twitch developer application generate one here, this requires the
account have two-factor enabled
Step 2: generating a new irc oauth access token with the new client_id
this step is needed because twitch requires that oauth tokens used in API calls be generated the client_id sent in the
api request
Subcommands
the SubCommand class makes it easier to implement different actions based on a parameters passed to a command.
its the same as normal command except thats its not a global command
example: !say could be its own command, then it could have the sub-commands !say myname or !say motd.
you can implements this using something like this:
Tip: revoking permission for a group (aka negating permissions)
to revoke a permission for a group, add the same permission but with a – in front of it
ex: you can to prevent group B from using permission feed from group A.
Simply add its negated version to group B: -feed, this PREVENTS group B from having the permission feed from group A
Usage
# Video Comments (VOD chat)forcommentinhelix.video(318017128).comments:
print(comment.commenter.display_name)
forvideo, commentsinhelix.videos([318017128, 317650435]).comments:
forcommentincomments:
print(comment.commenter.display_name, comment.message.body)
forvideo, commentsinhelix.user('sodapoppin').videos().comments:
forcommentincomments:
print(comment.commenter.display_name, comment.message.body)
foruser, videosinhelix.users(['sodapoppin', 'reckful']).videos(first=5):
forvideo, commentsinvideos.comments:
forcommentincomments:
print(comment.commenter.display_name, comment.message.body)
What is pubsub?
pubsub is the way twitch sends certain events to subscribers to the topic it originates from
all topics are listed under the PubSubTopics
enum found here
Получение id и секрета
Получить секрет своего аккаунта можно тут.
Получить ID можно по секрету, введя в консоле такие команды:
В результате вы получите ID.
Для свободного использования.
Установка
Сначало, установите Python, а также Git (если не установлено).
После установки, введите эти команды в консоле:
Теперь нужно провести установку нужных пакетов: