Init
This commit is contained in:
commit
6b1efee8e2
4 changed files with 58 additions and 0 deletions
9
shard.yml
Normal file
9
shard.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
name: twitch-irc-crystal
|
||||
version: 0.1.0
|
||||
|
||||
authors:
|
||||
- Fijxu <fijxu@nadeko.net>
|
||||
|
||||
crystal: '>= 1.13.0'
|
||||
|
||||
license: MIT
|
2
spec/spec_helper.cr
Normal file
2
spec/spec_helper.cr
Normal file
|
@ -0,0 +1,2 @@
|
|||
require "spec"
|
||||
require "../src/twitch-irc-crystal"
|
9
spec/twitch-irc-crystal_spec.cr
Normal file
9
spec/twitch-irc-crystal_spec.cr
Normal file
|
@ -0,0 +1,9 @@
|
|||
require "./spec_helper"
|
||||
|
||||
describe Twitch::Irc::Crystal do
|
||||
# TODO: Write tests
|
||||
|
||||
it "works" do
|
||||
false.should eq(true)
|
||||
end
|
||||
end
|
38
src/twitch-irc-crystal.cr
Normal file
38
src/twitch-irc-crystal.cr
Normal file
|
@ -0,0 +1,38 @@
|
|||
require "socket"
|
||||
|
||||
module TwitchIRC
|
||||
struct Client
|
||||
@ip_addr : String
|
||||
@port : String
|
||||
@ssl : Bool | Nil
|
||||
@client : TCPSocket
|
||||
def initialize(@ip_addr, @port, @ssl)
|
||||
@client = TCPSocket.new(@ip_addr, @port)
|
||||
end
|
||||
|
||||
def listen
|
||||
spawn do
|
||||
loop do
|
||||
puts @client.gets
|
||||
end
|
||||
end
|
||||
sleep
|
||||
end
|
||||
|
||||
def send_raw(msg : String)
|
||||
@client << "#{msg}"
|
||||
end
|
||||
|
||||
def send(msg : String)
|
||||
@client << "#{msg}\n"
|
||||
end
|
||||
|
||||
def send_privmsg(msg : String, channel : String)
|
||||
@client << "PRIVMSG ##{channel} :#{msg}\n"
|
||||
end
|
||||
|
||||
def capabilities
|
||||
self.send("CAP REQ :twitch.tv/membership twitch.tv/tags twitch.tv/commands")
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue