Futurism › class › dAmnPacketI
From Botdom Documentation
The dAmnPacketI class (short for dAmn Packet Incoming) is used to parse out and make properties for important components found in an inputted raw dAmn packet string.
Properties
- str argblock — The raw block of arguments found in the packet.
- dict args — A dictionary of the packet arguments.
- str body — The main body of the packet.
- str head — The part of the packet which was before the body. (Original formatting of cmd, param and args).
- str cmd — The packet command name.
- str cmdblock — The first line of the packet, where the cmd name is declared.
- str param — The packet's main parameter.
- str raw — The raw packet that was inputted.
If the incoming packet is a recv packet, the following properties are also to be found. These vary a lot depending on context, and so the descriptions here are unfortunately a little vague.
- str recvargs — Specific arguments about what was received.
- str recvbody — The main content that was received.
- str recvmeta — Information about what was received.
- str recvtarget — Target information.
- str recvtype — Information about what type of content was received.
There are examples of all of these in the next section.
Initialization
__init__(str pkt)
Upon intialization of the object instance, the raw packet str pkt is inputted, and the above properties are set, and one can then refer to them later on, in an organized way of storing the information. Examples of how the properties may look under different circumstances are seen below.
pkt = dAmnPacketI("join chat:elec\ne=ok") # pkt.argblock is: e=ok # pkt.args is: {'e': 'ok'} # pkt.body is: None # pkt.cmd is: join # pkt.cmdblock is: join chat:elec # pkt.head is: join chat:elec\ne=ok # pkt.param is: chat:elec # pkt.raw is: join chat:elec\ne=ok pkt = dAmnPacketI("property chat:elec\np=topic\nby=electricnet\nts=1219854021\n\nHello! :D") # pkt.argblock is: p=topic\nby=electricnet\nts=1219854021 # pkt.args is: {'p': 'topic', 'by': 'electricnet', 'ts': '1219854021'} # pkt.body is: Hello! :D # pkt.cmd is: property # pkt.cmdblock is: property chat:elec # pkt.head is: property chat:elec\np=topic\nby=electricnet\nts=1219854021 # pkt.param is: chat:elec # pkt.raw is: property chat:elec\np=topic\nby=electricnet\nts=1219854021\n\nHello! :D pkt = dAmnPacketI("recv chat:elec\nu=someguy\n\nmsg main\n\nHey you there!") # pkt.argblock is: u=someguy # pkt.args is: {'u': 'someguy'} # pkt.body is: msg main\n\nHey you there! # pkt.cmd is: recv # pkt.cmdblock is: recv chat:elec # pkt.head is: recv chat:elec\nu=someguy # pkt.param is: chat:elec # pkt.raw is: recv chat:elec\nu=someguy\n\nmsg main\n\nHey you there! # pkt.recvargs is: {} # pkt.recvbody is: Hey you there! # pkt.recvmeta is: msg main # pkt.recvtarget is: main # pkt.recvtype is: msg pkt = dAmnPacketI("recv chat:elec\n\nkicked username\nby=electricnet\n\n:O") # pkt.argblock is: None # pkt.args is: {} # pkt.body is: kicked username\nby=electricnet\n\n:O # pkt.cmd is: recv # pkt.cmdblock is: recv chat:elec # pkt.head is: recv chat:elec # pkt.param is: chat:elec # pkt.raw is: recv chat:elec\n\nkicked username\nby=electricnet\n\n:O # pkt.recvargblock is: by=electricnet # pkt.recvargs is: {'by': 'electricnet'} # pkt.recvbody is: :O # pkt.recvmeta is: kicked username\nby=electricnet # pkt.recvtarget is: username # pkt.recvtype is: kicked

