Implement Client.get_message_by_id()
This commit is contained in:
parent
447e593edb
commit
657c6d4b98
1 changed files with 15 additions and 3 deletions
|
@ -9,7 +9,7 @@ from typing import Optional
|
||||||
from nntp.tiny.socket import Connection
|
from nntp.tiny.socket import Connection
|
||||||
from nntp.tiny.host import Host
|
from nntp.tiny.host import Host
|
||||||
from nntp.tiny.response import Response, ResponseCode
|
from nntp.tiny.response import Response, ResponseCode
|
||||||
from nntp.tiny.message import MessageRange
|
from nntp.tiny.message import MessageRange, Message
|
||||||
|
|
||||||
from nntp.tiny.remote import (
|
from nntp.tiny.remote import (
|
||||||
RemoteException,
|
RemoteException,
|
||||||
|
@ -119,9 +119,9 @@ class Client(Connection):
|
||||||
int(parts[2]),
|
int(parts[2]),
|
||||||
parts[3] == 'y')
|
parts[3] == 'y')
|
||||||
|
|
||||||
def each_newsgroup_message(self, newsgroup: RemoteNewsgroup, msgrange: Optional[MessageRange]):
|
def each_newsgroup_message_overview(self, newsgroup: RemoteNewsgroup, msgrange: Optional[MessageRange]):
|
||||||
self.request('OVER', str(msgrange))
|
|
||||||
self.select_group(newsgroup.name)
|
self.select_group(newsgroup.name)
|
||||||
|
self.request('OVER', str(msgrange))
|
||||||
|
|
||||||
for line in self.each_response_line():
|
for line in self.each_response_line():
|
||||||
parts = line.split('\t')
|
parts = line.split('\t')
|
||||||
|
@ -142,3 +142,15 @@ class Client(Connection):
|
||||||
message.headers[key] = value
|
message.headers[key] = value
|
||||||
|
|
||||||
yield message
|
yield message
|
||||||
|
|
||||||
|
def get_message_by_id(self, message_id: str) -> Message:
|
||||||
|
message = Message()
|
||||||
|
|
||||||
|
self.request('ARTICLE', message_id)
|
||||||
|
|
||||||
|
for line in self.each_response_line():
|
||||||
|
message.readline(line + "\r\n")
|
||||||
|
|
||||||
|
message.finish()
|
||||||
|
|
||||||
|
return message
|
||||||
|
|
Loading…
Add table
Reference in a new issue