readme.md
12.3 KB
전략적 팀 전투 정보제공 챗봇
리그 오브 레전드의 전략적 팀 전투 모드의 플레이 데이터를 분석하고 유행하는 전략, 아이템 등을 추천해주는 챗봇 서비스입니다.
LINE 메신저 봇 ID(@149wlczg)를 통해서 사용해 볼 수 있고 아래의 QR 코드를 통해서도 이용 가능합니다.
공통 요구사항
Database 초기화
다음 SQL문을 실행해 데이터베이스의 테이블을 초기화해줍니다.
CREATE TABLE `character_aliases` (
`alias` varchar(32) NOT NULL,
`character_id` varchar(32) DEFAULT NULL,
`is_name` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`alias`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `character_aliases` VALUES ('가렌','TFT4_Garen',1),('나미','TFT4_Nami',1),('누누','TFT4_Nunu',0),('누누와 윌럼프','TFT4_Nunu',1),('누누와윌럼프','TFT4_Nunu',0),('니달리','TFT4_Nidalee',1),('다이애나','TFT4_Diana',1),('럭스','TFT4_Lux',1),('룰루','TFT4_Lulu',1),('리 신','TFT4_LeeSin',1),('리븐','TFT4_Riven',1),('리산드라','TFT4_Lissandra',1),('리신','TFT4_LeeSin',0),('릴리아','TFT4_Lillia',1),('마오카이','TFT4_Maokai',1),('모르가나','TFT4_Morgana',1),('바이','TFT4_Vi',1),('베이가','TFT4_Veigar',1),('베인','TFT4_Vayne',1),('사일러스','TFT4_Sylas',1),('세주아니','TFT4_Sejuani',1),('세트','TFT4_Sett',1),('쉔','TFT4_Shen',1),('신짜오','TFT4_XinZhao',1),('쓰레쉬','TFT4_Thresh',1),('아리','TFT4_Ahri',1),('아지르','TFT4_Azir',1),('아칼리','TFT4_Akali',1),('아트록스','TFT4_Aatrox',1),('아펠리오스','TFT4_Aphelios',1),('애니','TFT4_Annie',1),('애쉬','TFT4_Ashe',1),('야스오','TFT4_Yasuo',1),('엘리스','TFT4_Elise',1),('오공','TFT4_Wukong',1),('요네','TFT4_Yone',1),('워윅','TFT4_Warwick',1),('유미','TFT4_Yuumi',1),('이렐리아','TFT4_Irelia',1),('이블린','TFT4_Evelynn',1),('이즈리얼','TFT4_Ezreal',1),('자르반','TFT4_JarvanIV',0),('자르반 4세','TFT4_JarvanIV',1),('자르반4세','TFT4_JarvanIV',0),('잔나','TFT4_Janna',1),('잭스','TFT4_Jax',1),('제드','TFT4_Zed',1),('진','TFT4_Jhin',1),('질리언','TFT4_Zilean',1),('징크스','TFT4_Jinx',1),('카시오페아','TFT4_Cassiopeia',1),('카타리나','TFT4_Katarina',1),('칼리스타','TFT4_Kalista',1),('케넨','TFT4_Kennen',1),('케인','TFT4_Kayn',1),('킨드레드','TFT4_Kindred',1),('탈론','TFT4_Talon',1),('탐 켄치','TFT4_TahmKench',1),('탐켄치','TFT4_TahmKench',0),('트위스티드 페이트','TFT4_TwistedFate',1),('트위스티드페이트','TFT4_TwistedFate',0),('트페','TFT4_TwistedFate',0),('티모','TFT4_Teemo',1),('파이크','TFT4_Pyke',1),('피오라','TFT4_Fiora',1),('헤카림','TFT4_Hecarim',1);
CREATE TABLE `character_items` (
`character_id` varchar(32) NOT NULL,
`item` int(11) NOT NULL,
`count` int(11) NOT NULL,
PRIMARY KEY (`character_id`,`item`),
KEY `character_items_count_IDX` (`count`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `character_traits` (
`character_id` varchar(32) NOT NULL,
`trait` varchar(32) NOT NULL,
PRIMARY KEY (`character_id`,`trait`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `character_traits` VALUES ('TFT4_Aatrox','Cultist'),('TFT4_Aatrox','Set4_Vanguard'),('TFT4_Ahri','Set4_Mage'),('TFT4_Ahri','Set4_Spirit'),('TFT4_Akali','Set4_Assassin'),('TFT4_Akali','Set4_Ninja'),('TFT4_Annie','Fortune'),('TFT4_Annie','Set4_Mage'),('TFT4_Aphelios','Hunter'),('TFT4_Aphelios','Moonlight'),('TFT4_Ashe','Hunter'),('TFT4_Ashe','Set4_Elderwood'),('TFT4_Azir','Emperor'),('TFT4_Azir','Keeper'),('TFT4_Azir','Warlord'),('TFT4_Cassiopeia','Dusk'),('TFT4_Cassiopeia','Set4_Mystic'),('TFT4_Diana','Moonlight'),('TFT4_Diana','Set4_Assassin'),('TFT4_Elise','Cultist'),('TFT4_Elise','Keeper'),('TFT4_Evelynn','Cultist'),('TFT4_Evelynn','Set4_Shade'),('TFT4_Ezreal','Set4_Dazzler'),('TFT4_Ezreal','Set4_Elderwood'),('TFT4_Fiora','Duelist'),('TFT4_Fiora','Set4_Enlightened'),('TFT4_Garen','Set4_Vanguard'),('TFT4_Garen','Warlord'),('TFT4_Hecarim','Set4_Elderwood'),('TFT4_Hecarim','Set4_Vanguard'),('TFT4_Irelia','Divine'),('TFT4_Irelia','Set4_Adept'),('TFT4_Irelia','Set4_Enlightened'),('TFT4_Janna','Set4_Enlightened'),('TFT4_Janna','Set4_Mystic'),('TFT4_JarvanIV','Keeper'),('TFT4_JarvanIV','Warlord'),('TFT4_Jax','Divine'),('TFT4_Jax','Duelist'),('TFT4_Jhin','Cultist'),('TFT4_Jhin','Sharpshooter'),('TFT4_Jinx','Fortune'),('TFT4_Jinx','Sharpshooter'),('TFT4_Kalista','Cultist'),('TFT4_Kalista','Duelist'),('TFT4_Katarina','Fortune'),('TFT4_Katarina','Set4_Assassin'),('TFT4_Katarina','Warlord'),('TFT4_Kayn','Set4_Shade'),('TFT4_Kayn','Set4_Tormented'),('TFT4_Kennen','Keeper'),('TFT4_Kennen','Set4_Ninja'),('TFT4_Kindred','Hunter'),('TFT4_Kindred','Set4_Spirit'),('TFT4_LeeSin','Divine'),('TFT4_LeeSin','Duelist'),('TFT4_Lillia','Dusk'),('TFT4_Lillia','Set4_Mage'),('TFT4_Lissandra','Moonlight'),('TFT4_Lissandra','Set4_Dazzler'),('TFT4_Lulu','Set4_Elderwood'),('TFT4_Lulu','Set4_Mage'),('TFT4_Lux','Divine'),('TFT4_Lux','Set4_Dazzler'),('TFT4_Maokai','Set4_Brawler'),('TFT4_Maokai','Set4_Elderwood'),('TFT4_Morgana','Set4_Dazzler'),('TFT4_Morgana','Set4_Enlightened'),('TFT4_Nami','Set4_Enlightened'),('TFT4_Nami','Set4_Mage'),('TFT4_Nidalee','Sharpshooter'),('TFT4_Nidalee','Warlord'),('TFT4_Nunu','Set4_Brawler'),('TFT4_Nunu','Set4_Elderwood'),('TFT4_Pyke','Cultist'),('TFT4_Pyke','Set4_Assassin'),('TFT4_Riven','Dusk'),('TFT4_Riven','Keeper'),('TFT4_Sejuani','Fortune'),('TFT4_Sejuani','Set4_Vanguard'),('TFT4_Sett','Boss'),('TFT4_Sett','Set4_Brawler'),('TFT4_Shen','Set4_Adept'),('TFT4_Shen','Set4_Mystic'),('TFT4_Shen','Set4_Ninja'),('TFT4_Sylas','Moonlight'),('TFT4_Sylas','Set4_Brawler'),('TFT4_TahmKench','Fortune'),('TFT4_TahmKench','Set4_Brawler'),('TFT4_Talon','Set4_Assassin'),('TFT4_Talon','Set4_Enlightened'),('TFT4_Teemo','Set4_Spirit'),('TFT4_Teemo','Sharpshooter'),('TFT4_Thresh','Dusk'),('TFT4_Thresh','Set4_Vanguard'),('TFT4_TwistedFate','Cultist'),('TFT4_TwistedFate','Set4_Mage'),('TFT4_Vayne','Dusk'),('TFT4_Vayne','Sharpshooter'),('TFT4_Veigar','Set4_Elderwood'),('TFT4_Veigar','Set4_Mage'),('TFT4_Vi','Set4_Brawler'),('TFT4_Vi','Warlord'),('TFT4_Warwick','Divine'),('TFT4_Warwick','Hunter'),('TFT4_Warwick','Set4_Brawler'),('TFT4_Wukong','Divine'),('TFT4_Wukong','Set4_Vanguard'),('TFT4_XinZhao','Duelist'),('TFT4_XinZhao','Warlord'),('TFT4_Yasuo','Duelist'),('TFT4_Yasuo','Set4_Exile'),('TFT4_Yone','Set4_Adept'),('TFT4_Yone','Set4_Exile'),('TFT4_Yuumi','Set4_Mystic'),('TFT4_Yuumi','Set4_Spirit'),('TFT4_Zed','Set4_Ninja'),('TFT4_Zed','Set4_Shade'),('TFT4_Zilean','Cultist'),('TFT4_Zilean','Set4_Mystic');
CREATE TABLE `decks` (
`character_1` varchar(32) NOT NULL,
`character_2` varchar(32) NOT NULL,
`character_3` varchar(32) NOT NULL,
`character_4` varchar(32) NOT NULL,
`character_5` varchar(32) NOT NULL,
`character_6` varchar(32) NOT NULL,
`character_7` varchar(32) NOT NULL,
`character_8` varchar(32) NOT NULL,
`chosen` varchar(32) NOT NULL,
`count` int(11) DEFAULT NULL,
PRIMARY KEY (`character_1`,`character_2`,`character_3`,`character_4`,`character_5`,`character_6`,`character_7`,`character_8`,`chosen`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `items` (
`id` int(11) NOT NULL,
`name` varchar(32) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `items` VALUES (1,'B.F.대검'),(2,'곡궁'),(3,'쓸대없이 큰 지팡이'),(4,'여신의 눈물'),(5,'쇠사슬 조끼'),(6,'음전자 망토'),(7,'거인의 허리띠'),(8,'뒤집개'),(9,'연습용 장갑'),(11,'죽음의 검'),(12,'거인 학살자'),(13,'마법공학 총검'),(14,'쇼진의 창'),(15,'수호 천사'),(16,'피바라기'),(17,'지크의 정령'),(18,'신성의 검'),(19,'무한의 대검'),(22,'고속 연사포'),(23,'구인수의 격노검'),(24,'스태틱의 단검'),(25,'거인의 결의'),(26,'루난의 허리케인'),(27,'즈롯 차원문'),(28,'결투가의 열정'),(29,'최후의 속삭임'),(33,'라바돈의 죽음모자'),(34,'루덴의 메아리'),(35,'강철의 솔라리 펜던트'),(36,'이온 충격기'),(37,'모렐로노미콘'),(38,'황혼의 성위'),(39,'보석 건틀릿'),(44,'푸른 파수꾼'),(45,'얼어붙은 심장'),(46,'힘의 성배'),(47,'구원'),(48,'요술사의 모자'),(49,'정의의 손길'),(55,'덤블 조끼'),(56,'가고일 돌갑옷'),(57,'태양불꽃 망토'),(58,'수호자의 흉갑'),(59,'침묵의 장막'),(66,'용의 발톱'),(67,'서풍'),(68,'나무정령 새싹'),(69,'수은'),(77,'워모그의 갑옷'),(78,'대장군의 깃발'),(79,'덫 발톱'),(88,'대자연의 힘'),(89,'요우무의 유령검'),(99,'도적의 장갑');
CREATE TABLE `trait_levels` (
`trait_id` varchar(32) NOT NULL,
`count` int(11) NOT NULL,
`level` int(11) DEFAULT NULL,
PRIMARY KEY (`trait_id`,`count`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `trait_levels` VALUES ('Boss',1,3),('Cultist',3,1),('Cultist',6,3),('Cultist',9,4),('Divine',2,1),('Divine',4,2),('Divine',6,3),('Divine',8,4),('Duelist',2,1),('Duelist',4,2),('Duelist',6,3),('Duelist',8,4),('Dusk',2,1),('Dusk',4,2),('Dusk',6,3),('Emperor',1,3),('Fortune',3,3),('Fortune',6,4),('Hunter',2,1),('Hunter',3,2),('Hunter',4,3),('Hunter',5,4),('Keeper',2,1),('Keeper',4,3),('Keeper',6,4),('Moonlight',3,3),('Moonlight',5,4),('Set4_Adept',2,1),('Set4_Adept',3,3),('Set4_Adept',4,4),('Set4_Assassin',2,1),('Set4_Assassin',4,3),('Set4_Assassin',6,4),('Set4_Brawler',2,1),('Set4_Brawler',4,2),('Set4_Brawler',6,3),('Set4_Brawler',8,4),('Set4_Dazzler',2,1),('Set4_Dazzler',4,3),('Set4_Elderwood',3,1),('Set4_Elderwood',6,3),('Set4_Elderwood',9,4),('Set4_Enlightened',2,1),('Set4_Enlightened',4,2),('Set4_Enlightened',6,3),('Set4_Exile',1,1),('Set4_Exile',2,3),('Set4_Mage',3,1),('Set4_Mage',6,3),('Set4_Mage',9,4),('Set4_Mystic',2,1),('Set4_Mystic',4,3),('Set4_Mystic',6,4),('Set4_Ninja',1,1),('Set4_Ninja',4,3),('Set4_Shade',2,1),('Set4_Shade',3,3),('Set4_Shade',4,4),('Set4_Spirit',2,1),('Set4_Spirit',4,3),('Set4_Tormented',1,3),('Set4_Vanguard',2,1),('Set4_Vanguard',4,2),('Set4_Vanguard',6,3),('Set4_Vanguard',8,4),('Sharpshooter',2,1),('Sharpshooter',4,3),('Sharpshooter',6,4),('Warlord',3,1),('Warlord',6,3),('Warlord',9,4);
CREATE TABLE `traits` (
`id` varchar(32) NOT NULL,
`name` varchar(32) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `traits` VALUES ('Boss','우두머리'),('Cultist','광신도'),('Divine','신성'),('Duelist','결투가'),('Dusk','황혼'),('Emperor','황제'),('Fortune','행운'),('Hunter','사냥꾼'),('Keeper','귀감'),('Moonlight','달빛'),('Set4_Adept','조율자'),('Set4_Assassin','암살자'),('Set4_Brawler','싸움꾼'),('Set4_Dazzler','현혹술사'),('Set4_Elderwood','나무정령'),('Set4_Enlightened','선지자'),('Set4_Exile','추방자'),('Set4_Mage','요술사'),('Set4_Mystic','신비술사'),('Set4_Ninja','닌자'),('Set4_Shade','그림자'),('Set4_Spirit','영혼'),('Set4_Tormented','번뇌'),('Set4_Vanguard','선봉대'),('Sharpshooter','명사수'),('Warlord','대장군');
Data Analysis
Requirements
데이터 분석 모듈은 다음 요구사항이 존재합니다.
또한 다음 명령어를 통해 라이브러리를 설치해야합니다.
$ pip3 install requests pymysql
How to use
Jupyter Notebook으로 analysis.ipynb를 열고 riot_key 값을 발급받은 Riot API Key로 설정해주고 하단 데이터베이스 설정을 환경에 맞게 설정해준뒤 차례로 코드를 실행합니다.
주의사항
Riot Games의 Development API Key는 2분에 100개 API 호출의 제한이 있기 때문에 이로 인해 API 호출이 실패했을 경우 2분 후 다시 시도해야 합니다.
LINE Messaging API Webhook
Requirements
How to use
소스코드를 처음 받았으면 다음 명령어를 통해 라이브러리를 설치합니다.
$ npm install
app.js 파일의 channelToken을 발급받은 channel access token으로 설정하고 mysql.createPool()의 옵션을 데이터베이스 환경에 맞게 설정합니다.
다음 명령어를 통해 서비스를 실행합니다.
$ node app.js
Nginx나 Apache HTTP Server의 프록시 기능 등을 통해 HTTPS 연결을 활성화하고 LINE 관리자 페이지에서 Webhook URL을 등록합니다.