Formatting.
This commit is contained in:
		
							parent
							
								
									b745d310fd
								
							
						
					
					
						commit
						a28df0371f
					
				| @ -1,7 +1,6 @@ | |||||||
| import asyncio |  | ||||||
| import os |  | ||||||
| from nio import AsyncClient, RoomMessageText | from nio import AsyncClient, RoomMessageText | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| class BooeehBot: | class BooeehBot: | ||||||
|     def __init__(self, url, username, password): |     def __init__(self, url, username, password): | ||||||
|         self.url = url |         self.url = url | ||||||
| @ -19,7 +18,7 @@ class BooeehBot: | |||||||
|             return None |             return None | ||||||
| 
 | 
 | ||||||
|     async def handle_message(self, room, event): |     async def handle_message(self, room, event): | ||||||
|         specific_user_id = '@joewilliams007:matrix.org' |         specific_user_id = "@joewilliams007:matrix.org" | ||||||
| 
 | 
 | ||||||
|         if isinstance(event, RoomMessageText): |         if isinstance(event, RoomMessageText): | ||||||
|             if event.sender == specific_user_id: |             if event.sender == specific_user_id: | ||||||
| @ -28,10 +27,7 @@ class BooeehBot: | |||||||
|                     await self.client.room_send( |                     await self.client.room_send( | ||||||
|                         room.room_id, |                         room.room_id, | ||||||
|                         message_type="m.room.message", |                         message_type="m.room.message", | ||||||
|                         content={ |                         content={"msgtype": "m.text", "body": response_text}, | ||||||
|                             "msgtype": "m.text", |  | ||||||
|                             "body": response_text |  | ||||||
|                         } |  | ||||||
|                     ) |                     ) | ||||||
|                     print(f"Response to {event.sender}: " + response_text) |                     print(f"Response to {event.sender}: " + response_text) | ||||||
|                 except Exception as e: |                 except Exception as e: | ||||||
| @ -48,6 +44,3 @@ class BooeehBot: | |||||||
| 
 | 
 | ||||||
|     async def stop(self): |     async def stop(self): | ||||||
|         await self.client.close() |         await self.client.close() | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| import asyncio | import asyncio | ||||||
| from boeh import env | 
 | ||||||
| from boeh import BooeehBot | from boeh import BooeehBot, env | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| async def main_async(): | async def main_async(): | ||||||
|     url = "https://matrix.org" |     url = "https://matrix.org" | ||||||
| @ -13,8 +14,10 @@ async def main_async(): | |||||||
|     except KeyboardInterrupt: |     except KeyboardInterrupt: | ||||||
|         await bot.stop() |         await bot.stop() | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| def main(): | def main(): | ||||||
|     asyncio.run(main_async()) |     asyncio.run(main_async()) | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|     main() |     main() | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user