hyeonbot 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/exe/hyeonbot +125 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3169df4ab87da5b9216103552e6c7476177ed79a67695ef9d986884ba8e52e4c
|
4
|
+
data.tar.gz: 1cc12d3f57952f4dc2d9f9e57da19493ddba0c34965d446383315020e5aae712
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 304257a96c94f0e9e55591a59e9f5460f1cbf0806d3599692ddfe4d91b02c77fc6130f42f477c0e45b1591ccfacaa048089bf5e2e21c42086db79fd2db44a540
|
7
|
+
data.tar.gz: 56c6d5039c851fbc127a6ad179227e33c8d87c61b44422d1b8e04c3b094f372954e5f08d842c81e6d90bfd12a3f26a1c8ddbd575a153fd5939f1cdcf74199e87
|
data/exe/hyeonbot
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Copyright 2015-2019 Hyeon Kim
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
8
|
+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
9
|
+
# option. This file may not be copied, modified, or distributed
|
10
|
+
# except according to those terms.
|
11
|
+
|
12
|
+
require 'sqlite3'
|
13
|
+
require 'cinch'
|
14
|
+
require 'daumdic'
|
15
|
+
|
16
|
+
# Handle ^C gracefully
|
17
|
+
trap 'SIGINT' do
|
18
|
+
print "\n\nBye!\n\n"
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
22
|
+
# Load configs from environment variables
|
23
|
+
CFG_SERVER = ENV['HYEONBOT_SERVER'] || 'irc.ozinger.org'
|
24
|
+
CFG_PORT = ENV['HYEONBOT_PORT']&.to_i || 6697
|
25
|
+
CFG_LOG_LEVEL = ENV['HYEONBOT_LOG_LEVEL']&.to_sym || :debug
|
26
|
+
|
27
|
+
# Connect to DB
|
28
|
+
db = SQLite3::Database.new 'db'
|
29
|
+
db.execute <<-'SQL'
|
30
|
+
CREATE TABLE IF NOT EXISTS channels (
|
31
|
+
name TEXT PRIMARY KEY
|
32
|
+
);
|
33
|
+
SQL
|
34
|
+
|
35
|
+
#
|
36
|
+
# IRC bot definition
|
37
|
+
#
|
38
|
+
bot = Cinch::Bot.new do |b|
|
39
|
+
configure do |c|
|
40
|
+
c.nick = '김젼봇'
|
41
|
+
c.realname = 'IRC bot. See https://github.com/simnalamburt/hyeonbot for the reference.'
|
42
|
+
c.user = 'hyeonbot'
|
43
|
+
|
44
|
+
c.server = CFG_SERVER
|
45
|
+
c.port = CFG_PORT
|
46
|
+
c.ssl.use = true
|
47
|
+
c.max_reconnect_delay = 60
|
48
|
+
|
49
|
+
c.channels = db.execute('SELECT * FROM channels').flatten
|
50
|
+
end
|
51
|
+
|
52
|
+
# Daum dictionary
|
53
|
+
on :message, /^[dD](?:ic)? (.+)$/ do |m, query|
|
54
|
+
result = Daumdic.one_liner(query.strip.downcase)
|
55
|
+
result = 'ㅇㅅㅇ)a' if result.nil?
|
56
|
+
|
57
|
+
m.reply result
|
58
|
+
end
|
59
|
+
|
60
|
+
# Health check
|
61
|
+
on :message, 'ㅇㅅㅇ)b' do |m|
|
62
|
+
m.reply 'd(ㅇㅅㅇ'
|
63
|
+
end
|
64
|
+
on :message, '>ㅅㅇ' do |m|
|
65
|
+
m.reply 'ㅇㅅ<'
|
66
|
+
end
|
67
|
+
|
68
|
+
# 올바른 언어생활
|
69
|
+
on :message, /우리나라/ do |m|
|
70
|
+
m.reply '우리나라 → 한국'
|
71
|
+
end
|
72
|
+
on :message, /한글화/ do |m|
|
73
|
+
m.reply '한글화 → 한국어 번역 ' + Cinch::Formatting.format(:grey, 'https://t.co/ztyockmyrj')
|
74
|
+
end
|
75
|
+
on :message, /쉐이더/ do |m|
|
76
|
+
m.reply '쉐이더 → 셰이더 ' + Cinch::Formatting.format(:grey, '쉘 → 셸, 쉐어 → 셰어 https://korean.go.kr/front/onlineQna/onlineQnaView.do?qna_seq=120529')
|
77
|
+
end
|
78
|
+
on :message, /쉐이크/ do |m|
|
79
|
+
m.reply '쉐이크 → 셰이크 ' + Cinch::Formatting.format(:grey, '쉘 → 셸, 쉐어 → 셰어 https://korean.go.kr/front/onlineQna/onlineQnaView.do?qna_seq=120529')
|
80
|
+
end
|
81
|
+
on :message, /쉘/ do |m|
|
82
|
+
m.reply '쉘 → 셸 ' + Cinch::Formatting.format(:grey, '쉐이크 → 셰이크, 쉐어 → 셰어 https://korean.go.kr/front/onlineQna/onlineQnaView.do?qna_seq=120529')
|
83
|
+
end
|
84
|
+
on :message, /쉐어/ do |m|
|
85
|
+
m.reply '쉐어 → 셰어 ' + Cinch::Formatting.format(:grey, '쉐이크 → 셰이크, 쉘 → 셸 https://korean.go.kr/front/onlineQna/onlineQnaView.do?qna_seq=120529')
|
86
|
+
end
|
87
|
+
on :message, /됬/ do |m|
|
88
|
+
m.reply '됬 → 됐 ' + Cinch::Formatting.format(:grey, 'https://korean.go.kr/front/onlineQna/onlineQnaView.do?qna_seq=151151')
|
89
|
+
end
|
90
|
+
on :message, /메세지/ do |m|
|
91
|
+
m.reply '메세지 → 메시지 ' + Cinch::Formatting.format(:grey, 'https://korean.go.kr/front/mcfaq/mcfaqView.do?mcfaq_seq=5548')
|
92
|
+
end
|
93
|
+
|
94
|
+
# React on invitation
|
95
|
+
on :invite do |m|
|
96
|
+
# Join the channel
|
97
|
+
b.join m.channel
|
98
|
+
|
99
|
+
# Update DB
|
100
|
+
begin
|
101
|
+
db.execute('INSERT INTO channels VALUES (?)', m.target.name)
|
102
|
+
b.loggers.info "Hyeonbot has been invited to #{m.target.name}"
|
103
|
+
rescue SQLite3::ConstraintException
|
104
|
+
b.loggers.warn 'Hyeonbot has been invited to the already joined channel.'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
on :kick do |m|
|
109
|
+
# Check if kicked user was hyeonbot or someone else
|
110
|
+
if m.params[1] != m.bot.nick
|
111
|
+
return
|
112
|
+
end
|
113
|
+
|
114
|
+
# Hyeonbot has been kicked, update DB
|
115
|
+
db.execute('DELETE FROM channels WHERE name = ?', m.target.name)
|
116
|
+
b.loggers.info "Hyeonbot has been kicked from #{m.target.name}"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
bot.loggers.level = CFG_LOG_LEVEL
|
121
|
+
|
122
|
+
#
|
123
|
+
# Connect to the network
|
124
|
+
#
|
125
|
+
bot.start
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hyeonbot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hyeon Kim
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-06-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cinch
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: daumdic
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.4'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.4'
|
55
|
+
description: |
|
56
|
+
Personal IRC bot of Hyeon Kim.
|
57
|
+
Daum Dictionary API written in ruby.
|
58
|
+
email: simnalamburt@gmail.com
|
59
|
+
executables:
|
60
|
+
- hyeonbot
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- exe/hyeonbot
|
65
|
+
homepage: https://github.com/simnalamburt/hyeonbot
|
66
|
+
licenses:
|
67
|
+
- Apache-2.0
|
68
|
+
- MIT
|
69
|
+
metadata:
|
70
|
+
bug_tracker_uri: https://github.com/simnalamburt/hyeonbot/issues
|
71
|
+
source_code_uri: https://github.com/simnalamburt/hyeonbot
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubygems_version: 3.0.3
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Personal IRC bot of Hyeon Kim
|
91
|
+
test_files: []
|