entities.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/env python3
  2. #
  3. # Entities library for Internet Delay Chat server written in Python
  4. # Trio. Don't run this.
  5. #
  6. # Written by: Andrew <https://www.andrewyu.org>
  7. # luk3yx <https://luk3yx.github.io>
  8. #
  9. # This is free and unencumbered software released into the public
  10. # domain.
  11. #
  12. # Anyone is free to copy, modify, publish, use, compile, sell, or
  13. # distribute this software, either in source code form or as a compiled
  14. # binary, for any purpose, commercial or non-commercial, and by any
  15. # means.
  16. #
  17. # In jurisdictions that recognize copyright laws, the author or authors
  18. # of this software dedicate any and all copyright interest in the
  19. # software to the public domain. We make this dedication for the benefit
  20. # of the public at large and to the detriment of our heirs and
  21. # successors. We intend this dedication to be an overt act of
  22. # relinquishment in perpetuity of all present and future rights to this
  23. # software under copyright law.
  24. #
  25. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  28. # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  29. # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  30. # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  31. # OTHER DEALINGS IN THE SOFTWARE.
  32. #
  33. from __future__ import annotations
  34. from typing import Optional, Union, List, Sequence, Any
  35. from dataclasses import dataclass, field
  36. import trio.abc
  37. @dataclass
  38. class Server:
  39. # stub, we're not using it just yet
  40. rvalue: bytes
  41. domain: bytes
  42. users: dict[bytes, User]
  43. @dataclass
  44. class User:
  45. username: bytes
  46. password: bytes
  47. options: list[str]
  48. connected_clients: list[Client] = field(default_factory=list)
  49. in_channels: list[Channel] = field(default_factory=list)
  50. queue: list[bytes] = field(default_factory=list)
  51. @dataclass
  52. class Client:
  53. cid: bytes
  54. stream: trio.abc.Stream
  55. user: Optional[User] = None
  56. ccrt: Optional[Any] = None
  57. @dataclass
  58. class Guild:
  59. guildname: bytes
  60. users: list[User]
  61. channels: list[Channel]
  62. @dataclass
  63. class Channel:
  64. channelname: bytes
  65. guild: Optional[Guild]
  66. broadcast_to: list[User]