mirror of
				https://github.com/onyx-and-iris/obsws-python.git
				synced 2025-11-03 22:31:48 +00:00 
			
		
		
		
	send event name to callback
add requirements to readme.
This commit is contained in:
		
							parent
							
								
									d37cda9976
								
							
						
					
					
						commit
						82ddbacd7d
					
				@ -6,6 +6,12 @@ This is a wrapper around OBS Websocket.
 | 
				
			|||||||
Not all endpoints in the official documentation are implemented. But all endpoints in the Requests section is implemented. You can find the relevant document using below link.
 | 
					Not all endpoints in the official documentation are implemented. But all endpoints in the Requests section is implemented. You can find the relevant document using below link.
 | 
				
			||||||
[obs-websocket github page](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#Requests)
 | 
					[obs-websocket github page](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#Requests)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Requirements
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-   [OBS Studio](https://obsproject.com/)
 | 
				
			||||||
 | 
					-   [OBS Websocket v5 Plugin](https://github.com/obsproject/obs-websocket/releases/tag/5.0.0)
 | 
				
			||||||
 | 
					-   Python 3.11 or greater
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### How to install using pip
 | 
					### How to install using pip
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
import re
 | 
					import re
 | 
				
			||||||
 | 
					from typing import Callable, Iterable, Union
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Callback:
 | 
					class Callback:
 | 
				
			||||||
@ -28,16 +29,16 @@ class Callback:
 | 
				
			|||||||
        for fn in self._callbacks:
 | 
					        for fn in self._callbacks:
 | 
				
			||||||
            if fn.__name__ == self.to_snake_case(event):
 | 
					            if fn.__name__ == self.to_snake_case(event):
 | 
				
			||||||
                if "eventData" in data:
 | 
					                if "eventData" in data:
 | 
				
			||||||
                    fn(data["eventData"])
 | 
					                    fn(event, data["eventData"])
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
                    fn()
 | 
					                    fn(event)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def register(self, fns):
 | 
					    def register(self, fns: Union[Iterable, Callable]):
 | 
				
			||||||
        """registers callback functions"""
 | 
					        """registers callback functions"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            iter(fns)
 | 
					            iterator = iter(fns)
 | 
				
			||||||
            for fn in fns:
 | 
					            for fn in iterator:
 | 
				
			||||||
                if fn not in self._callbacks:
 | 
					                if fn not in self._callbacks:
 | 
				
			||||||
                    self._callbacks.append(fn)
 | 
					                    self._callbacks.append(fn)
 | 
				
			||||||
        except TypeError as e:
 | 
					        except TypeError as e:
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user