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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 831e6ea6d01c75667b4ac3838c4b0d2b98314c7a
4
- data.tar.gz: a9ca84fa21ce3a18358d0db99194f521d43bf610
3
+ metadata.gz: d9588bdebb5443e4bc0b9796dbc1d32cb97734d6
4
+ data.tar.gz: 91870a6dcd5f00876419107e7b925b038c8146f2
5
5
  SHA512:
6
- metadata.gz: 6706cfa4655d43d45cc3212bd154b9d91f5a8be6744e2ccdc32e6efb3ff99927cbcfc5130f2d24e3b8efd047cb8955462f0d797217594a0e9d507a64fa145c48
7
- data.tar.gz: 1f9aeb68c3e70283c4671fafa28a51c991dd4ec431dc30d1ed74d7351bdbb5b87e18dff70fb3161dd8075cd0fde6b9c683b01859accf0624871396817a270ba5
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
- Until I figure out how to make it into a gem, download the .rb file, and place
10
- it in a subdirectory of your bot entitled
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
- # puts output
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
@@ -1,5 +1,5 @@
1
1
  module Cinch
2
2
  module Automode
3
- VERSION = '0.0.1'.freeze
3
+ VERSION = '0.0.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Cinch-Automode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lily Jónsdóttir