diff --git a/.gitignore b/.gitignore index 0bbd4a9..82f1ad5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -/docs/ /lib/ /bin/ /.shards/ diff --git a/docs/Caridina.html b/docs/Caridina.html index 6306a58..479f17e 100644 --- a/docs/Caridina.html +++ b/docs/Caridina.html @@ -4,7 +4,7 @@ - + @@ -18,7 +18,7 @@ -
"0.3.1"
+ VERSION = "0.4.0"
Caridina::Events::MSC2676::Message::Content
Caridina::Events::MSC2676::Message::Content
Caridina::Events::Message::Text
Caridina::Events::Message::Text
Caridina::Events::Message::Content
Caridina::Events::Message::Content
Caridina::Events::Event::Content
Caridina::Events::Event::Content
Caridina::Events::Message
Caridina::Events::Message
Caridina::Events::RoomEvent
Caridina::Events::RoomEvent
Caridina::Events::Event
Caridina::Events::Event
Caridina::Events::Message::Content
Caridina::Events::Message::Content
Caridina::Events::Event::Content
Caridina::Events::Redaction
Caridina::Events::Redaction
Caridina::Events::RoomEvent
Caridina::Events::RoomEvent
Caridina::Events::Event
Caridina::Events::Event
Caridina::Events::Redaction::Content
Caridina::Events::Redaction::Content
Caridina::Events::Event::Content
Caridina::Events::RoomEvent
Caridina::Events::RoomEvent
Caridina::Events::Event
Caridina::Events::Event
Caridina::Events::Event::Content
Caridina::Events::RoomEvent::UnsignedData
Caridina::Events::RoomEvent::UnsignedData
Caridina::Events::Unknown
Caridina::Events::Unknown
Caridina::Events::Event
Caridina::Events::Event
Caridina::Events::Unknown::Content
Caridina::Events::Event::Content
This event represents a StrippedState event.
+ +It is used in Member
event and in Responses::Sync
in invited rooms's state.
+It is actually a state event, but it does not inherit from StateEvent
as
+some fields are not presents.
This type is used to represents many distinct stripped state events.
+To distinguish them you must check the #content
's type.
This event represents a StrippedState event.
"room_id" is not set in events returned from the sync API, so we need to set it up ourself.
"room_id" is not set in events returned from the sync API, so we need to set it up ourself.
Caridina::Events::Event
Caridina::Events::Event
This event represents a StrippedState event.
+ +It is used in Member
event and in Responses::Sync
in invited rooms's state.
+It is actually a state event, but it does not inherit from StateEvent
as
+some fields are not presents.
This type is used to represents many distinct stripped state events.
+To distinguish them you must check the #content
's type.
"room_id" is not set in events returned from the sync API, so we need to +set it up ourself.
+"room_id" is not set in events returned from the sync API, so we need to +set it up ourself.
+This object allow you to register listeners to be executed when some events +are received.
+ +This avoid you to have to parse the whole Responses::Sync
.
+However #process_response
must be called with a Responses::Sync
manually.
+This allow you to control precisely when you want to handle events.
syncer = Caridina::Syncer.new
+syncer.on(Caridina::Events::Message) do |event|
+ # TODO: actually do something
+end
+
+syncer.process_response(sync)
+
+Events sent to listeners are Events::Event
objects.
+You should use a type restriction in order to access all their fields.
Caridina::Events::Event -> Nil
+ Caridina::Events::Event, Caridina::Syncer::Source -> Nil
@@ -500,13 +505,6 @@ 1
+ 2
+ Now we can create a new channel, and tell the connection object to start syncing. The sync responses will be streamed in the channel.
-matrix = Channel(Caridina::Events::Sync).new
+matrix = Channel(Caridina::Events::Sync).new
conn.sync(matrix)
-sync = matrix.receive
+sync = matrix.receive
You have now a sync response.
If you don't want to go through the whole sync response by yourself (which is understandable), we provide you a Caridina::Syncer object.
-syncer = Caridina::Syncer.new
-syncer.on(Caridina::Events::Message) do |event|
- # TODO: actually do something
-end
+syncer = Caridina::Syncer.new
+syncer.on(Caridina::Events::Message) do |event|
+ # TODO: actually do something
+end
syncer.process_response(sync)
@@ -557,20 +562,20 @@
will be Caridina::Events::Event
objects. You need to restrict the type of an event
object to access all its fields.
-sync.rooms.try &.join.each do |room_id, room|
- room.timeline.events.each do |event|
- case event
- when Caridina::Events::Member
- # someone's membership changed
- when Caridina:: Events::PowerLevels
- # some authorization changed
- when Caridina::Events::Messages
- # someone talked
- else
- # unknown event
- end
- end
-end
+sync.rooms.try &.join.each do |room_id, room|
+ room.timeline.events.each do |event|
+ case event
+ when Caridina::Events::Member
+ # someone's membership changed
+ when Caridina:: Events::PowerLevels
+ # some authorization changed
+ when Caridina::Events::Messages
+ # someone talked
+ else
+ # unknown event
+ end
+ end
+end
Sometimes the event's content can be polymorphic too.
That is especially the case for message events.
@@ -590,12 +595,12 @@
:warning: This part is in a very early stage.
> Currently only a few methods are provided.
-# join a room
-conn.join("!room_id:matrix.org")
-# send a message
-event_id = conn.send_message("!room_id:matrix.org", "Hello, wurld!")
-# edit a message
-conn.edit_message("!room_id:matrix.org", "Hello, world!"))
+# join a room
+conn.join("!room_id:matrix.org")
+# send a message
+event_id = conn.send_message("!room_id:matrix.org", "Hello, wurld!")
+# edit a message
+conn.edit_message("!room_id:matrix.org", "Hello, world!"))
- Top Level Namespace - caridina main
+ Top Level Namespace - caridina main-dev
@@ -39,7 +39,7 @@
- main
+ main-dev
@@ -211,11 +211,6 @@
-
- StrippedState
-
-
-
UnsignedData
@@ -341,6 +336,11 @@
+
+ StrippedState
+
+
+
Type
@@ -441,6 +441,11 @@
+
+ Source
+
+
+
@@ -629,8 +634,6 @@
- [View source]
-
diff --git a/shard.yml b/shard.yml
index 4505fc3..8bd68ef 100644
--- a/shard.yml
+++ b/shard.yml
@@ -1,5 +1,5 @@
name: caridina
-version: 0.3.1
+version: 0.4.0
authors:
- Alexandre Morignot
diff --git a/src/caridina.cr b/src/caridina.cr
index 81a95e2..ef8508e 100644
--- a/src/caridina.cr
+++ b/src/caridina.cr
@@ -3,7 +3,7 @@
require "./connection"
module Caridina
- VERSION = "0.3.1"
+ VERSION = "0.4.0"
Log = ::Log.for(self)
end