Skip to content

Commit

Permalink
📝 improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mraniki committed Aug 8, 2023
1 parent fa95f64 commit 2f83a0b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 43 deletions.
1 change: 0 additions & 1 deletion docs/01_start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Setup your config
Create your config file settings.toml or use env variables.
Refer to :doc:`talky:02_config` for details.

example:

.. literalinclude:: ../examples/example_settings.toml

Expand Down
7 changes: 2 additions & 5 deletions docs/02_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Config will load:
- user secrets: .secrets.toml

Your settings should be setup in settings.toml, .secrets.toml, .env or environment variable.
Settings.toml or .env can be located in :file:`/app/settings.toml` or :file:`/app/.env` for docker.
If deployed locally, place your file in :file:`/tt/` folder.
Settings.toml or .env can be located in :file:`/app/settings.toml` or :file:`/app/.env` for docker.
If deployed locally, place your file in :file:`/tt/` folder.


Talky Settings
Expand All @@ -45,7 +45,6 @@ Settings Example

Settings.toml
-------------
example:

.. literalinclude:: ../examples/example_settings.toml
:linenos:
Expand All @@ -54,8 +53,6 @@ example:
.env or ENV VARS
------------------

place the .env at

.. literalinclude:: ../examples/example.env
:linenos:

32 changes: 2 additions & 30 deletions docs/plugins/helper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,9 @@
helper
=====

Provide multiple function such as giving the list of
available command, network ping or restarting the bot

Function
=====

Help
----

:file:`/help` command to return the list of available command

Trading Switch
--------------

:file:`/trading` command to turn off or on the trading capability

Network
-------

:file:`/network` command to retrieve the network ping latency and IP of the bot

Restart
--------

:file:`/restart` command to restart the bot


Module Reference
================

.. automodule:: tt.plugins.default_plugins.helper_plugin
:members:
:undoc-members:



43 changes: 36 additions & 7 deletions tt/plugins/default_plugins/helper_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@


class HelperPlugin(BasePlugin):
""" Helper Plugin """
"""
Helper Plugin
Provide multiple function
such as giving the list of
available command, network ping
or restarting the bot
"""
name = os.path.splitext(os.path.basename(__file__))[0]
def __init__(self):
super().__init__()
Expand Down Expand Up @@ -53,31 +60,53 @@ async def handle_message(self, msg):
await self.send_notification(f"{await function()}")

async def get_helper_help(self):
"""Help Message"""
"""
Help Message
:file:`/help` command to
return the list of
available command
"""
return f"{self.help_message}"

async def get_helper_info(self):
"""Help Message"""
"""
return
TalkyTrader version
"""
return self.version

async def get_helper_network(self):
"""Help Message"""
"""
:file:`/network` command to retrieve the network
ping latency and
the bot IP address
"""
ping_result = ping3.ping(settings.ping, unit='ms')
ping_result = round(ping_result, 2) if ping_result is not None else 0
return (f"️{self.host_ip}\n"
f"🏓 {ping_result}\n")

async def trading_switch_command(self):
"""Trading switch command"""
"""
Trading switch command
:file:`/trading` command
to turn off or on the
trading capability
"""
settings.trading_enabled = not settings.trading_enabled
return f"Trading is {'enabled' if settings.trading_enabled else 'disabled'}."

async def restart(self):
"""Restart Bot """
"""
:file:`/restart` command
to restart the bot
"""
os.execl(sys.executable, os.path.abspath(__file__), sys.argv[0])

def get_host_ip(self):
"""Returns host IP """
"""
Returns bot IP
"""
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect((settings.ping, 80))
ip_address = s.getsockname()[0]
Expand Down

0 comments on commit 2f83a0b

Please sign in to comment.