Skip to content

Commit

Permalink
Some reordering and send_text_to_channel function
Browse files Browse the repository at this point in the history
  • Loading branch information
Mydayyy committed Sep 22, 2017
1 parent dffbd93 commit 5c30509
Showing 1 changed file with 50 additions and 37 deletions.
87 changes: 50 additions & 37 deletions Bot/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,43 @@ def get_value(self, key, default_value=None):
"""
return self._dataManager.get_value(key, default_value)

@staticmethod
def get_user_setting(key_path):
"""!
@brief Returns the value of an user setting.
This function returns the value of an user setting.
These are values the user can define inside their config.json.
The key can be a path to a value ( separated with . )
which will correspond to a key nested inside the json document.
E.g:
key_path = MyPlugin.youtube.api_key
would correspond to the following structure inside config.json:
```
{
"chosen_config_namespace": {
"plugins": {
"MyPlugin": {
"youtube": {
"api_key": "000000000000000"
}
}
}
}
}
```
The config namespace and the plugins key be prepended automatically.
@param key_path The path to the value
@return The value at the given path
"""
return config.get_value("plugins." + key_path)

def get_clients(self):
"""!
@brief Returns an array of currently connected client ids. This excludes server query clients.
Expand Down Expand Up @@ -923,43 +960,6 @@ def register_value_changed_callback(self, key, callback):
self._callbacksValueChanged[key] = []
self._callbacksValueChanged[key].append(callback)

@staticmethod
def get_user_setting(key_path):
"""!
@brief Returns the value of an user setting.
This function returns the value of an user setting.
These are values the user can define inside their config.json.
The key can be a path to a value ( separated with . )
which will correspond to a key nested inside the json document.
E.g:
key_path = MyPlugin.youtube.api_key
would correspond to the following structure inside config.json:
```
{
"chosen_config_namespace": {
"plugins": {
"MyPlugin": {
"youtube": {
"api_key": "000000000000000"
}
}
}
}
}
```
The config namespace and the plugins key be prepended automatically.
@param key_path The path to the value
@return The value at the given path
"""
return config.get_value("plugins." + key_path)

def start_timer(self, callback, interval, is_single_shot=False, *args):
"""!
@brief A timer will be started and the callback will be called after interval seconds with the given args.
Expand Down Expand Up @@ -1125,6 +1125,19 @@ def send_text_to_client(self, clid, message, callback=None, data=None, err_callb
clid, escape(message)
), callback, data, err_callback)

def send_text_to_channel(self, cid, message):
"""!
@brief Sends a text message in a channel
@param cid Channel id
@param msg Message to send
@return None
"""
self.switch_to_channel(cid)
self.send_command("sendtextmessage targetmode=2 target={0} msg={1}".format(
cid, escape(message)
))

# more complex server query wrappers encapsulating multiple commands into one function
def login_use(self, register_for_events=True):
"""!
Expand Down

0 comments on commit 5c30509

Please sign in to comment.