ZBABUXXS5JKOQ2DCLPSNQV5G5ZHBS6NR4QOFYYJMLVVHUP7POMZAC
parts << &db.SqlValue{name: "left", value: db.SqlType(self.left)}
parts << &db.SqlValue{name: "right", value: db.SqlType(self.right)}
parts << &db.SqlValue{
name: 'left'
value: db.SqlType(self.left)
}
parts << &db.SqlValue{
name: 'right'
value: db.SqlType(self.right)
}
}
pub fn matching_room(lr string, mut db db.Db) ?string {
lefts := db.select_by_field('bridges', 'left', lr)
rights := db.select_by_field('bridges', 'right', lr)
if lefts.len > 0 {
println('bridge.matching room found left $lr -> right ${lefts[0][1]}')
return lefts[0][1] // pick right
} else if rights.len > 0 {
println('bridge.matching room found right $lr -> left ${rights[0][0]}')
return rights[0][0] // pick left
}
return error('no bridge found for $lr')
}
pub fn from_db(rows []string) &Bridge {
return &Bridge{
left: rows[0]
right: rows[1]
}
nick := self.name_convert(chat.System.matrix, whoami)
if channel := self.matching_irc_channel(nick, room) {
msg = msg + 'Bridging room $room to $channel as $whoami'
} else {
msg = msg + '(no matching irc channel found for $room)'
// nick := self.name_convert(chat.System.matrix, whoami)
// if channel := self.matching_irc_channel(nick, room) {
if room.name is string {
if channel := bridge.matching_room(room.name, mut self.db) {
msg = msg + 'Bridging room $room to $channel as $whoami'
} else {
msg = msg + 'irc joined $room: no matrix room set for bridge. use !bridge'
}
self.admin_say(msg)
self.process_out_user(whoami)