Skip to content

Commit 5dcf522

Browse files
committed
major updates
1 parent ee64618 commit 5dcf522

36 files changed

+848
-69
lines changed

.gitignore

100644100755
File mode changed.

LICENSE

100644100755
File mode changed.

README.md

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![demopic](img/webhooks_bot_logo.png)
1+
![demopic](https://user-images.githubusercontent.com/38849824/160300853-ef6fe753-36d6-41a9-9bd2-8a06f7add71d.png)
22

33
![](https://img.shields.io/github/license/robswc/tradingview-webhooks-bot?style=for-the-badge)
44
![](https://img.shields.io/github/repo-size/robswc/tradingview-webhooks-bot?style=for-the-badge)

img/webhooks_bot_logo.png

-9.08 KB
Binary file not shown.

requirements.txt

100644100755
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
click==8.0.4
1+
click==7.1.2
2+
colorama==0.4.5
23
Flask==2.0.3
4+
gunicorn==20.1.0
35
itsdangerous==2.1.2
46
Jinja2==3.1.1
57
MarkupSafe==2.1.1
6-
typer==0.4.0
8+
shellingham==1.5.0
9+
typer==0.3.2
10+
typer-cli==0.0.12
711
Werkzeug==2.0.3

src/commons.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# settings
2+
LOG_LOCATION = 'components/logs/log.log'
3+
LOG_LIMIT = 100
4+
5+
# ensure log file exists
6+
try:
7+
open(LOG_LOCATION, 'r')
8+
except FileNotFoundError:
9+
open(LOG_LOCATION, 'w').close()
10+
11+
# DO NOT CHANGE
12+
VERSION_NUMBER = '0.5'

src/components/actions/base/__init__.py

Whitespace-only changes.

src/components/actions/base/action.py

100644100755
Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
import datetime
22
from logging import getLogger, DEBUG
33

4-
from utils.log import CONSOLE_HANDLER
4+
from components.logs.log_event import LogEvent
5+
from utils.log import get_logger
56

6-
logger = getLogger(__name__)
7-
logger.addHandler(CONSOLE_HANDLER)
8-
logger.setLevel(DEBUG)
7+
logger = get_logger(__name__)
98

109

1110
class ActionManager:
1211
def __init__(self):
1312
self._actions = []
1413

14+
def get_all(self):
15+
"""
16+
Gets all actions from manager
17+
:return: list of Action()
18+
"""
19+
return self._actions
20+
1521
def get(self, action_name: str):
1622
"""
1723
Gets action from manager that matches given name
@@ -39,9 +45,12 @@ class Action:
3945
objects = am
4046

4147
def __init__(self):
42-
self.name = 'Unnamed Action'
48+
self.name = self.get_name()
4349
self.logs = []
4450

51+
def get_name(self):
52+
return type(self).__name__
53+
4554
def __str__(self):
4655
return f'{self.name}'
4756

@@ -52,10 +61,18 @@ def get_logs(self):
5261
"""
5362
return self.logs
5463

64+
def register(self):
65+
"""
66+
Registers action with manager
67+
"""
68+
self.objects._actions.append(self)
69+
logger.info(f'ACTION REGISTERED --->\t{str(self)}')
70+
5571
def run(self, *args, **kwargs):
5672
"""
5773
Runs, logs action
5874
"""
5975
self.logs.append(ActionLogEvent('INFO', 'action run'))
76+
log_event = LogEvent(self.name, 'action_run', datetime.datetime.now(), f'{self.name} triggered')
77+
log_event.write()
6078
logger.info(f'ACTION TRIGGERED --->\t{str(self)}')
61-
pass

src/components/actions/base/template/action_template.py

100644100755
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
class TemplateActionClass(Action):
55
def __init__(self):
66
super().__init__()
7-
self.name = '_TemplateAction_'
87

98
def run(self, *args, **kwargs):
10-
super(Action).run(*args, **kwargs)
9+
super().run(*args, **kwargs)
1110
"""
1211
Custom run method. Add your custom logic here.
1312
"""
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from components.actions.base.action import Action
2+
3+
4+
class HandleOrderExample(Action):
5+
def __init__(self):
6+
super().__init__()
7+
self.name = 'handle_order_example'
8+
9+
def run(self, *args, **kwargs):
10+
super(Action).run(*args, **kwargs)
11+
"""
12+
Custom run method. Add your custom logic here.
13+
"""
14+
print(self.name, '---> action has run!')
15+
16+
17+
handle_order_example = HandleOrderExample()

0 commit comments

Comments
 (0)