|
@@ -5,25 +5,36 @@ async def start():
|
|
|
host = "127.0.0.1"
|
|
host = "127.0.0.1"
|
|
|
port = 11066
|
|
port = 11066
|
|
|
channel = "#dev"
|
|
channel = "#dev"
|
|
|
- nickname = "meeting"
|
|
|
|
|
|
|
+ nickname = "meeting_bot"
|
|
|
|
|
|
|
|
print(f"Start a connection {host}:{port}")
|
|
print(f"Start a connection {host}:{port}")
|
|
|
reader, writer = await asyncio.open_connection(host, port)
|
|
reader, writer = await asyncio.open_connection(host, port)
|
|
|
|
|
|
|
|
|
|
+ print("Send CAP msg")
|
|
|
|
|
+ cap_msg = f"CAP REQ : no-history \r\n"
|
|
|
|
|
+ writer.write(cap_msg.encode('utf8'))
|
|
|
|
|
+
|
|
|
print("Send NICK msg")
|
|
print("Send NICK msg")
|
|
|
nick_msg = f"NICK {nickname} \r\n"
|
|
nick_msg = f"NICK {nickname} \r\n"
|
|
|
writer.write(nick_msg.encode('utf8'))
|
|
writer.write(nick_msg.encode('utf8'))
|
|
|
|
|
|
|
|
|
|
+ print("Send CAP END msg")
|
|
|
|
|
+ cap_end_msg = f"CAP END \r\n"
|
|
|
|
|
+ writer.write(cap_end_msg.encode('utf8'))
|
|
|
|
|
+
|
|
|
print(f"Send JOIN msg: {channel}")
|
|
print(f"Send JOIN msg: {channel}")
|
|
|
join_msg = f"JOIN {channel} \r\n"
|
|
join_msg = f"JOIN {channel} \r\n"
|
|
|
writer.write(join_msg.encode('utf8'))
|
|
writer.write(join_msg.encode('utf8'))
|
|
|
|
|
|
|
|
topics = []
|
|
topics = []
|
|
|
|
|
|
|
|
|
|
+ print("Start...")
|
|
|
while True:
|
|
while True:
|
|
|
- msg = await reader.read(350)
|
|
|
|
|
|
|
+ msg = await reader.read(1024)
|
|
|
msg = msg.decode('utf8').strip()
|
|
msg = msg.decode('utf8').strip()
|
|
|
|
|
|
|
|
|
|
+ print(msg)
|
|
|
|
|
+
|
|
|
if not msg:
|
|
if not msg:
|
|
|
print("Error: Receive empty msg")
|
|
print("Error: Receive empty msg")
|
|
|
break
|
|
break
|
|
@@ -56,16 +67,19 @@ async def start():
|
|
|
reply = f"PRIVMSG {channel} :add topic: {topic} \r\n"
|
|
reply = f"PRIVMSG {channel} :add topic: {topic} \r\n"
|
|
|
|
|
|
|
|
if msg_title == "#m_list":
|
|
if msg_title == "#m_list":
|
|
|
- tp = " ".join(
|
|
|
|
|
- [f"{i}-{topic}" for i, topic in enumerate(topics, 1)])
|
|
|
|
|
|
|
+ rep = f"PRIVMSG {channel} :topics: \r\n"
|
|
|
|
|
+ writer.write(rep.encode('utf8'))
|
|
|
|
|
|
|
|
- reply = f"PRIVMSG {channel} :topics: {tp} \r\n"
|
|
|
|
|
|
|
+ for i, topic in enumerate(topics, 1):
|
|
|
|
|
+ rep = f"PRIVMSG {channel} :{i}-{topic} \r\n"
|
|
|
|
|
+ writer.write(rep.encode('utf8'))
|
|
|
|
|
+ await writer.drain()
|
|
|
|
|
|
|
|
if msg_title == "#m_next":
|
|
if msg_title == "#m_next":
|
|
|
if len(topics) == 0:
|
|
if len(topics) == 0:
|
|
|
reply = f"PRIVMSG {channel} :no topics \r\n"
|
|
reply = f"PRIVMSG {channel} :no topics \r\n"
|
|
|
else:
|
|
else:
|
|
|
- tp = topics.pop(0)
|
|
|
|
|
|
|
+ tp = topics.pop(0)
|
|
|
reply = f"PRIVMSG {channel} :current topic: {tp} \r\n"
|
|
reply = f"PRIVMSG {channel} :current topic: {tp} \r\n"
|
|
|
|
|
|
|
|
if reply != None:
|
|
if reply != None:
|