BO5VKP6Z3GNEZN2RKCS4MSUYM77L3KSOJAFGZO4GPDPSZAHQ7PSQC
BIWQWRTPVNCRRDNYWFTDP3TGL2ER6U3ESUYPRUADATHZ4N2F5YJQC
ZX5GI7ZM5WMGMNWNBYTJNE3T3OSIKASM53PHBPVB73IWGWUBEM5QC
64UUKXJNHHGNYPQLYPAT74RGYBZNPOHSV7LCWM64K2DJFT5BU6RAC
S4P2B3FPF57HPHTIAYGMPCVKB7573IB5ZBKNXVBTB6ICCPF55WNQC
LNGUDOUQK35O5IIUHSVJ5LW54JA7QNMNCJGQNYWPRDUSK6R4XCLQC
TKEQSYZ7PZ4GBD6R4EOOE26TQ6VKXBXLYRLUUYWOOQ7SVXQSVETQC
BEWT3YUFWOAKQVEO4ZERUTFISI26ULUCNKICDZFYZ4OM3DRLCKWQC
PPHB36IL7PBXYAGHV6QEFNCKUXEJSSR6264PACKRP7OT2SWNUV6AC
DJJIZVCNVIH2HTR6K7YBEZTFMTMMW55GP37G4RAZO6G3UUXU52PAC
2WSNTTC436QG4CGXVRKK7QWMEBUUUCLZBRZGPI5PK3PADRVZPZPQC
3ZE4YIXX3UAKYLD2EJSIX2DPHFUOF3TOUKBPHG4UKX4UOP7DPSEQC
SIC4BVK6MY6CC4NSS6NQDFG7SM7I7LLIRSEGOHESIM2UEDILGVSQC
ZIDFZNTT4HZDKKWK25U7OPIFSVTSNTZVEKWCBQ6XEPR3HHSNL2AAC
STCA6ICCSBIEFHLRULQWP4AKN554ZECHVLZPXLABJIOR6YUTFW5AC
TFCCKVFDPARIKHK3RKVLWUPT6M4P3FXD6NMC42U47PKHG2BSEDGQC
M5GXUK5HZE7HPLWQ33T73CXRJITOUJAO6T6F6QWTYYL7NLWFYA3AC
PFE537UQPEHTZAMPKTXNTJF6Z56PA2LQNAQHEOVTD2ZQRTFUTJKAC
pub fn (mut self IrcActor) add_server(addr string) {
mut names := []string{}
names.push(addr)
self.networks.push(Network{
hostnames: names
state: ConnState.disconnected
})
println('irc network added host $addr')
pub fn (mut self IrcActor) find_server(addr string) ?&Network {
for net in self.networks {
if net.name == addr || net.hostnames[0] == addr {
return &net
}
}
return error('server not found')
}
pub fn (mut self IrcActor) add_server(ircnet Network) {
self.networks.push(ircnet)
println('irc added network $ircnet.one_line()')
pub fn (self &IrcActor) connect(host string) {
for mut ircnet in self.networks {
addr := ircnet.hostnames[0]
if addr == host {
self.dial(mut ircnet)
}
}
}
pub fn (mut self Db) add_irc_server(hostname string) {
rows, code := self.sqlite.exec('insert into irc_servers (hostname, netname) values ("$hostname", "$hostname")')
pub fn (mut self Db) add_irc_server(parts []string) {
rows, code := self.sqlite.exec('insert into irc_servers (hostname, netname) values ("$parts[1]", "$parts[2]")')
self.db.add_irc_server(host)
self.irc.add_server(host)
go self.irc.connect(host)
mut ircnet := self.irc.find_server(host) or {
self.say_chan <- matrix.Say{
room: room_id
message: "cant find ${host}. add with '!server add <hostname>'"
}
return
}
go self.irc.dial(mut ircnet)
self.db.add_irc_server(host)
self.irc.add_server(host)
mut ircrow := []string{}
ircrow.push('') // id
ircrow.push(host)
ircrow.push('') // netname
mut ircnet := irc.network_from_db(ircrow)
self.irc.networks.push(ircnet)
self.db.add_irc_server(ircrow)
self.irc.add_server(ircnet)