This commit is contained in:
garigariganzy
2022-10-04 01:16:34 +09:00
parent 9c97c24698
commit 4bb2cf1a89
4 changed files with 18 additions and 22 deletions

2
rules

Submodule rules updated: 28c1de3279...aaf910cdca

View File

@@ -555,7 +555,7 @@ impl EventInfo {
}
#[derive(Debug, Clone)]
pub struct EventInfoConfig {
eventinfo: HashMap<String, EventInfo>,
eventinfo: HashMap<(String, String), EventInfo>,
}
impl Default for EventInfoConfig {
@@ -570,8 +570,9 @@ impl EventInfoConfig {
eventinfo: HashMap::new(),
}
}
pub fn get_event_id(&self, eventid: &str) -> Option<&EventInfo> {
self.eventinfo.get(eventid)
pub fn get_event_id(&self, channel: &str, eventid: &str) -> Option<&EventInfo> {
self.eventinfo
.get(&(channel.to_string(), eventid.to_string()))
}
}
@@ -586,19 +587,21 @@ fn load_eventcode_info(path: &str) -> EventInfoConfig {
// event_id_info.txtが読み込めなかったらエラーで終了とする。
read_result.unwrap().into_iter().for_each(|line| {
if line.len() != 2 {
if line.len() != 3 {
return;
}
let empty = &"".to_string();
let eventcode = line.get(0).unwrap_or(empty);
let event_title = line.get(1).unwrap_or(empty);
let channel = line.get(0).unwrap_or(empty);
let eventcode = line.get(1).unwrap_or(empty);
let event_title = line.get(2).unwrap_or(empty);
infodata = EventInfo {
evttitle: event_title.to_string(),
};
config
.eventinfo
.insert(eventcode.to_owned(), infodata.to_owned());
config.eventinfo.insert(
(channel.to_owned(), eventcode.to_owned()),
infodata.to_owned(),
);
});
config
}

View File

@@ -6,8 +6,5 @@ pub mod omikuji;
pub mod options;
pub mod timeline;
pub mod yaml;
<<<<<<< HEAD
=======
#[macro_use]
extern crate horrorshow;
>>>>>>> d91fd31392813c79a33cf5dc10eae06db2ce2613

View File

@@ -139,23 +139,19 @@ impl Timeline {
// 件数の割合を算出
let rate: f32 = **event_cnt as f32 / self.stats.total as f32;
// channelとIDを分割
let ch_id = event_id.split(',').fold(Vec::new(), |mut s, i| {
s.push(i.to_string());
s
});
println!("{:?}", ch_id);
let fmted_channel = channel.replace('\"', "");
println!("{:?}", fmted_channel);
println!("{:?}", event_id);
// イベント情報取得(eventtitleなど)
let conf = CONFIG
.read()
.unwrap()
.event_timeline_config
.get_event_id(event_id)
.get_event_id(&fmted_channel, event_id)
.is_some();
// event_id_info.txtに登録あるものは情報設定
// 出力メッセージ1行作成
let fmted_channel = channel.replace('\"', "");
let ch = CH_CONFIG
.get(fmted_channel.to_lowercase().as_str())
.unwrap_or(&fmted_channel)
@@ -170,7 +166,7 @@ impl Timeline {
.read()
.unwrap()
.event_timeline_config
.get_event_id(event_id)
.get_event_id(&fmted_channel, event_id)
.unwrap()
.evttitle
.to_string(),