diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d344ba6b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config.json diff --git a/Gemfile b/Gemfile index 6510d618..1f6c7dae 100644 --- a/Gemfile +++ b/Gemfile @@ -15,6 +15,6 @@ gem 'prime' gem 'pastebinrb' gem 'ascii-image' gem 'rmagick' -#gem 'mongo' #lol this one is actually really fucking important js +gem 'mongo' #lol this one is actually really fucking important js gem 'extralite' #sqlitle never wants to instawall diff --git a/Gemfile.lock b/Gemfile.lock index c76c4078..75018c4c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,9 +5,13 @@ GEM ascii-image (0.1.5) rainbow (~> 3.0, >= 3.0.0) rmagick (~> 2.16, >= 2.16.0) + bson (4.12.1) cinch (2.3.4) + extralite (1.2) fmylife (0.6.0) forwardable (1.3.2) + mongo (2.15.0) + bson (>= 4.8.2, < 5.0.0) nokogiri (1.11.6-x86_64-linux) racc (~> 1.4) open-uri (0.1.0) @@ -29,7 +33,9 @@ DEPENDENCIES ansirc ascii-image cinch + extralite fmylife + mongo nokogiri open-uri pastebin @@ -39,4 +45,4 @@ DEPENDENCIES shellwords BUNDLED WITH - 2.2.21 + 2.2.25 diff --git a/classes/Util.rb b/classes/Util.rb index 8dd4f142..b073e43e 100644 --- a/classes/Util.rb +++ b/classes/Util.rb @@ -1,7 +1,8 @@ - +#!/usr/bin/env ruby require 'pathname' require 'cinch' +require "json" require 'pastebinrb' require_relative "Hooks.rb" require_relative "Meta.rb" @@ -76,12 +77,18 @@ module Util #utilities and such def initialize @@excuses = []; @@success = []; - @@url = "127.0.0.1:27017" + config = JSON.parse( + File.open("config.json","r") { |f| f.read() } + ) + mUsr = config['username'] + mPass = config['password'] + @@url = "mongodb://#{mUsr}:#{mPass}@127.0.0.1:27017 + " @@mongos = {}; - @@mongos[:chans] = Mongo::Client.new([@@url], :database => "chans") - @@mongos[:extendobot] = Mongo::Client.new([@@url], :database => "extendobot") - @@mongos[:acl] = Mongo::Client.new([@@url], :database => "acl") - @@mongos[:markov] = Mongo::Client.new([@@url], :database => "markov") + @@mongos[:chans] = Mongo::Client.new(@@url, :database => "chans") + @@mongos[:extendobot] = Mongo::Client.new(@@url, :database => "extendobot") + @@mongos[:acl] = Mongo::Client.new(@@url, :database => "acl") + @@mongos[:markov] = Mongo::Client.new(@@url, :database => "markov") end def getDB(dbn) db = @@mongos[dbn.to_sym] @@ -91,7 +98,7 @@ module Util #utilities and such return db else #puts "initializing connection to #{dbn}" - p @@mongos[dbn.to_sym] = Mongo::Client.new([@@url], :database => dbn) + p @@mongos[dbn.to_sym] = Mongo::Client.new(@@url, :database => dbn) return @@mongos[dbn.to_sym] end end @@ -213,11 +220,10 @@ module Util #utilities and such c.server_queue_size = 512 c.messages_per_second = 64 puts "gotta find thgat nick for #{name} in da game mayne" - q = conf.find({ 'key' => 'nick', 'server' => name })#.to_a[0]["val"] - puts "here is a thing: #{q.inspect}" - exit + nickname = conf.find({ 'key' => 'nick', 'server' => name }).to_a[0]["val"] + puts "here is a thing: #{nickname}" c.user = "botholejones" - c.nick + c.nick = nickname c.realname = "O Shid It Dat Bot!" passwd = nil pass = conf.find({ 'key' => 'pass', 'server' => name }) diff --git a/plugins/Markovian.rb b/plugins/Markovian.rb index 4026979a..4f44edcd 100644 --- a/plugins/Markovian.rb +++ b/plugins/Markovian.rb @@ -72,7 +72,7 @@ class Markovian end def markov(m,length=nil,seed=nil) - out = start(m,seed,length == nil ? length : length.to_i) + out = start(m,seed,length == nil ? length : length.to_i) puts "markov out:\n\t#{out}" m.reply(out) @@ -118,13 +118,13 @@ class Markovian return ret end - def start(m, seed=nil, words=nil) + def start(m, seed=nil, words=nil) db = Util::Util.instance.getCollection("markov","ngrams") res = "" if(words == nil) words = (4+rand(24).to_i) end - words = words > 1024 ? 1024 : words + words = words > 256 ? 256 : words #puts "begin markov chainsaw" #puts "start.count: #{words}, start.seed: #{seed}" if seed != nil