Sha256: c92170b5fa8e6deaca91995b294289e24f525b9ae5c0b6173e04122b7435dcf5

Contents?: true

Size: 726 Bytes

Versions: 1

Compression:

Stored size: 726 Bytes

Contents

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'rubygems'
$:.unshift File.expand_path '../lib', File.dirname(__FILE__)
require 'skype'

chats = Skype.chats
puts "#{chats.length} chats found"
chats.each_with_index do |c, index|
  title = "#{c.topic} #{c.members[0..5].join(',')} (#{c.members.size} users)".strip
  puts "[#{index}] #{title}"
end

chat = nil
loop do
  print "select [0]~[#{chats.size-1}] >"
  line = STDIN.gets.strip
  next unless line =~ /^\d+$/
  chat = chats[line.to_i]
  break
end

Thread.new do
  last_id = 0
  loop do
    chat.messages.each do |m|
      next unless last_id < m.id
      puts m
      last_id = m.id
    end
    sleep 1
  end
end

loop do
  line = STDIN.gets.strip
  chat.post line
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
skype-0.1.4 samples/chat.rb