Mohammed Foud commited on
Commit
f644c01
·
1 Parent(s): 472b2ed

Fix some Bugs and add some Feathers

Browse files
a.py CHANGED
@@ -1,13 +1,111 @@
1
- import asyncio
2
- from fivesimapi import fivesim
3
 
4
- api_key = "YOUR_API_KEY" # Replace with your actual API key
 
 
 
 
 
 
 
5
 
6
- async def main():
7
- client = fivesim.FiveSim(api_key)
8
- country = "any" # You can specify a country code like 'us', 'ru', etc.
9
- products = await client.get_products(country)
10
- for product in products:
11
- print(f"Product: {product['product']}, Price: {product['cost']}, Available: {product['count']}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- asyncio.run(main())
 
 
 
 
 
 
 
 
 
1
+ import requests
 
2
 
3
+ url = "https://cdn.webook.com/"
4
+ headers = {
5
+ "Accept": "*/*",
6
+ "Content-Type": "application/json",
7
+ "Origin": "https://webook.com",
8
+ "Referer": "https://webook.com",
9
+ "User-Agent": "Mozilla/5.0"
10
+ }
11
 
12
+ payload = {
13
+ "query": """
14
+ query getEventDetail($lang:String,$limit:Int,$skip:Int,$where:EventFilter,$order:[EventOrder]) {
15
+ eventCollection(locale:$lang, limit:$limit, skip:$skip, where:$where, order:$order) {
16
+ items {
17
+ id
18
+ title
19
+ subtitle
20
+ slug
21
+ ticketingUrlSlug
22
+ startingPrice
23
+ currencyCode
24
+ isStreamingEvent
25
+ zoneEntryIncluded
26
+ streamingUrl
27
+ buttonLabel
28
+ cardButtonLabel
29
+ eventType
30
+ authGaurd
31
+ buttonLink
32
+ isComingSoon
33
+ whatToKnow
34
+ specialPromotion
35
+ showResellBanner
36
+ organizationSlug
37
+ visibility
38
+ image11 {
39
+ sys { id publishedAt }
40
+ url width height contentType title
41
+ }
42
+ image31 {
43
+ sys { id publishedAt }
44
+ url width height contentType title
45
+ }
46
+ description {
47
+ json
48
+ links { assets { block { sys { id } } } }
49
+ }
50
+ schedule {
51
+ title openTitle openDateTime closeDateTime openScheduleText
52
+ }
53
+ season {
54
+ title slug
55
+ }
56
+ category {
57
+ id title slug
58
+ }
59
+ location {
60
+ title address city countryCode seactionHeader
61
+ location { lat lon }
62
+ accessibility
63
+ banner {
64
+ sys { id publishedAt }
65
+ url width height contentType title
66
+ }
67
+ }
68
+ seo {
69
+ title description keywords noindex
70
+ image {
71
+ sys { id publishedAt }
72
+ url width height contentType title
73
+ }
74
+ }
75
+ cmsTagsCollection(limit: 10) {
76
+ items {
77
+ title slug id
78
+ background {
79
+ sys { id publishedAt }
80
+ url width height contentType title
81
+ }
82
+ icon {
83
+ sys { id publishedAt }
84
+ url width height contentType title
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ }
91
+ """,
92
+ "variables": {
93
+ "order": "order_ASC",
94
+ "lang": "en-US",
95
+ "limit": 1,
96
+ "where": {
97
+ "slug": "wwe-two-nights-bundle-wwe-tickets--season--374653"
98
+ }
99
+ },
100
+ "operationName": "getEventDetail"
101
+ }
102
 
103
+ response = requests.post(url, headers=headers, json=payload)
104
+
105
+ # Print response
106
+ try:
107
+ data = response.json()
108
+ print(data)
109
+ except Exception as e:
110
+ print("Error:", e)
111
+ print(response.text)
src/bots/handlers/webookHandlers.ts CHANGED
@@ -2,7 +2,7 @@ import { BotContext } from "../types/botTypes";
2
  import { createLogger } from '../../utils/logger';
3
  import { callbackReplyHandler } from "../utils/handlerUtils";
4
  import { messageManager } from "../utils/messageManager";
5
- import { webookAPI, EventFilters } from '../../webook/webookApi';
6
  import { Markup } from "telegraf";
7
  import { getBackToMainMenuButton, getLoggedInMenuKeyboard } from "../utils/keyboardUtils";
8
  import {
@@ -250,4 +250,37 @@ export function setupWeBookBookByUrlPaymentHandlers(bot: any) {
250
  }
251
  await handleBookingProcess(ctx, false);
252
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  }
 
2
  import { createLogger } from '../../utils/logger';
3
  import { callbackReplyHandler } from "../utils/handlerUtils";
4
  import { messageManager } from "../utils/messageManager";
5
+ import { webookAPI, EventFilters, getEventDetailsByUrl } from '../../webook/webookApi';
6
  import { Markup } from "telegraf";
7
  import { getBackToMainMenuButton, getLoggedInMenuKeyboard } from "../utils/keyboardUtils";
8
  import {
 
250
  }
251
  await handleBookingProcess(ctx, false);
252
  });
253
+ }
254
+
255
+ /**
256
+ * Handler to reply with event info when user sends a WeBook event URL
257
+ */
258
+ export async function handleWeBookEventInfoByUrl(ctx: BotContext) {
259
+ const message = ctx.message;
260
+ if (!message || typeof message !== 'object' || !('text' in message) || typeof message.text !== 'string') return false;
261
+ const url = message.text.trim();
262
+ if (!isValidWeBookEventUrl(url)) return false;
263
+ await ctx.reply('Fetching event information...');
264
+ const event = await getEventDetailsByUrl(url);
265
+ if (!event) {
266
+ await ctx.reply('Could not find event information for this URL.');
267
+ return true;
268
+ }
269
+ // Format event info
270
+ let info = `<b>${event.title || ''}</b>\n`;
271
+ if (event.subtitle) info += `<i>${event.subtitle}</i>\n`;
272
+ if (event.startingPrice) info += `Price: <b>${event.startingPrice} ${event.currencyCode || ''}</b>\n`;
273
+ if (event.schedule && event.schedule.openDateTime) info += `Start: <b>${event.schedule.openDateTime}</b>\n`;
274
+ if (event.schedule && event.schedule.closeDateTime) info += `End: <b>${event.schedule.closeDateTime}</b>\n`;
275
+ if (event.location && event.location.title) info += `Location: <b>${event.location.title}</b>\n`;
276
+ if (event.description && event.description.json && event.description.json.content && event.description.json.content.length > 0) {
277
+ const desc = event.description.json.content.map((c: any) => c.content && c.content[0] && c.content[0].value).filter(Boolean).join(' ');
278
+ if (desc) info += `\n${desc}`;
279
+ }
280
+ if (event.image11 && event.image11.url) {
281
+ await ctx.replyWithPhoto({ url: event.image11.url }, { caption: info, parse_mode: 'HTML' });
282
+ } else {
283
+ await ctx.reply(info, { parse_mode: 'HTML' });
284
+ }
285
+ return true;
286
  }
src/index.ts CHANGED
@@ -40,4 +40,4 @@ startServer();
40
 
41
 
42
 
43
- handleAddTelegrafBot("1e186256-fdd6-453f-8344-fd824660b8bd")
 
40
 
41
 
42
 
43
+ // handleAddTelegrafBot("1e186256-fdd6-453f-8344-fd824660b8bd")
src/webook/webookApi.ts CHANGED
@@ -347,4 +347,52 @@ export class WeBookAPI {
347
  }
348
 
349
  // Export a default instance
350
- export const webookAPI = new WeBookAPI();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
  }
348
 
349
  // Export a default instance
350
+ export const webookAPI = new WeBookAPI();
351
+
352
+ /**
353
+ * Fetch event details from WeBook API by event URL (slug)
354
+ * @param eventUrl string - full event URL (e.g. https://webook.com/en/events/slug)
355
+ * @returns event details object or null
356
+ */
357
+ export async function getEventDetailsByUrl(eventUrl: string): Promise<any | null> {
358
+ try {
359
+ // Extract slug from URL
360
+ const match = eventUrl.match(/\/events\/([a-zA-Z0-9\-]+)/);
361
+ if (!match || !match[1]) return null;
362
+ const slug = match[1];
363
+ const payload = {
364
+ query: `
365
+ query getEventDetail($lang:String,$limit:Int,$skip:Int,$where:EventFilter,$order:[EventOrder]) {
366
+ eventCollection(locale:$lang, limit:$limit, skip:$skip, where:$where, order:$order) {
367
+ items {
368
+ id title subtitle slug ticketingUrlSlug startingPrice currencyCode isStreamingEvent zoneEntryIncluded streamingUrl buttonLabel cardButtonLabel eventType authGaurd buttonLink isComingSoon whatToKnow specialPromotion showResellBanner organizationSlug visibility image11 { sys { id publishedAt } url width height contentType title } image31 { sys { id publishedAt } url width height contentType title } description { json links { assets { block { sys { id } } } } } schedule { title openTitle openDateTime closeDateTime openScheduleText } season { title slug } category { id title slug } location { title address city countryCode seactionHeader location { lat lon } accessibility banner { sys { id publishedAt } url width height contentType title } } seo { title description keywords noindex image { sys { id publishedAt } url width height contentType title } } cmsTagsCollection(limit: 10) { items { title slug id background { sys { id publishedAt } url width height contentType title } icon { sys { id publishedAt } url width height contentType title } } } }
369
+ }
370
+ }
371
+ `,
372
+ variables: {
373
+ order: "order_ASC",
374
+ lang: "en-US",
375
+ limit: 1,
376
+ where: { slug },
377
+ },
378
+ operationName: "getEventDetail"
379
+ };
380
+ const response = await axios.post("https://cdn.webook.com/", payload, {
381
+ headers: {
382
+ "Accept": "*/*",
383
+ "Content-Type": "application/json",
384
+ "Origin": "https://webook.com",
385
+ "Referer": "https://webook.com",
386
+ "User-Agent": "Mozilla/5.0"
387
+ }
388
+ });
389
+ const items = response.data?.data?.eventCollection?.items;
390
+ if (Array.isArray(items) && items.length > 0) {
391
+ return items[0];
392
+ }
393
+ return null;
394
+ } catch (e) {
395
+ console.error('Error fetching event details:', e);
396
+ return null;
397
+ }
398
+ }