colorful nicks

This commit is contained in:
Alexander Yakovlev 2017-10-19 16:26:54 +07:00
parent 263ccf5099
commit f30502abc0

View file

@ -5,6 +5,7 @@ require 'uri'
require 'json'
require 'formdata'
require 'nokogiri'
require 'digest'
require_relative 'plugins/link_info'
require_relative 'plugins/help'
@ -40,15 +41,15 @@ class QuestBook
begin
if response['msgs'] then
for msg in response['msgs'] do
who = '[Система]'
print = false
if msg[1] != '' then
who = "[#{msg[1]}]"
print = true
end
msg = msg[2]
a = Nokogiri::HTML.parse msg
msg = a.text
msg = a.text
color = Digest::MD5.hexdigest(msg[1]).to_i(16) % 14 + 2
who = "[\x03#{color}#{msg[1]}\x0f]"
if msg[2] != @last and print then
Channel('#questbook').send("#{who}: #{msg}")
@last = msg[2]