Cinch-Automode 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -4
- data/lib/cinch/plugins/automode.rb +1 -45
- data/lib/cinch/plugins/automode/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9588bdebb5443e4bc0b9796dbc1d32cb97734d6
|
4
|
+
data.tar.gz: 91870a6dcd5f00876419107e7b925b038c8146f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c9e3d9253de49191021e503cc16039fc733fb69c7fa184916ecbe059a88b296951d51f59114d2d1690f4f5ff71c8e281577f756fcc70fe296c4bd5c10d84a0b
|
7
|
+
data.tar.gz: 71da032a6d50f76c38ea2641b296320f5693c524d1afbec4bcabe840480de65525b2603d01bedeeff41bb439115e93ade89a510e86bc80a1fa4273085f4eece2
|
data/README.md
CHANGED
@@ -6,10 +6,8 @@ entire channel
|
|
6
6
|
Usage
|
7
7
|
-----
|
8
8
|
|
9
|
-
|
10
|
-
it
|
11
|
-
`plugins` then require it via `require_relative`.
|
12
|
-
Add it to your bot like so:
|
9
|
+
install the gem with *gem install Cinch-Automode*, and
|
10
|
+
add it to your bot like so:
|
13
11
|
|
14
12
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ruby
|
15
13
|
require 'cinch'
|
@@ -44,16 +44,8 @@ module Cinch
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
# making shit stand out in the console for debug
|
48
|
-
def header(title)
|
49
|
-
puts '=' * 5 + " #{title} " + '=' * 5
|
50
|
-
end
|
51
|
-
|
52
47
|
# reading and writing database methods
|
53
48
|
def read_db(nick, hostmask, channel)
|
54
|
-
# header 'reading?'
|
55
|
-
# puts "db class: #{@db.class}"
|
56
|
-
# puts "db tables: #{@db.tables}"
|
57
49
|
return 'no' unless @db.table_exists?(:users)
|
58
50
|
|
59
51
|
users = @db[:users] # Users table
|
@@ -65,12 +57,6 @@ module Cinch
|
|
65
57
|
return chans.where(chan: channel).first[:mode]
|
66
58
|
end
|
67
59
|
|
68
|
-
# header 'database'
|
69
|
-
# puts users.all
|
70
|
-
# puts hosts.all
|
71
|
-
# puts userchans.all
|
72
|
-
# header 'end database'
|
73
|
-
|
74
60
|
return 'no' if users.where(nick: nick).first.nil?
|
75
61
|
return 'admin' if users.where(nick: nick).first[:mode] == 'admin'
|
76
62
|
|
@@ -78,32 +64,16 @@ module Cinch
|
|
78
64
|
has_hostmasks = hosts.where(user_id: user_id).map(:mask)
|
79
65
|
has_channels = userchans.where(user_id: user_id).map(:chan)
|
80
66
|
|
81
|
-
# puts "hostmask: #{hostmask}"
|
82
|
-
# puts "hostmasks: #{has_hostmasks}"
|
83
|
-
# puts "channels: #{has_channels}"
|
84
|
-
# puts "has? #{has_hostmasks.include?(hostmask)}"
|
85
|
-
# puts "mode: #{users.where(nick: nick).first[:mode]}"
|
86
|
-
|
87
67
|
return 'no' unless has_hostmasks.include?(hostmask)
|
88
68
|
return 'no' unless has_channels.include?(channel)
|
89
69
|
users.where(nick: nick).first[:mode]
|
90
70
|
end
|
91
71
|
|
92
72
|
def write_db(nick, hostmask, mode, in_chan)
|
93
|
-
# header 'writing?'
|
94
|
-
# puts "db class: #{@db.class}"
|
95
|
-
# puts "db tables: #{@db.tables}"
|
96
|
-
|
97
73
|
users = @db[:users]
|
98
74
|
hosts = @db[:hostmasks]
|
99
75
|
chans = @db[:userchans]
|
100
76
|
|
101
|
-
# header 'database'
|
102
|
-
# puts users.all
|
103
|
-
# puts hosts.all
|
104
|
-
# puts chans.all
|
105
|
-
# header 'end database'
|
106
|
-
|
107
77
|
# If user isn't in db, add user to db
|
108
78
|
if users.where(nick: nick).first.nil?
|
109
79
|
users.insert(nick: nick, mode: mode)
|
@@ -125,15 +95,6 @@ module Cinch
|
|
125
95
|
output = "User #{users.where(nick: nick).first[:nick]} added "
|
126
96
|
output << "hostmask #{hosts.where(user_id: user_id).all[-1][:mask]} "
|
127
97
|
output << "with mode #{users.where(nick: nick).first[:mode]}"
|
128
|
-
# header 'stuff'
|
129
|
-
# puts "output: #{output}"
|
130
|
-
# puts "user_id: #{user_id}"
|
131
|
-
|
132
|
-
# header 'database'
|
133
|
-
# puts users.all
|
134
|
-
# puts hosts.all
|
135
|
-
# puts chans.all
|
136
|
-
# header 'end database'
|
137
98
|
|
138
99
|
output
|
139
100
|
end
|
@@ -147,7 +108,7 @@ module Cinch
|
|
147
108
|
end
|
148
109
|
output = "#{chans.where(chan: chan).first[:chan]} "
|
149
110
|
output << "added with mode #{chans.where(chan: chan).first[:mode]}"
|
150
|
-
|
111
|
+
|
151
112
|
output
|
152
113
|
end
|
153
114
|
|
@@ -166,7 +127,6 @@ module Cinch
|
|
166
127
|
@automode[m.channel] ||= true
|
167
128
|
return unless @automode[m.channel]
|
168
129
|
return if m.user.nick == bot.nick
|
169
|
-
# header 'listen?'
|
170
130
|
hostmask = m.raw.split(' ')[0].delete(':').split('!')[1]
|
171
131
|
mode = read_db(m.user.nick, hostmask, m.channel.to_s)
|
172
132
|
case mode
|
@@ -247,10 +207,6 @@ module Cinch
|
|
247
207
|
m.reply('Baleeted!')
|
248
208
|
end
|
249
209
|
end
|
250
|
-
# header 'database'
|
251
|
-
# puts users.all
|
252
|
-
# puts hosts.all
|
253
|
-
# header 'end database'
|
254
210
|
end
|
255
211
|
end
|
256
212
|
end
|