-
Notifications
You must be signed in to change notification settings - Fork 3
/
pywxtest.py
51 lines (39 loc) · 1.34 KB
/
pywxtest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import os
import sys
from modules import registry
def test_command(command, args):
lines = reg.commands[command].run({'sender': 'mach5', 'msg': f'{command} {args}', 'command': command, 'args': args})
for line in lines:
print('--')
print(repr(line))
def test_periodic_command(config, command):
lines = reg.periodic_tasks[command]['command'](config).run()
for line in lines:
print('--')
print(repr(line))
def test_parser(msg):
parsed_things = []
msg = {'msg': msg}
for parser in reg.parsers:
for line in parser.parse(msg):
parsed_things.append(line)
for line in parsed_things:
print('--')
print(repr(line))
if __name__ == '__main__':
try:
config = json.load(open('data/local_config.json', encoding='utf-8'))
config['pywx_path'] = os.path.dirname(os.path.abspath(__file__))
except ImportError:
print('cant import local_config.py')
sys.exit()
reg = registry.registry
reg.load_modules(config)
# test_command('lastalert', '35169')
test_parser('https://bsky.app/profile/staceyhood.bsky.social/post/3lbsehmeft22r')
# test_periodic_command(config, "scanner")
# test_periodic_command(config, "scanner")
# test_periodic_command(config, "scanner")