added config.json for mongo auth config

This commit is contained in:
oz 2021-08-03 01:03:43 +03:00
parent bfab09ef2d
commit 59350c339f
5 changed files with 29 additions and 16 deletions

1
.gitignore vendored Normal file

@ -0,0 +1 @@
config.json

@ -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

@ -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

@ -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 })

@ -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