forked from SFTtech/cyberbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkvtest_plugin.py
136 lines (110 loc) · 4.48 KB
/
kvtest_plugin.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import asyncio
HELP_DESC = """
!addlocalval key val
!addroomval key val
!addpluginval key val
!getlocalval key
!getroomval key
!getpluginval key
!remlocalval key
!remroomval key
!rempluginval key
!getlocalkeys
!getroomkeys
!getpluginkeys
"""[
1:-1
]
async def register_to(plugin):
async def addlocalval_callback(room, event):
args = plugin.extract_args(event)
if len(args) == 3:
key = args[1]
val = args[2]
await plugin.kvstore_set_local_value(key, val)
addlocalval_handler = plugin.CommandHandler("addlocalval", addlocalval_callback)
plugin.add_handler(addlocalval_handler)
async def addroomval_callback(room, event):
args = plugin.extract_args(event)
if len(args) == 3:
key = args[1]
val = args[2]
await plugin.kvstore_set_room_value(key, val)
addroomval_handler = plugin.CommandHandler("addroomval", addroomval_callback)
plugin.add_handler(addroomval_handler)
async def addpluginval_callback(room, event):
args = plugin.extract_args(event)
if len(args) == 3:
key = args[1]
val = args[2]
await plugin.kvstore_set_plugin_value(key, val)
addpluginval_handler = plugin.CommandHandler("addpluginval", addpluginval_callback)
plugin.add_handler(addpluginval_handler)
async def getlocalval_callback(room, event):
args = plugin.extract_args(event)
if len(args) == 2:
key = args[1]
r = await plugin.kvstore_get_local_value(key)
await plugin.send_text(str(r))
getlocalval_handler = plugin.CommandHandler("getlocalval", getlocalval_callback)
plugin.add_handler(getlocalval_handler)
async def getroomval_callback(room, event):
args = plugin.extract_args(event)
if len(args) == 2:
key = args[1]
r = await plugin.kvstore_get_room_value(key)
await plugin.send_text(str(r))
getroomval_handler = plugin.CommandHandler("getroomval", getroomval_callback)
plugin.add_handler(getroomval_handler)
async def getpluginval_callback(room, event):
args = plugin.extract_args(event)
if len(args) == 2:
key = args[1]
r = await plugin.kvstore_get_plugin_value(key)
await plugin.send_text(str(r))
getpluginval_handler = plugin.CommandHandler("getpluginval", getpluginval_callback)
plugin.add_handler(getpluginval_handler)
async def remlocalval_callback(room, event):
args = plugin.extract_args(event)
await plugin.kvstore_get_local_keys()
if len(args) == 2:
key = args[1]
r = await plugin.kvstore_rem_local_value(key)
await plugin.send_text(str(r))
remlocalval_handler = plugin.CommandHandler("remlocalval", remlocalval_callback)
plugin.add_handler(remlocalval_handler)
async def remroomval_callback(room, event):
args = plugin.extract_args(event)
await plugin.kvstore_get_room_keys()
if len(args) == 2:
key = args[1]
r = await plugin.kvstore_rem_room_value(key)
await plugin.send_text(str(r))
remroomval_handler = plugin.CommandHandler("remroomval", remroomval_callback)
plugin.add_handler(remroomval_handler)
async def rempluginval_callback(room, event):
args = plugin.extract_args(event)
await plugin.kvstore_get_plugin_keys()
if len(args) == 2:
key = args[1]
r = await plugin.kvstore_rem_plugin_value(key)
await plugin.send_text(str(r))
rempluginval_handler = plugin.CommandHandler("rempluginval", rempluginval_callback)
plugin.add_handler(rempluginval_handler)
async def getlocalkeys_callback(room, event):
r = await plugin.kvstore_get_local_keys()
await plugin.send_text(" ".join(r))
getlocalkeys_handler = plugin.CommandHandler("getlocalkeys", getlocalkeys_callback)
plugin.add_handler(getlocalkeys_handler)
async def getroomkeys_callback(room, event):
r = await plugin.kvstore_get_room_keys()
await plugin.send_text(" ".join(r))
getroomkeys_handler = plugin.CommandHandler("getroomkeys", getroomkeys_callback)
plugin.add_handler(getroomkeys_handler)
async def getpluginkeys_callback(room, event):
r = await plugin.kvstore_get_plugin_keys()
await plugin.send_text(" ".join(r))
getpluginkeys_handler = plugin.CommandHandler(
"getpluginkeys", getpluginkeys_callback
)
plugin.add_handler(getpluginkeys_handler)