Fix some bugs
This commit is contained in:
parent
b5827df2f1
commit
5ee578258e
3 changed files with 15 additions and 12 deletions
|
|
@ -8,7 +8,7 @@ from .utils import *
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
__all__ = ["Bot"]
|
__all__ = ["Bot", "command"]
|
||||||
|
|
||||||
|
|
||||||
# Some command stuff
|
# Some command stuff
|
||||||
|
|
@ -30,7 +30,7 @@ def command(commandname, specific=True, noargs=False):
|
||||||
if argstr: return
|
if argstr: return
|
||||||
return await func(self, room, message, *args, **kwargs)
|
return await func(self, room, message, *args, **kwargs)
|
||||||
else:
|
else:
|
||||||
return await func(self, room, message, args*args, **kwargs)
|
return await func(self, room, message, argstr, *args, **kwargs)
|
||||||
return wrapper
|
return wrapper
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
@ -38,14 +38,11 @@ def command(commandname, specific=True, noargs=False):
|
||||||
# And now comes the real bot...
|
# And now comes the real bot...
|
||||||
|
|
||||||
class Bot(Inhabitant):
|
class Bot(Inhabitant):
|
||||||
def __init__(self, nick, cookiefile=None, rooms=["test"]):
|
def __init__(self, nick, cookiefile=None):
|
||||||
self.target_nick = nick
|
self.target_nick = nick
|
||||||
self.rooms = {}
|
self.rooms = {}
|
||||||
self.cookiejar = CookieJar(cookiefile)
|
self.cookiejar = CookieJar(cookiefile)
|
||||||
|
|
||||||
for roomname in rooms:
|
|
||||||
self.join_room(roomname)
|
|
||||||
|
|
||||||
# ROOM MANAGEMENT
|
# ROOM MANAGEMENT
|
||||||
|
|
||||||
def join_room(self, roomname, password=None):
|
def join_room(self, roomname, password=None):
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,7 @@ class Room:
|
||||||
if self._status == Room.CLOSED:
|
if self._status == Room.CLOSED:
|
||||||
raise RoomClosed()
|
raise RoomClosed()
|
||||||
|
|
||||||
|
self.target_nick = nick
|
||||||
ptype, data, error, throttled = await self._send_while_connected(
|
ptype, data, error, throttled = await self._send_while_connected(
|
||||||
"nick",
|
"nick",
|
||||||
name=nick
|
name=nick
|
||||||
|
|
@ -126,11 +127,6 @@ class Room:
|
||||||
return pm_id, to_nick
|
return pm_id, to_nick
|
||||||
|
|
||||||
async def send(self, content, parent_mid=None):
|
async def send(self, content, parent_mid=None):
|
||||||
"""
|
|
||||||
Send a message to the room.
|
|
||||||
See http://api.euphoria.io/#send
|
|
||||||
"""
|
|
||||||
|
|
||||||
if parent_mid:
|
if parent_mid:
|
||||||
ptype, data, error, throttled = await self._send_while_connected(
|
ptype, data, error, throttled = await self._send_while_connected(
|
||||||
"send",
|
"send",
|
||||||
|
|
@ -146,7 +142,8 @@ class Room:
|
||||||
return Message.from_dict(data)
|
return Message.from_dict(data)
|
||||||
|
|
||||||
async def who(self):
|
async def who(self):
|
||||||
pass
|
ptype, data, error, throttled = await self._send_while_connected("who")
|
||||||
|
self.listing = Listing.from_dict(data.get("listing"))
|
||||||
|
|
||||||
# COMMUNICATION WITH CONNECTION
|
# COMMUNICATION WITH CONNECTION
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"parallel",
|
"parallel",
|
||||||
"mention", "mention_reduced", "similar",
|
"mention", "mention_reduced", "similar",
|
||||||
|
|
@ -144,6 +146,13 @@ class Listing:
|
||||||
|
|
||||||
return sessions
|
return sessions
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, d):
|
||||||
|
listing = cls()
|
||||||
|
for session in d:
|
||||||
|
listing.add(Session.from_dict(session))
|
||||||
|
return listing
|
||||||
|
|
||||||
#def get_people(self):
|
#def get_people(self):
|
||||||
#return self.get(types=["agent", "account"])
|
#return self.get(types=["agent", "account"])
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue