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__)
|
||||
__all__ = ["Bot"]
|
||||
__all__ = ["Bot", "command"]
|
||||
|
||||
|
||||
# Some command stuff
|
||||
|
|
@ -30,7 +30,7 @@ def command(commandname, specific=True, noargs=False):
|
|||
if argstr: return
|
||||
return await func(self, room, message, *args, **kwargs)
|
||||
else:
|
||||
return await func(self, room, message, args*args, **kwargs)
|
||||
return await func(self, room, message, argstr, *args, **kwargs)
|
||||
return wrapper
|
||||
return decorator
|
||||
|
||||
|
|
@ -38,14 +38,11 @@ def command(commandname, specific=True, noargs=False):
|
|||
# And now comes the real bot...
|
||||
|
||||
class Bot(Inhabitant):
|
||||
def __init__(self, nick, cookiefile=None, rooms=["test"]):
|
||||
def __init__(self, nick, cookiefile=None):
|
||||
self.target_nick = nick
|
||||
self.rooms = {}
|
||||
self.cookiejar = CookieJar(cookiefile)
|
||||
|
||||
for roomname in rooms:
|
||||
self.join_room(roomname)
|
||||
|
||||
# ROOM MANAGEMENT
|
||||
|
||||
def join_room(self, roomname, password=None):
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ class Room:
|
|||
if self._status == Room.CLOSED:
|
||||
raise RoomClosed()
|
||||
|
||||
self.target_nick = nick
|
||||
ptype, data, error, throttled = await self._send_while_connected(
|
||||
"nick",
|
||||
name=nick
|
||||
|
|
@ -126,11 +127,6 @@ class Room:
|
|||
return pm_id, to_nick
|
||||
|
||||
async def send(self, content, parent_mid=None):
|
||||
"""
|
||||
Send a message to the room.
|
||||
See http://api.euphoria.io/#send
|
||||
"""
|
||||
|
||||
if parent_mid:
|
||||
ptype, data, error, throttled = await self._send_while_connected(
|
||||
"send",
|
||||
|
|
@ -146,7 +142,8 @@ class Room:
|
|||
return Message.from_dict(data)
|
||||
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import asyncio
|
||||
import logging
|
||||
import time
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
__all__ = [
|
||||
"parallel",
|
||||
"mention", "mention_reduced", "similar",
|
||||
|
|
@ -144,6 +146,13 @@ class Listing:
|
|||
|
||||
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):
|
||||
#return self.get(types=["agent", "account"])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue