abrahimladha 8 yıl önce
işleme
4223dde5df
7 değiştirilmiş dosya ile 736 ekleme ve 0 silme
  1. 1 0
      .gitignore
  2. BIN
      __pycache__/itemshortener.cpython-36.pyc
  3. 12 0
      config.ini.example
  4. 19 0
      ideas.txt
  5. 280 0
      item-shortener.txt
  6. 228 0
      itemshortener.py
  7. 196 0
      lolbot.py

+ 1 - 0
.gitignore

@ -0,0 +1 @@
1
*.ini

BIN
__pycache__/itemshortener.cpython-36.pyc


+ 12 - 0
config.ini.example

@ -0,0 +1,12 @@
1
[Matrix]
2
Username:lol-bot
3
Password:test12345
4
Homeserver:https://vgd.me
5
6
#Riot games API. Not the riot matrix client
7
[Riot]
8
API_key:your_key_here
9
Region:NA
10
11
[Champion.gg]
12
API_key:your_key_here

+ 19 - 0
ideas.txt

@ -0,0 +1,19 @@
1
!ingame summoner returns true/false
2
!history summoner returns a list with entries like champ - kda - win/loss -
3
items - keystone
4
5
!mains summoner returns top 5 champions this user plays
6
!rank returns the league they are in (diamond, gold, etc)
7
!opgg formats nice link
8
9
10
champion.gg stuff
11
!winrate role (top/jungle/middle/adc/support)
12
!counter champion returns like 5 champion names
13
kills, deaths, assists, gold, pick, ban, play
14
15
16
config file should have riot api key, default region,champion.gg api key
17
18
Username - level 44
19
Orianna 5/4/11 LOSS item,item,item,item,item,item Flash/heal

+ 280 - 0
item-shortener.txt

@ -0,0 +1,280 @@
1
#yes i went through and did these all by hand. If you disagree with what I think is colloquial feel free to change it.
2
def renamer(longname: str):
3
    names = {
4
    'Boots of Speed':'boots',
5
    'Faerie Charm':'faerie charm',
6
    'Rejuvenation Bead':'rejuv bead',
7
    'Giant\'s Belt':'giants belt',
8
    'Cloak of Agility':'cloak of agility',
9
    'Blasting Wand':'blasting wand',
10
    'Sapphire Crystal': 'mana crystal',
11
    'Ruby Crystal':'ruby crystal',
12
    'Cloth Armor':'cloth armor',
13
    'Chain Vest':'chain vest',
14
    'Null-Magic Mantle':'nullmagic mantle',
15
    'Long Sword':'ls',
16
    'Pickaxe':'pickaxe',
17
    'B. F. Sword':'bf sword',
18
    'Hunter\'s Talisman':'talisman',
19
    'Hunter\'s Machete':'machete',
20
    'Dagger':'dagger',
21
    'Recurve Bow':'recurve',
22
    'Brawler\'s Gloves':'brawlers gloves',
23
    'Amplifying Tome':'amp tome',
24
    'Vampiric Scepter':'vamp scepter',
25
    'Doran\'s Shield':'dshield',
26
    'Doran\'s Blade':'dblade',
27
    'Doran\'s Ring':'dring',
28
    'Negatron Cloak':'negatron',
29
    'Needlessly Large Rod':'nlr',
30
    'The Dark Seal':'dark seal',
31
    'Cull':'cull',
32
    'Enchantment: Warrior':'warrior smite',
33
    'Enchantment: Cinderhulk':'cinderhulk smite',
34
    'Enchantment: Runic Echoes':'ap smite',
35
    'Enchantment: Bloodrazor':'as smite',
36
    'Health Potion':'hp pot',
37
    'Mana Potion':'mp pot',
38
    'Total Biscuit of Rejuvenation':'removed biscuit',
39
    'Total Biscuit of Everlasting Will':'biscuit',
40
    'Elixir Of Skill':'elixir of skill',
41
    'Looted Biscuit of Rejuvenation':'klepto biscuit',
42
    'Looted Oracle\'s Extract':'klepto oracles',
43
    'Kircheis Shard':'arrowhead',
44
    'Refillable Potion':'refillable',
45
    'Hunter\'s Potion':'hunters pot',
46
    'Corrupting Potion':'corrupting pots',
47
    'Oracle's Extract':'oracles extract',
48
    'Explorer's Ward
49
    'Guardian's Horn
50
    'Poro-Snax
51
    'Raptor Cloak
52
    'Diet Poro-Snax
53
    'Control Ward':'control ward'
54
    'Pilfered Stealth Ward
55
    'Peering Farsight Ward
56
    'Travel Size Elixir of Iron
57
    'Travel Size Elixir of Sorcery
58
    'Travel Size Elixir of Wrath
59
    'Pilfered Health Potion
60
    'Pilfered Potion of Rouge
61
    'Elixir of Iron
62
    'Elixir of Sorcery
63
    'Elixir of Wrath
64
    'Sly Sack of Gold
65
    'Minion Dematerializer
66
    'Commencing Stopwatch
67
    'Stopwatch':'stopwatch'
68
    'Broken Stopwatch':'broken stopwatch'
69
    'Slightly Magical Boots':'free boots'
70
    'Abyssal Mask
71
    'Archangel's Staff
72
    'Manamune
73
    'Berserker's Greaves':'beserkers'
74
    'Archangel's Staff (Quick Charge)
75
    'Manamune (Quick Charge)
76
    'Boots of Swiftness':'swifties'
77
    'Catalyst of Aeons':'catalyst'
78
    'Sorcerer\'s Shoes':'sorc shoes'
79
    'Frozen Mallet
80
    'Glacial Shroud
81
    'Iceborn Gauntlet':'iceborn'
82
    'Guardian Angel':'ga'
83
    'Rod of Ages':'roa'
84
    'Chalice of Harmony':'chalice'
85
    'Rod of Ages (Quick Charge)
86
    'Hextech GLP-800':'glp'
87
    'Infinity Edge':'ie'
88
    'Mortal Reminder':'mortal reminder'
89
    'Giant Slayer
90
    'Last Whisper':'lw'
91
    'Lord Dominik's Regards
92
    'Seraph's Embrace
93
    'Mejai\'s Soulstealer':'mejais'
94
    'Muramana
95
    'Muramana
96
    'Phage':'phage'
97
    'Phantom Dancer':'pd'
98
    'Ninja Tabi':'tabis'
99
    'Seraph's Embrace
100
    'Zeke's Convergence':'zekes'
101
    'Jaurim\'s Fist':'jaurims'
102
    'Sterak's Gage':'steraks'
103
    'Ohmwrecker':'ohmwrecker'
104
    'Sheen':'sheen'
105
    'Banner of Command':'banner'
106
    'Spirit Visage':'spirit visage'
107
    'Kindlegem':'kindlegem'
108
    'Sunfire Cape':'sunfire'
109
    'Remnant of the Ascended
110
    'Tear of the Goddess':'tear'
111
    'The Black Cleaver':'black cleaver'
112
    'The Bloodthirster':'bt'
113
    'Tear of the Goddess (Quick Charge)
114
    'Ravenous Hydra':'ravenous hydra'
115
    'Thornmail':'thornmail'
116
    'Bramble Vest':'bramble'
117
    'Tiamat':'tiamat'
118
    'Trinity Force':'trinity'
119
    'Warden's Mail':'wardens mail'
120
    'Warmog's Armor':'warmogs'
121
    'Overlord's Bloodmail
122
    'Runaan's Hurricane':'runaans'
123
    'Zeal':'zeal'
124
    'Statikk Shiv':'statikk'
125
    'Rabadon's Deathcap':'rabadons'
126
    'Wooglet's Witchcap':'wooglets'
127
    'Wit's End':'wits end'
128
    'Remnant of the Watchers
129
    'Rapid Firecannon':'rfc'
130
    'Nomad's Medallion
131
    'Targon's Brace':'targons'
132
    'Frostfang':'frostfang'
133
    'Lich Bane':'lich bane'
134
    'Stinger
135
    'Banshee's Veil':'banshees'
136
    'Lord Van Damm's Pillager
137
    'Aegis of the Legion':'aegis'
138
    'Redemption':'redemption'
139
    'Fiendish Codex
140
    'Knight's Vow':'knights vow'
141
    'Frozen Heart
142
    'Mercury's Treads':'merc treads'
143
    'Guardian's Orb
144
    'Aether Wisp
145
    'Forbidden Idol
146
    'Nashor's Tooth':'nashors'
147
    'Rylai's Crystal Scepter':'rylais'
148
    'Boots of Mobility':'mobis'
149
    'Wicked Hatchet
150
    'Executioner's Calling':'executioners'
151
    'Guinsoo's Rageblade':'rageblade'
152
    'Caulfield's Warhammer
153
    'Serrated Dirk
154
    'Void Staff':'void staff'
155
    'Haunting Guise
156
    'Dervish Blade
157
    'Mercurial Scimitar':'merc scimitar'
158
    'Quicksilver Sash':'qss'
159
    'Youmuu's Ghostblade':'yomuus'
160
    'Randuin's Omen':'randuins'
161
    'Bilgewater Cutlass':'cutlass'
162
    'Hextech Revolver':'revolver'
163
    'Hextech Gunblade':'gunblade'
164
    'Duskblade of Draktharr':'duskblade'
165
    'Liandry's Torment':'liandrys'
166
    'Hextech Protobelt-01':'protobelt'
167
    'Blade of the Ruined King':'bork'
168
    'Hexdrinker':'hexdrinker'
169
    'Maw of Malmortius':'maw'
170
    'Zhonya's Hourglass':'zhonyas'
171
    'Ionian Boots of Lucidity':'cdr boots'
172
    'Morellonomicon':'morellos'
173
    'Moonflair Spellblade':'moonflairs'
174
    'Athene's Unholy Grail':'athenes'
175
    'Head of Kha'Zix
176
    'Sanguine Blade
177
    'Guardian's Hammer
178
    'The Lightbringer
179
    'Arcane Sweeper
180
    'Locket of the Iron Solari':'locket'
181
    'Seeker's Armguard':'seekers'
182
    'Gargoyle Stoneplate
183
    'Adaptive Helm':'adaptive helm'
184
    'The Hex Core mk-1
185
    'The Hex Core mk-2
186
    'Perfect Hex Core
187
    'Prototype Hex Core
188
    'Spectre's Cowl':'cowl'
189
    'Mikael's Crucible':'mikaels'
190
    'Poacher's Dirk
191
    'Luden's Echo':'ludens'
192
    'Ancient Coin':'coin'
193
    'Relic Shield':'relic'
194
    'Spellthief's Edge':'spellthiefs'
195
    'Timeworn Ancient Coin':'full coin'
196
    'Timeworn Nomad's Medallion':'full nomads'
197
    'Timeworn Talisman of Ascension':'full'
198
    'Timeworn Relic Shield
199
    'Timeworn Targon's Brace
200
    'Timeworn Face of the Mountain
201
    'Timeworn Spellthief's Edge
202
    'Timeworn Frostfang
203
    'Timeworn Frost Queen's Claim
204
    'Warding Totem (Trinket)
205
    'Sweeping Lens (Trinket)
206
    'Soul Anchor (Trinket)
207
    'Arcane Sweeper
208
    'Greater Stealth Totem (Trinket)
209
    'Greater Vision Totem (Trinket)
210
    'Farsight Alteration
211
    'Oracle Alteration
212
    'Molten Edge
213
    'Forgefire Cape
214
    'Rabadon's Deathcrown
215
    'Infernal Mask
216
    'The Obsidian Cleaver
217
    'Salvation
218
    'Circlet of the Iron Solari
219
    'Trinity Fusion
220
    'Wooglet's Witchcrown
221
    'Zhonya's Paradox
222
    'Remnant of the Aspect
223
    'Head of Kha'Zix
224
    'Head of Kha'Zix
225
    'Head of Kha'Zix
226
    'Head of Kha'Zix
227
    'Golden Transcendence
228
    'Golden Transcendence (Disabled)
229
    'Seer Stone (Trinket)
230
    'Ardent Censer':'ardent'
231
    'Essence Reaver':'essence reaver'
232
    'Zz\'Rot Portal':'zzrot'
233
    'Eye of the Herald
234
    'The Black Spear
235
    'Siege Teleport
236
    'Siege Ballista
237
    'Siege Teleport
238
    'Tower: Beam of Ruination
239
    'Port Pad
240
    'Tower: Storm Bulwark
241
    'Nexus Siege: Siege Weapon Slot
242
    'Flash Zone
243
    'Vanguard Banner
244
    'Siege Refund
245
    'Entropy Field
246
    'Seer Stone (Trinket)
247
    'Shield Totem
248
    'Siege Teleport (Inactive)
249
    'Siege Sight Warder
250
    'Enchantment: Warrior
251
    'Enchantment: Cinderhulk
252
    'Enchantment: Runic Echoes
253
    'Enchantment: Bloodrazor
254
    'Frosted Snax
255
    'Super Spicy Snax
256
    'Espresso Snax
257
    'Rainbow Snax Party Pack!
258
    'Cosmic Shackle
259
    'Singularity Lantern
260
    'Dark Matter Scythe
261
    'Gravity Boots
262
    'Cloak of Stars
263
    'Dark Star Sigil
264
    'Stalker's Blade':'stalkers'
265
    'Tracker's Knife:'trackers'
266
    'Skirmisher's Sabre':'skirmishers'
267
    'Dead Man's Plate':'dead mans'
268
    'Titanic Hydra':'titantic'
269
    'Bami's Cinder':'bami cinder'
270
    'Righteous Glory':'righteous glory'
271
    'Crystalline Bracer':'bracer'
272
    'Lost Chapter':'lost chapter'
273
    'Death's Dance:'deaths dance',
274
    'Edge of Night':'edge of night',
275
    'Fire at Will':'gp longer',
276
    'Death's Daughter':'gp big boom',
277
    'Raise Morale':'gp fast'
278
    }
279
    return names[longname]
280

+ 228 - 0
itemshortener.py

@ -0,0 +1,228 @@
1
#yes i went through and did these all by hand.
2
#If you disagree with what I think is colloquial feel free to change it.
3
def renamer(longname: str):
4
    names = {
5
    'Boots of Speed':'boots',
6
    'Faerie Charm':'faerie charm',
7
    'Rejuvenation Bead':'rejuv bead',
8
    'Giant\'s Belt':'giants belt',
9
    'Cloak of Agility':'cloak of agility',
10
    'Blasting Wand':'blasting wand',
11
    'Sapphire Crystal': 'mana crystal',
12
    'Ruby Crystal':'ruby crystal',
13
    'Cloth Armor':'cloth armor',
14
    'Chain Vest':'chain vest',
15
    'Null-Magic Mantle':'nullmagic mantle',
16
    'Long Sword':'ls',
17
    'Pickaxe':'pickaxe',
18
    'B. F. Sword':'bf sword',
19
    'Hunter\'s Talisman':'talisman',
20
    'Hunter\'s Machete':'machete',
21
    'Dagger':'dagger',
22
    'Recurve Bow':'recurve',
23
    'Brawler\'s Gloves':'brawlers gloves',
24
    'Amplifying Tome':'amp tome',
25
    'Vampiric Scepter':'vamp scepter',
26
    'Doran\'s Shield':'dshield',
27
    'Doran\'s Blade':'dblade',
28
    'Doran\'s Ring':'dring',
29
    'Negatron Cloak':'negatron',
30
    'Needlessly Large Rod':'needlessly',
31
    'The Dark Seal':'dark seal',
32
    'Cull':'cull',
33
    'Enchantment: Warrior':'warrior smite',
34
    'Enchantment: Cinderhulk':'cinderhulk smite',
35
    'Enchantment: Runic Echoes':'ap smite',
36
    'Enchantment: Bloodrazor':'as smite',
37
    'Health Potion':'hp pot',
38
    'Mana Potion':'mp pot',
39
    'Total Biscuit of Rejuvenation':'removed biscuit',
40
    'Total Biscuit of Everlasting Will':'biscuit',
41
    'Elixir Of Skill':'elixir of skill',
42
    'Looted Biscuit of Rejuvenation':'klepto biscuit',
43
    'Looted Oracle\'s Extract':'klepto oracles',
44
    'Kircheis Shard':'arrowhead',
45
    'Refillable Potion':'refillable',
46
    'Hunter\'s Potion':'hunters pot',
47
    'Corrupting Potion':'corrupting pots',
48
    'Oracle\'s Extract':'oracles extract',
49
    'Guardian\'s Horn':'aram def',
50
    'Raptor Cloak':'raptor cloak',
51
    'Control Ward':'control ward',
52
    'Pilfered Stealth Ward':'klepto green ward',
53
    'Peering Farsight Ward':'klepto blue ward',
54
    'Travel Size Elixir of Iron':'klepto elixir of iron',
55
    'Travel Size Elixir of Sorcery':'klepto elixir of sorcery',
56
    'Travel Size Elixir of Wrath':'klepto elixir of wrath',
57
    'Pilfered Health Potion':'klepto hp pot',
58
    'Pilfered Potion of Rouge':'klepto rouge pot',
59
    'Elixir of Iron':'elixir of iron',
60
    'Elixir of Sorcery':'elixir of sorcery',
61
    'Elixir of Wrath':'elixir of wrath',
62
    'Sly Sack of Gold':'klepto gold sack',
63
    'Minion Dematerializer':'dematerializer',
64
    'Commencing Stopwatch':'inactive stopwatch',
65
    'Stopwatch':'stopwatch',
66
    'Broken Stopwatch':'broken stopwatch',
67
    'Slightly Magical Boots':'free boots',
68
    'Abyssal Mask':'abyssal mask',
69
    'Archangel\'s Staff':'archangels',
70
    'Manamune':'manamune',
71
    'Berserker\'s Greaves':'beserkers',
72
    'Archangel\'s Staff (Quick Charge)':'archangels',
73
    'Manamune (Quick Charge)':'manamune',
74
    'Boots of Swiftness':'swifties',
75
    'Catalyst of Aeons':'catalyst',
76
    'Sorcerer\'s Shoes':'sorc shoes',
77
    'Frozen Mallet':'frozen mallet',
78
    'Glacial Shroud':'glacial shroud',
79
    'Iceborn Gauntlet':'iceborn',
80
    'Guardian Angel':'ga',
81
    'Rod of Ages':'roa',
82
    'Chalice of Harmony':'chalice',
83
    'Rod of Ages (Quick Charge)':'roa',
84
    'Hextech GLP-800':'glp',
85
    'Infinity Edge':'ie',
86
    'Mortal Reminder':'mortal reminder',
87
    'Giant Slayer':'giant slayer',
88
    'Last Whisper':'lw',
89
    'Lord Dominik\'s Regards':'lord dominiks',
90
    'Seraph\'s Embrace':'seraphs',
91
    'Mejai\'s Soulstealer':'mejais',
92
    'Muramana':'muramana',
93
    'Phage':'phage',
94
    'Phantom Dancer':'pd',
95
    'Ninja Tabi':'tabis',
96
    'Zeke\'s Convergence':'zekes',
97
    'Jaurim\'s Fist':'jaurims',
98
    'Sterak\'s Gage':'steraks',
99
    'Ohmwrecker':'ohmwrecker',
100
    'Sheen':'sheen',
101
    'Banner of Command':'banner',
102
    'Spirit Visage':'spirit visage',
103
    'Kindlegem':'kindlegem',
104
    'Sunfire Cape':'sunfire',
105
    'Remnant of the Ascended':'coin ward',
106
    'Tear of the Goddess':'tear',
107
    'The Black Cleaver':'black cleaver',
108
    'The Bloodthirster':'bt',
109
    'Ravenous Hydra':'ravenous hydra',
110
    'Thornmail':'thornmail',
111
    'Bramble Vest':'bramble',
112
    'Tiamat':'tiamat',
113
    'Trinity Force':'triforce',
114
    'Warden\'s Mail':'wardens mail',
115
    'Warmog\'s Armor':'warmogs',
116
    'Runaan\'s Hurricane':'runaans',
117
    'Zeal':'zeal',
118
    'Statikk Shiv':'statikk',
119
    'Rabadon\'s Deathcap':'rabadons',
120
    'Wooglet\'s Witchcap':'wooglets',
121
    'Wit\'s End':'wits end',
122
    'Remnant of the Watchers':'spellthiefs ward',
123
    'Rapid Firecannon':'rfc',
124
    'Nomad\'s Medallion':'nomads',
125
    'Targon\'s Brace':'targons',
126
    'Frostfang':'frostfang',
127
    'Lich Bane':'lich bane',
128
    'Stinger':'stinger',
129
    'Banshee\'s Veil':'banshees',
130
    'Aegis of the Legion':'aegis',
131
    'Redemption':'redemption',
132
    'Fiendish Codex':'codex',
133
    'Knight\'s Vow':'knights vow',
134
    'Frozen Heart':'frozen heart',
135
    'Mercury\'s Treads':'merc treads',
136
    'Guardian\'s Orb':'aram ap',
137
    'Aether Wisp':'wisp',
138
    'Forbidden Idol':'forbidden idol',
139
    'Nashor\'s Tooth':'nashors',
140
    'Rylai\'s Crystal Scepter':'rylais',
141
    'Boots of Mobility':'mobis',
142
    'Executioner\'s Calling':'executioners',
143
    'Guinsoo\'s Rageblade':'rageblade',
144
    'Caulfield\'s Warhammer':'caufield',
145
    'Serrated Dirk':'serrated dirk',
146
    'Void Staff':'void staff',
147
    'Haunting Guise':'mini liandrys',
148
    'Mercurial Scimitar':'merc scimitar',
149
    'Quicksilver Sash':'qss',
150
    'Youmuu\'s Ghostblade':'yomuus',
151
    'Randuin\'s Omen':'randuins',
152
    'Bilgewater Cutlass':'cutlass',
153
    'Hextech Revolver':'revolver',
154
    'Hextech Gunblade':'gunblade',
155
    'Duskblade of Draktharr':'duskblade',
156
    'Liandry\'s Torment':'liandrys',
157
    'Hextech Protobelt-01':'protobelt',
158
    'Blade of the Ruined King':'bork',
159
    'Hexdrinker':'hexdrinker',
160
    'Maw of Malmortius':'maw',
161
    'Zhonya\'s Hourglass':'zhonyas',
162
    'Ionian Boots of Lucidity':'cdr boots',
163
    'Morellonomicon':'morellos',
164
    'Moonflair Spellblade':'moonflairs',
165
    'Athene\'s Unholy Grail':'athenes',
166
    'Guardian\'s Hammer':'aram ad',
167
    'Arcane Sweeper':'sweeper',
168
    'Locket of the Iron Solari':'locket',
169
    'Seeker\'s Armguard':'seekers',
170
    'Gargoyle Stoneplate':'stoneplate',
171
    'Adaptive Helm':'adaptive helm',
172
    'The Hex Core mk-1':'hexcore 1',
173
    'The Hex Core mk-2':'hexcore 2',
174
    'Perfect Hex Core':'hexcore perfect',
175
    'Prototype Hex Core':'prototype hexcore',
176
    'Spectre\'s Cowl':'cowl',
177
    'Mikael\'s Crucible':'mikaels',
178
    'Poacher\'s Dirk':'poachers dirk',
179
    'Luden\'s Echo':'ludens',
180
    'Ancient Coin':'coin',
181
    'Relic Shield':'relic',
182
    'Spellthief\'s Edge':'spellthiefs',
183
    'Timeworn Ancient Coin':'full coin',
184
    'Timeworn Nomad\'s Medallion':'full nomads',
185
    'Timeworn Talisman of Ascension':'full talisman',
186
    'Timeworn Relic Shield':'full relic',
187
    'Timeworn Targon\'s Brace':'full targon',
188
    'Timeworn Face of the Mountain':'full fotm',
189
    'Timeworn Spellthief\'s Edge':'full spellthiefs',
190
    'Timeworn Frostfang':'full frostfang',
191
    'Timeworn Frost Queen\'s Claim':'full frostqueens',
192
    'Warding Totem (Trinket)':'sight wards',
193
    'Sweeping Lens (Trinket)':'sweeping lens',
194
    'Arcane Sweeper':'sweeper',
195
    'Farsight Alteration':'blue trinket',
196
    'Molten Edge':'ornn ie',
197
    'Forgefire Cape':'ornn sunfire',
198
    'Rabadon\'s Deathcrown':'ornn rabadons',
199
    'Infernal Mask':'ornn abyssal mask',
200
    'The Obsidian Cleaver':'ornn black cleaver',
201
    'Salvation':'ornn redemption',
202
    'Circlet of the Iron Solari':'ornn locket',
203
    'Trinity Fusion':'ornn triforce',
204
    'Zhonya\'s Paradox':'ornn zhonyas',
205
    'Remnant of the Aspect':'relic ward',
206
    'Ardent Censer':'ardent',
207
    'Essence Reaver':'essence reaver',
208
    'Zz\'Rot Portal':'zzrot',
209
    'Eye of the Herald':'rift herald',
210
    'The Black Spear':'kalista bind',
211
    'Stalker\'s Blade':'stalkers',
212
    'Tracker\'s Knife':'trackers',
213
    'Skirmisher\'s Sabre':'skirmishers',
214
    'Dead Man\'s Plate':'dead mans',
215
    'Titanic Hydra':'titantic',
216
    'Bami\'s Cinder':'bami cinder',
217
    'Righteous Glory':'rglory',
218
    'Crystalline Bracer':'bracer',
219
    'Lost Chapter':'lost chapter',
220
    'Death\'s Dance':'deaths dance',
221
    'Edge of Night':'edge of night',
222
    'Fire at Will':'gp longer',
223
    'Death\'s Daughter':'gp big boom',
224
    'Raise Morale':'gp fast',
225
    'Oracle Alteration':'oracles'
226
    }
227
    return names[longname]
228

+ 196 - 0
lolbot.py

@ -0,0 +1,196 @@
1
from matrix_bot_api.matrix_bot_api import MatrixBotAPI
2
from matrix_bot_api.mhandler import MHandler
3
from matrix_bot_api.mregex_handler import MRegexHandler
4
from matrix_bot_api.mcommand_handler import MCommandHandler
5
6
import configparser
7
import math
8
import operator
9
import cassiopeia as cass
10
from  cassiopeia import Summoner, Match, Item, Items, Champion, Role
11
from cassiopeia.data import Season, Queue
12
from itemshortener import renamer
13
14
from collections import Counter
15
16
def history_callback(room,event):
17
    args = event['content']['body'].split(" ",1)[1]
18
    return_str = ""
19
    summoner = Summoner(name = args, region ="NA")
20
    match_history = summoner.match_history
21
    match_history(seasons={Season.season_8}, queues={Queue.ranked_solo_fives})
22
23
    champion_id_to_name_mapping = {champion.id: champion.name for champion in cass.get_champions(region="NA")}
24
    for x in range(0,20):
25
        champ_id = match_history[x].participants[summoner.name].champion.id
26
        player =  match_history[x].participants[summoner.name]
27
        kills =  player.stats.kills
28
        deaths =  player.stats.deaths
29
        assists =  player.stats.assists
30
31
        return_str += champion_id_to_name_mapping[champ_id]
32
        for x in range(0,14 - len(champion_id_to_name_mapping[champ_id])):
33
            return_str += " "
34
        return_str += "\t"
35
        return_str += str(kills) + "/" + str(deaths)+ "/" + str(assists) + "\t"
36
        return_str += "Win " if player.stats.win else "Loss "
37
        return_str += "\t"
38
        return_str += player.summoner_spell_d.name + " / " + player.summoner_spell_f.name
39
        for x in range(0,10 - len(player.summoner_spell_f.name)):
40
            return_str +=" "
41
        return_str += "\t"
42
        for item in player.stats.items:
43
            if item is not None:
44
                try:
45
                    return_str += str(renamer(item.name))
46
                except KeyError:
47
                    return_str += str(item.name)
48
                return_str += ", "
49
        return_str += "\n"
50
51
52
    room.send_notice(return_str)
53
54
def mains_callback(room, event):
55
    args = event['content']['body'].split(" ",1)[1]
56
    #names can have spaces
57
    #summoner = Summoner(name="Kalturi", account=34718348, id=21359666, region="NA")
58
    name = "Kalturi"
59
    #account = 34718348
60
    #id = 21359666
61
    region = "NA"
62
    summoner = Summoner(name=args,region=region)
63
    match_history = summoner.match_history
64
    match_history(seasons={Season.season_8}, queues={Queue.ranked_solo_fives})
65
    champion_id_to_name_mapping = {champion.id: champion.name for champion in cass.get_champions(region="NA")}
66
    played = Counter()
67
    for match in match_history:
68
        champion_id = match.participants[summoner.name].champion.id
69
        champion_name = champion_id_to_name_mapping[champion_id]
70
        played[champion_name] += 1
71
72
    return_str = ""
73
    room.send_notice("Top 5 champions {} played:".format(summoner.name))
74
    for champion_name, count in played.most_common(5):
75
        return_str += champion_name +"  "+str(count) + "\n"
76
    room.send_notice(return_str)
77
78
def rank_callback(room,event):
79
    args = event['content']['body'].split(" ",1)[1].rsplit(" ",1)[0]
80
    tiers = {'Tier.diamond':'D', 'Tier.master':'M', 'Tier.challenger':'C', 'Tier.platinum':'P', 'Tier.gold':'G', 'Tier.silver':'S','Tier.bronze':'B'}
81
    divisions = {'Division.one':'1','Division.two':'2','Division.three':'3','Division.four':'4','Division.five':'5'}
82
    return_str = ""
83
    summoner = Summoner(name=args,region="NA")
84
    positions = summoner.league_positions
85
    try:
86
        if positions.fives.promos is not None:
87
            return_str += "Promos: "
88
            for match in positions.fives.promos.progress:
89
                return_str += ("W-" if match else "L-")
90
            return_str += "\n"
91
        league = positions.fives
92
        return_str += tiers[str(league.tier)] + divisions[str(league.division)] + " " + str(league.league_points) + "LP " + str(league.wins) + "W " + str(league.losses) + "L"
93
        ratio = '{0:.2f}'.format(100 * league.wins / (league.wins + league.losses))
94
        return_str += " " + str(ratio) + "% WR"
95
    except Exception:
96
        return_str += "unranked"
97
    room.send_notice(return_str)
98
99
def opgg_callback(room,event):
100
    args = event['content']['body'].split(" ",1)[1]
101
    room.send_notice("http://na.op.gg/summoner/userName="+args)
102
103
def lolhelp_callback(room,event):
104
    help_str = "!history  -  Returns past 20 games and some data on them. \n"
105
    help_str += "!mains  -  Return most played champions of past several games. \n"
106
    help_str += "!op.gg  -  Posts an op.gg link if you want more info. \n"
107
    help_str += "!winrate  -  Returns highest winrate champion of a role. \n"
108
    help_str += "!lolhelp  -  Prints this."
109
    room.send_notice(help_str)
110
111
def winrate_callback(room,event):
112
    argz = event['content']['body'].split()
113
    if len(argz) == 1:
114
        room.send_notice("Need a role (top/jungle/mid/adc/support)")
115
        return
116
    argz.pop(0)
117
    args = argz[0]
118
    if len(argz) == 1:
119
        sorter = True
120
    if len(argz) == 2:
121
        sorter = (True if argz[1] == "worst" else False)
122
    else:
123
        room.send_notice("error")
124
        return
125
126
    roles = {"top","jungle","mid","adc","support"}
127
    if args not in roles:
128
        room.send_notice("invalid")
129
        return
130
131
    win_rates = {}
132
    role_converter = {}
133
    role_converter["top"] = Role.top
134
    role_converter["jungle"] = Role.jungle
135
    role_converter["mid"] = Role.middle
136
    role_converter["adc"] = Role.adc
137
    role_converter["support"] = Role.support
138
    champ_id_to_name_mapping = {champion.id: champion.name for champion in cass.get_champions(region="NA")}
139
    return_str = ""
140
    patcher = Champion(name="Annie", id=1,region="NA")
141
    #return_str += "Patch: " + str(patcher.championgg.championgg_metadata["patch"]) + "\n"
142
    for champ in cass.get_champions(region="NA"):
143
        try:
144
            win_rates[champ.id] = champ.championgg.win_rate[role_converter[args]]
145
        except Exception:
146
            pass
147
    sorted_x = sorted(win_rates.items(),key=operator.itemgetter(1),reverse=True)
148
    for x in range(0,5):
149
        return_str += champ_id_to_name_mapping[sorted_x[x][0]] + "\t\t" + str('{0:.2f}'.format(100*sorted_x[x][1])) + "%\n"
150
    room.send_notice(return_str)
151
152
def main():
153
    config = configparser.ConfigParser()
154
    config.read("config.ini")
155
    username = config.get("Matrix","Username")
156
    password = config.get("Matrix","Password")
157
    server = config.get("Matrix", "Homeserver")
158
    riot_key = config.get("Riot","API_key")
159
160
161
    #cass.set_default_region("NA")
162
    championgg_api_key = "b53dd758c723794046a42f669e83bbf0"
163
164
    config = cass.get_default_config()
165
    config["pipeline"]["ChampionGG"] = {
166
            "package": "cassiopeia_championgg",
167
            "api_key": championgg_api_key
168
        }
169
    cass.apply_settings(config)
170
    cass.set_riot_api_key("RGAPI-71e9891c-ca90-41c1-990c-c679e4471246")
171
    bot = MatrixBotAPI(username, password, server)
172
173
    m_history_handler = MCommandHandler('history', history_callback)
174
    bot.add_handler(m_history_handler)
175
176
    m_mains_handler = MCommandHandler('mains', mains_callback)
177
    bot.add_handler(m_mains_handler)
178
179
    m_rank_handler = MCommandHandler('rank', rank_callback)
180
    bot.add_handler(m_rank_handler)
181
182
    m_opgg_handler = MCommandHandler('opgg', opgg_callback)
183
    bot.add_handler(m_opgg_handler)
184
185
    m_winrate_handler = MCommandHandler('winrate',winrate_callback)
186
    bot.add_handler(m_winrate_handler)
187
188
    m_lolhelp_handler = MCommandHandler('lolhelp',lolhelp_callback)
189
    bot.add_handler(m_lolhelp_handler)
190
191
    bot.start_polling()
192
    while True:
193
        input()
194
195
if __name__ == "__main__":
196
    main()