Initialize before starting bot
This commit is contained in:
parent
8b976e038b
commit
c53e0b6919
1 changed files with 2 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import yaboli
|
import yaboli
|
||||||
from yaboli.utils import *
|
from yaboli.utils import *
|
||||||
|
import asyncio
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
@ -66,10 +67,6 @@ class PlusOne(yaboli.Bot):
|
||||||
self.register_command("points", self.command_points, specific=False)
|
self.register_command("points", self.command_points, specific=False)
|
||||||
self.register_trigger(self.PLUSONE_RE, self.trigger_plusone)
|
self.register_trigger(self.PLUSONE_RE, self.trigger_plusone)
|
||||||
|
|
||||||
async def on_connected(self):
|
|
||||||
await super().on_connected()
|
|
||||||
await self.db.initialize()
|
|
||||||
|
|
||||||
async def trigger_plusone(self, message, match):
|
async def trigger_plusone(self, message, match):
|
||||||
specific = re.match(self.MENTION_RE, match.group(2))
|
specific = re.match(self.MENTION_RE, match.group(2))
|
||||||
if specific:
|
if specific:
|
||||||
|
|
@ -111,6 +108,7 @@ class PlusOne(yaboli.Bot):
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) == 3:
|
if len(sys.argv) == 3:
|
||||||
db = PointDB(sys.argv[2])
|
db = PointDB(sys.argv[2])
|
||||||
|
asyncio.get_event_loop().run_until_complete(db.initialize())
|
||||||
run_bot(PlusOne, sys.argv[1], db)
|
run_bot(PlusOne, sys.argv[1], db)
|
||||||
else:
|
else:
|
||||||
print("USAGE:")
|
print("USAGE:")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue