-
Notifications
You must be signed in to change notification settings - Fork 4
/
bruh.py
75 lines (58 loc) · 1.49 KB
/
bruh.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
import os
import re
import sys
import queue
import collections
import functools
import argparse
import bruh
from walnut.drivers import Walnut
from redislite import StrictRedis
def parse():
parser = argparse.ArgumentParser(description = 'A Python3 IRC bot written for Walnut.')
parser.add_argument(
'-d',
dest = 'data',
action = 'store',
help = 'location of the database file'
)
parser.add_argument(
'-a',
dest = 'aof',
action = 'store',
help = 'enable redis aof (will erase db)'
)
return parser.parse_args()
if __name__ == '__main__':
print('Loading Plugins...')
for plugin in os.listdir('plugins'):
if plugin.endswith('.py'):
name = plugin[:-3]
plugin = __import__('plugins.' + name, globals(), locals(), -1)
print('Running')
Walnut.run('bruh')
else:
c = {}
e = {}
s = []
p = parse()
r = None
print('Opening Database...')
r = StrictRedis(p.data or 'data.rdb', db=4, serverconfig={
'appendonly': 'yes' if p.aof else 'no',
'appendfilename': p.aof or 'data.aof',
'appendfsync': 'everysec'
})
def command(name):
def register_command(f):
c[name] = f
return f
return register_command
def regex(pattern):
def register_command(f):
e[pattern] = f
return f
return register_command
def sink(f):
s.append(f)
return f