spacevim/bundle/vim-chat/autoload/chat/irc.vim
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

85 lines
2.3 KiB
VimL

"=============================================================================
" irc.vim --- irc protocol for vim-chat
" Copyright (c) 2016-2023 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
let g:chat_irc_server_address = 'irc.libera.chat'
let g:char_irc_server_port = '6667'
let s:server_lib = g:_spacevim_root_dir . 'bundle/Chatting-server/target'
let s:LOG = SpaceVim#logger#derive('irc')
let s:JOB = SpaceVim#api#import('job')
function! chat#irc#send(room, msg) abort
call chat#irc#send_raw(printf('PRIVMSG %s %s', a:room, a:msg))
call chat#windows#push({
\ 'user' : 'wsdjeg2',
\ 'username' : 'wsdjeg2',
\ 'room' : a:room,
\ 'msg' : a:msg,
\ 'time': strftime("%Y-%m-%d %H:%M"),
\ })
endfunction
function! chat#irc#enter_room(room) abort
call chat#irc#send_raw('JOIN ' . a:room)
return 1
endfunction
let s:irc_channel_id = 0
function! chat#irc#send_raw(msg) abort
call s:JOB.send(s:irc_channel_id, a:msg)
endfunction
function! chat#irc#get_channels() abort
if s:irc_channel_id <= 0
let s:irc_channel_id = s:JOB.start(['java', '-cp', s:server_lib, 'com.wsdjeg.chat.Client', g:chat_irc_server_address, g:char_irc_server_port],{
\ 'on_stdout' : function('s:on_data'),
\ 'on_exit' : function('s:on_exit'),
\ })
call chat#irc#send_raw('NICK wsdjeg2')
call chat#irc#send_raw('USER wsdjeg2 - - wsdjeg2')
endif
return []
endfunction
function! s:on_data(id, data, name) abort
for line in a:data
let line = substitute(line, '\r', '', 'g')
call s:LOG.debug(line)
if line =~# 'PRIVMSG'
let user = matchstr(line, '^:\zs[^!]*')
let room = matchstr(line, 'PRIVMSG\s\zs#\S*')
let msg = matchstr(line, 'PRIVMSG\s#\S*\s:\zs.*')
call chat#windows#push({
\ 'user' : user,
\ 'username' : user,
\ 'room' : room,
\ 'msg' : msg,
\ 'time': strftime("%Y-%m-%d %H:%M"),
\ })
endif
endfor
endfunction
function! s:on_exit(...) abort
let s:irc_channel_id = 0
endfunction
function! s:on_vim_data(channel, data) abort
call s:LOG.debug(a:data)
endfunction
function! chat#irc#get_user_count(room) abort
return ''
endfunction