Archived
1
0
Fork 0

Implement groupchats in the adapter for Lita

This commit is contained in:
Braiden Vasco 2015-09-14 08:10:18 +00:00
parent 55f2c56259
commit 67941b4cc8

View file

@ -41,6 +41,20 @@ module Lita
message.command!
robot.receive(message)
end
@tox.on_group_invite do |friend_number, data|
@tox.join_groupchat(friend_number, data)
end
@tox.on_group_message do |group_number, peer_number, text|
unless @tox.group_peernumber_is_ours(group_number, peer_number)
user = User.new(-1 - peer_number) # TODO
source = Source.new(user: user, room: group_number)
message = Message.new(robot, text, source)
robot.receive(message)
end
end
end
def run
@ -59,7 +73,11 @@ module Lita
def send_messages(target, messages)
messages.reject(&:empty?).each do |message|
@tox.friend_send_message(target.user.id.to_i, message)
if target.user.id.to_i >= 0
@tox.friend_send_message(target.user.id.to_i, message)
else
@tox.group_message_send(target.room.to_i, message)
end
end
end
end