Advertisement
westor

Game List parser for Aotik v1.0

Feb 22nd, 2015
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 2.93 KB | None | 0 0
  1. alias csids_save { ; by westor
  2.   if ($1) && (c isin $1) { var %output = .msg $2 ( $+ $3 $+ ): }
  3.   if (!$1) { var %output = echo -a }
  4.   var %v = csid_ $+ $ticks
  5.   var %u = http://api.steampowered.com/ISteamApps/GetAppList/v0001/
  6.   JSONOpen -ud %v %u
  7.   if (%JSONError) {
  8.     %output Error: There was an connection error while trying to save the game ids database! - (Error details: %JSONError $+ )
  9.     unset %updatelistrun
  10.     JSONClose %v
  11.     return
  12.   }
  13.   var %tot
  14.   var %f = games-ids.txt
  15.   var %t = $JSON(%v,applist,apps,app,length)
  16.   var %i = $lines(%f)
  17.   if (!%i) { var %i = 0 }
  18.   while (%i <= %t) {
  19.     var %id = $json(%v,applist,apps,app,%i,appid)
  20.     var %desc = $json(%v,applist,apps,app,%i,name)
  21.     if (%id) && (%desc) { write $qt(%f) %id %desc | inc %tot 1 }
  22.     inc %i
  23.   }
  24.   %output The Game IDs database has been updated. - (Total Saved:  $+ $iif(%tot,$v1,0) $+ )
  25.   unset %updatelistrun
  26.   JSONClose %v
  27. }
  28.  
  29. ON !*:TEXT:*:#: { ; by westor
  30.   tokenize 32 $strip($1-)
  31.   if ($1 == !gameid) {
  32.     if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify an number! | return }
  33.     if ($2 !isnum) { .msg $chan ( $+ $nick $+ ): Error, Please specify only numbers! | return }
  34.     if ($2 isnum) && ($2 !isalnum) { .msg $chan ( $+ $nick $+ ): Error, Please specify only digital numbers! | return }
  35.     var %f = games-ids.txt
  36.     if (!$isfile(%f)) { .msg $chan ( $+ $nick $+ ): Error, There is NOT any games-ids database available! | return }
  37.     if (!$lines(%f)) { .msg $chan ( $+ $nick $+ ): Error, The games-ids database is currently empty! | return }
  38.     var %r = $read(%f,nw,$2 $+ *)
  39.     var %game = $gettok(%r,2-,32)
  40.     if (!%game) { .msg $chan ( $+ $nick $+ ): The $qt($2) ID does NOT exist on the database! }
  41.     elseif (%game) { .msg $chan ( $+ $nick $+ ): The $qt($2) ID is $qt(%game) game. }
  42.   }
  43.   if ($1 == !gamename) || ($1 == !gamedesc) {
  44.     if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please specify a game name! | return }
  45.     var %f = games-ids.txt
  46.     if (!$isfile(%f)) { .msg $chan ( $+ $nick $+ ): Error, There is NOT any games-ids database available! | return }
  47.     if (!$lines(%f)) { .msg $chan ( $+ $nick $+ ): Error, The games-ids database is currently empty! | return }
  48.     var %r = $read(%f,nw,* $+ $2- $+ *)
  49.     if ($gettok(%r,2-,32) !== $2-) { .msg $chan ( $+ $nick $+ ): Error, The $qt($2-) Game does NOT match with the given try again and check your typo! | return }
  50.     var %id = $gettok(%r,1,32)
  51.     if (!%id) { .msg $chan ( $+ $nick $+ ): The $qt($2-) Game ID does NOT exist on the database! }
  52.     elseif (%id) { .msg $chan ( $+ $nick $+ ): The $qt($2-) Game ID is $qt(%id) id. }
  53.   }
  54.   if ($1 == !updategamelist) {
  55.     if (%updatelistrun) { return }
  56.     set -e %updatelistrun $ctime
  57.     .msg $chan ( $+ $nick $+ ): Updating the Games IDs database, This progress may take some minutes to complete, Please wait...
  58.     .timer[CSIDS] 1 1 csids_save -c $chan $nick
  59.   }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement