The Parent Object

class Dev.PythonManager

Your main link to the chatbot. OBS controls are not documented

AddPoints(userid, username, amount)

Adds points to the target user

Parameters
  • userid (str) – the userid of the person you wish to add points to. On twitch this is generally the lowercase version of the username, but on mixer and youtube it will be something else

  • username (str) – the username of the person you wish to add points to. this is not the same as the userid. it can be fetched using GetDsiplayName()

  • amount (int) – the amount of points you wish to add

Returns

bool based on if the operation succeeded or not

RemovePoints(userid, username, amount)

Removes points from the target user

Parameters
  • useridstr the userid of the person you wish to remove points from. On twitch this is generally the lowercase version of the username, but on mixer and youtube it will be something else

  • usernamestr the username of the person you wish to remove points from. this is not the same as the userid. it can be fetched using GetDsiplayName()

  • amountint the amount of points you wish to remove

Returns

bool based on if the operation succeeded or not

AddPointsAll(data)

batch adds points to many users at once. blocks until the procedure is done

Parameters

data (dict) – Dict[str userid, int amount]

Returns

Dict[str] a list of users that could not have points added to them

AddPointsAllAsync(data, callback)

batch adds points to many users at once. returns immediately, and runs the callback when complete

Parameters

Parameters
  • data (dict) – Dict[str userid, int amount]

  • callback (callable) – called when the operation is complete. should take a list of userids (str) as its sole argument.

RemovePointsAll(data)

batch removes points to many users at once. blocks until the procedure is done

Parameters

data (dict) – Dict[str userid, int amount]

Returns

Dict[str] a list of users that could not have points removed from them

RemovePointsAllAsync(data, callback)

batch removes points to many users at once. returns immediately, and runs the callback when complete

Parameters

Parameters
  • data (dict) – Dict[str userid, int amount]

  • callback (callable) – called when the operation is complete. should take a list of userids (str) as its sole argument.

GetPoints(userid)

retrieves a users points

Parameters

userid (str) – the userid of the user to get points for

Returns

int the points the user has

GetRank(userid)

retrieves a users rank

Parameters

userid (str) – the userid of the user to get rank for

Returns

str the rank the user has

GetHours(userid)

retrieves a users hours

Parameters

userid (str) – the userid of the user to get hours for

Returns

float the hours the user has watched for

GetTopCurrency(n)

retrieves the top n users based on currency

Parameters

n (int) – the amount of users to get

Returns

Dict[userid: points] a dict of userids to points.

GetTopHours(n)

retrieves the top n users based on hour

Parameters

n (int) – the amount of users to get

Returns

Dict[userid: points] a dict of userids to hours.

GetCurrencyUsers(userids)

retrieves a list of Currency objects

Parameters

userids (list) – a list of userids

Returns

a list of Currency objects

SendStreamMessage(text):

sends a message to the stream chat

Parameters

text (str) – the message to be sent

SendStreamWhisper(userid, text)

sends a whisper to a viewer on stream

Important

this only works on twitch. it does not work on youtube or mixer

Warning

twitch whispers are very unreliable. Avoid using them if possible

Parameters
  • userid (str) – the id of the user to send the message to

  • text (str) – the message to whisper to the user

SendDiscordMessage(text):

sends a message to the discord chat

Note

this only works if the streamer has set up discord

Parameters

text (str) – the message to be sent

SendDiscordDM(userid, text):

sends a message to a specific discord user.

Note

this only works if the streamer has set up discord

Parameters
  • userid (str) – the id of the user to send the message to

  • text (str) – the message to whisper to the user

BroadcastWSEvent(event_name, json_data)

sends a message to connected overlays, should look something like

Parameters
  • event_name (str) – The name of the event.

  • json_data (str) – the json data associated with the event. usually you would pass the output of json.dumps

HasPermission(userid, permission, info)

checks if a user has a certain permission. a list of permissions can be found Dev Permission Levels.

Parameters
  • userid (str) – a string with the userid of the target user

  • permission (str) – a string containing the permission you wish to check for

  • info (str) – only used for the min_rank, min_points, min_hours permissions. otherwise should be passed an empty string

Returns

bool

GetViewerList()

gets the current viewers

Returns

list of userids

GetActiveViewers()

gets the current active chatters

Returns

list of userids

GetRandomActiveViewer()
Returns

str

GetDisplayName(userid)

gets a displayname based off the given userid

Parameters

userid (str) – the userid to fetch a username for

AddCooldown(script_name, command, seconds)

Adds a cooldown to the internal cooldown manager

Parameters
  • script_name (str) – the name of your script

  • command (str) – the name of the command on cooldown

  • seconds (int) – the amount of seconds the command should be on cooldown for

IsOnCooldown(script_name, command)

checks if a command is on cooldown

Parameters
  • script_name (str) – the name of your script

  • command (str) – the name of the command on cooldown

Returns

bool

GetCooldownDuration(script_name, command)

fetches the remainder of the cooldown

Parameters
  • script_name (str) – the name of your script

  • command (str) – the name of the command on cooldown

Returns

int

AddUserCooldown(script_name, command, user, seconds)

Adds a user cooldown to the internal cooldown manager

Parameters
  • script_name (str) – the name of your script

  • command (str) – the name of the command on cooldown

  • user (str) – the user to add a cooldown for

  • seconds (int) – the amount of seconds the command should be on cooldown for

IsOnUserCooldown(script_name, command, user)

checks if a command is on user cooldown

Parameters
  • script_name (str) – the name of your script

  • command (str) – the name of the command on cooldown

  • user (str) – the user to check for

Returns

bool

GetUserCooldownDuration(script_name, command, user)

fetches the remainder of the cooldown for a user

Parameters
  • script_name (str) – the name of your script

  • command (str) – the name of the command on cooldown

  • user (str) – the user to fetch a cooldown for

Returns

int

GetRequest(url, headers)

GETs from an api

Parameters
  • url (str) – the url to get the request from

  • headers (dict) – the headers for the api

Returns

str A JSON dict containing the response data. Will contain the fields status and optionally response or error

PostRequest(url, headers, content, is_json=True)

POSTs to an api

Parameters
  • url (str) – the url to send the request to

  • headers (dict) – the headers for the api

  • content (Union[str, dict]) – the content to post

  • is_json (bool) – indicates whether the data should be jsonified or not

Returns

?

DeleteRequest(url, headers)

DELETEs from an api

Parameters
  • url (str) – the url to send the request to

  • headers (dict) – the headers for the api

Returns

?

PutRequest(url, headers, content, is_json=True)

PUTs to an api

Parameters
  • url (str) – the url to send the request to

  • headers (dict) – the headers for the api

  • content (Union[str, dict]) – the content to post

  • is_json (bool) – indicates whether the data should be jsonified or not

Returns

?

IsLive()

indicates whether the stream is live or not

Returns

bool

GetRandom(min, max)

a replacement for the default random module, which is broken in ironpython. this can be fixed however, by doing the following

Parameters
  • min (int) – the minimum number

  • max (int) – the maximum number

Returns

int

GetStreamingService()

gets the platform the streamer is streaming on

Returns

str

GetChannelName()

gets the channel name of the streamer.

Important

this only works on twitch

Returns

str

GetCurrencyName()

gets the channels currency name

Returns

str

Log(script_name, message)

logs data to the chatbot’s logging window

Parameters
  • script_name (str) – the name of your script

  • message (str) – the message to log

PlaySound(file_path, volume)

Attempts to play a sound, if possible, returns whether the sound was played or not

Parameters
  • file_path (str) – the path of the file to play

  • volume (float) – a number between 0 and 1, how loud the sound should be

Returns

bool

GetQueue(n)

Retrieves n number of people in the queue at the moment

Parameters

n (int) – the amount of people to get

Returns

Dict[int: str]

GetSongQueue(max)

gets the next n songs in the song queue

Parameters

n (int) – the amount of songs to get

Returns

List[Song]

GetSongPlaylist(max)

gets the next n songs in the playlist

Parameters

n (int) – the amount of songs to get

Returns

List[Song]

GetNowPlaying()

gets the current playing song

Returns

NamedTuple[Key: str, Value: str]

The Currency Object

class Dev.Currency

The class given when batch retrieving currency data

UserId

str the users id

UserName

str the users name

Points

int the users points

TimeWatched

float the users watch time

Rank

str the users rank

The Song Object

class Dev.Song

a song request, returned by GetSongQueue

Title

str the title of the song

RequestedBy

str the requester of the song. this is their userid

RequestedByName

str the requester of the song. this is their username

ID

str the id of the song

URL

str the URL of the song

Dev Permission Levels

These are passed to HasPermission

Permisssion

Who is it

Caster

The Streamer

Editor

A Chatbot editor

Moderator

A Stream moderator

VIP+

A VIP or a subscriber

VIP

A VIP on stream

Subscriber

A subscriber on the platform

Regular

A Chatbot regular

The Data object

This will be passed to Execute

class Dev.Data

The object passed to Execute

User

str The user’s userid

UserName

str The user’s username

Message

str The message sent

RawData

str The raw data (Ex. the IRC data if from twitch)

ServiceType

Unknown

IsChatMessage()

Checks if the data is for a chat message

Returns

bool

IsRawData()

checks if the data is unparsed, Ex. a raid message through twitch IRC

Returns

bool

IsFromTwitch()

checks if the data came from twitch

Returns

bool

IsFromYoutube()

checks if the data came from youtube

Returns

bool

IsFromMixer()

checks if the data came from mixer

Note

mixer has shut down, this will never return true anymore

Returns

bool

IsFromDiscord()

checks if the data came from discord

Returns

bool

IsWhisper()

checks if the data is a whisper/dm

Returns

bool

GetParam(n)

gets an argument from the ~Data.Message

Parameters

n (int) – the index to get from

Returns

str

GetParamCount()

returns the amount of parameters the message contains

Returns

int