1212from botframework .connector .aio import ConnectorClient
1313from botframework .connector .teams .teams_connector_client import TeamsConnectorClient
1414
15+
1516class TeamsInfo :
1617 @staticmethod
1718 def get_team_details (turn_context : TurnContext , team_id : str = "" ) -> TeamDetails :
@@ -23,20 +24,28 @@ def get_team_details(turn_context: TurnContext, team_id: str = "") -> TeamDetail
2324 "TeamsInfo.get_team_details: method is only valid within the scope of MS Teams Team."
2425 )
2526
26- return TeamsInfo .get_teams_connector_client (turn_context ).teams .get_team_details (team_id )
27+ return TeamsInfo .get_teams_connector_client (
28+ turn_context
29+ ).teams .get_team_details (team_id )
2730
2831 @staticmethod
29- def get_team_channels (turn_context : TurnContext , team_id : str = "" ) -> List [ChannelInfo ]:
32+ def get_team_channels (
33+ turn_context : TurnContext , team_id : str = ""
34+ ) -> List [ChannelInfo ]:
3035 if not team_id :
3136 team_id = TeamsInfo .get_team_id (turn_context )
3237
3338 if not team_id :
3439 raise TypeError (
3540 "TeamsInfo.get_team_channels: method is only valid within the scope of MS Teams Team."
3641 )
37-
38- return TeamsInfo .get_teams_connector_client (turn_context ).teams .get_teams_channels (team_id ).conversations
39-
42+
43+ return (
44+ TeamsInfo .get_teams_connector_client (turn_context )
45+ .teams .get_teams_channels (team_id )
46+ .conversations
47+ )
48+
4049 @staticmethod
4150 async def get_team_members (turn_context : TurnContext , team_id : str = "" ):
4251 if not team_id :
@@ -47,49 +56,60 @@ async def get_team_members(turn_context: TurnContext, team_id: str = ""):
4756 "TeamsInfo.get_team_members: method is only valid within the scope of MS Teams Team."
4857 )
4958
50- return await TeamsInfo ._get_members (TeamsInfo ._get_connector_client (turn_context ), turn_context .activity .conversation .id )
59+ return await TeamsInfo ._get_members (
60+ TeamsInfo ._get_connector_client (turn_context ),
61+ turn_context .activity .conversation .id ,
62+ )
5163
5264 @staticmethod
5365 async def get_members (turn_context : TurnContext ) -> List [TeamsChannelAccount ]:
5466 team_id = TeamsInfo .get_team_id (turn_context )
5567 if not team_id :
5668 conversation_id = turn_context .activity .conversation .id
57- return await TeamsInfo ._get_members (TeamsInfo ._get_connector_client (turn_context ), conversation_id )
58-
69+ return await TeamsInfo ._get_members (
70+ TeamsInfo ._get_connector_client (turn_context ), conversation_id
71+ )
72+
5973 return await TeamsInfo .get_team_members (turn_context , team_id )
6074
6175 @staticmethod
6276 def get_teams_connector_client (turn_context : TurnContext ) -> TeamsConnectorClient :
6377 connector_client = TeamsInfo ._get_connector_client (turn_context )
64- return TeamsConnectorClient (connector_client .config .credentials , turn_context .activity .service_url )
78+ return TeamsConnectorClient (
79+ connector_client .config .credentials , turn_context .activity .service_url
80+ )
6581
6682 # TODO: should have access to adapter's credentials
67- #return TeamsConnectorClient(turn_context.adapter._credentials, turn_context.activity.service_url)
83+ # return TeamsConnectorClient(turn_context.adapter._credentials, turn_context.activity.service_url)
6884
6985 @staticmethod
7086 def get_team_id (turn_context : TurnContext ):
7187 channel_data = TeamsChannelData (** turn_context .activity .channel_data )
7288 if channel_data .team :
73- #urllib.parse.quote_plus(
74- return channel_data .team ['id' ]
89+ # urllib.parse.quote_plus(
90+ return channel_data .team ["id" ]
7591 return ""
7692
7793 @staticmethod
7894 def _get_connector_client (turn_context : TurnContext ) -> ConnectorClient :
7995 return turn_context .adapter .create_connector_client (
8096 turn_context .activity .service_url
8197 )
82-
98+
8399 @staticmethod
84- async def _get_members (connector_client : ConnectorClient , conversation_id : str ) -> List [TeamsChannelAccount ]:
100+ async def _get_members (
101+ connector_client : ConnectorClient , conversation_id : str
102+ ) -> List [TeamsChannelAccount ]:
85103 if connector_client is None :
86104 raise TypeError ("TeamsInfo._get_members.connector_client: cannot be None." )
87105
88106 if not conversation_id :
89107 raise TypeError ("TeamsInfo._get_members.conversation_id: cannot be empty." )
90108
91109 teams_members = []
92- members = await connector_client .conversations .get_conversation_members (conversation_id )
110+ members = await connector_client .conversations .get_conversation_members (
111+ conversation_id
112+ )
93113
94114 for member in members :
95115 new_account_json = member .serialize ()
0 commit comments